demorphus

Demorphus API

The API does exactly what the Studio does, from your own code: you send a track, Demorphus processes it and checks it with SH Labs, then you fetch the MP3. Same pipeline, same allowance, same result.

1. Who can use it

The allowance is shared with the Studio: a track sent through the API counts like a track imported in the Studio. The free account has no API access.

2. Create a key

Sign in, open API access in the Studio, name the key and click “Create an API key”.

3. Authentication

API base URL: https://studio.demorphus.com/api/v1

Every request sends the key in the header Authorization: Bearer dmk_live_…. No cookie is read.

curl -H "Authorization: Bearer $DEMORPHUS_KEY" https://studio.demorphus.com/api/v1/me

4. Process a track

A track takes 10 to 15 minutes, so the API is asynchronous: you send the file, get an id back, then ask for the track until it is ready.

Send the file

curl -H "Authorization: Bearer $DEMORPHUS_KEY" \
     -H "Idempotency-Key: $(uuidgen)" \
     -F [email protected] https://studio.demorphus.com/api/v1/tracks

Response 202, with a Location header pointing at the track:

{"reused": false, "track": {"id": "8f0c…", "status": "queued", "audio_url": null, …}}

The optional Idempotency-Key header is recommended. If the connection drops and you resend the same file with the same value, you get the same track back (200, "reused": true) without it being counted twice. One value per upload: 1 to 64 characters among A-Z a-z 0-9 _ . : -. Reused with another file, or more than 24 hours later, it answers 409.

Follow the track

curl -H "Authorization: Bearer $DEMORPHUS_KEY" https://studio.demorphus.com/api/v1/tracks/$ID

Ask every 30 to 60 seconds. The status field is one of:

statusMeaning
queuedWaiting in the queue.
processingBeing processed.
doneFinished, the render passes below the SH Labs threshold.
not_reachedFinished, but no render passes the threshold: the best one is delivered and the track counts, as in the Studio.
unverifiedFinished, render delivered without an SH Labs verdict.
failedProcessing failed.

The track also carries the same information as the Studio report: scores before and after (baseline, attempts), duration, SHA-256 fingerprints of the source and result files, expiry date.

Download the MP3

curl -H "Authorization: Bearer $DEMORPHUS_KEY" -o song-demorphus.mp3 \
     https://studio.demorphus.com/api/v1/tracks/$ID/audio

Available when status is done, not_reached or unverified (the audio_url field is then set). Files are erased after 7 days, as in the Studio.

5. Endpoints

EndpointPurpose
GET /meYour plan and what is left: plan, status, unlimited, remaining_this_month, used_this_month, credits.
POST /tracksSends a track (multipart field file).
GET /tracksLists your tracks, Studio ones included.
GET /tracks/{id}One track.
GET /tracks/{id}/audioThe processed MP3.

6. Accepted files and limits

7. Errors

Every error returns {"error": "…", "code": "…"} : error is a readable message, code never changes and is what your code should branch on.

HTTPcode
400invalid_request
401invalid_key
402quota_exhausted
403forbidden
404not_found
405method_not_allowed
409conflict
413file_too_large
429rate_limited
503unavailable
other (500…)error

402 quota_exhausted : the month’s allowance is used up and no pay-as-you-go track is left. It resets on the first of next month, or buy pay-as-you-go tracks from My account.