DEV Community

lshadow
lshadow

Posted on

Licensing Music from Code: Search, License, and Stream Stems in Three API Calls

Music licensing assumes humans, lawyers, and business days. You email a rights holder, negotiate, sign a PDF, and wait. But the software I'm building — agents and apps that generate media — needs a track cleared in the same request cycle it discovered it. So I built the licensing step into an API.

The catalog as data

X402 Music exposes 240 pre-cleared tracks and 960+ stems across 30 genres as JSON: BPM, key, frequency distribution, sentiment tags, an 8-dimension emotion vector, and a per-track fee schedule. If a machine can't read it, it doesn't ship.

Discovery

Search by BPM range, key, mood tags, or vibe vector. Lookups run against an in-memory index and come back in single-digit milliseconds:

curl -s 'https://levievans.cloud/api/v1/search?min_bpm=120&max_bpm=128&key=Amin' \
  -H "authorization: Bearer $TOKEN"
Enter fullscreen mode Exit fullscreen mode

Licensing as an API call

Auth is one POST with a name — you get an API key (shown once) plus a JWT:

curl -s -X POST https://levievans.cloud/api/v1/auth/register \
  -H 'content-type: application/json' -d '{"name":"my-agent"}'
Enter fullscreen mode Exit fullscreen mode

Licensing is another POST with the track IDs. Every license returns a signed HMAC receipt you can verify offline — a receipt instead of a PDF contract. Fees are per track, starting at $0.20.

curl -s -X POST https://levievans.cloud/api/v1/license \
  -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
  -d '{"client_wallet":"0xabc","track_ids":["trk_neon_drive"]}'
Enter fullscreen mode Exit fullscreen mode

Streaming stems

Each track splits into drums, bass, melody, vocals, and FX, streamed as WAV at 1 credit per stem request (1 credit = 1 US cent). Billing is prepaid credits via Stripe Checkout — no subscription.

curl -s 'https://levievans.cloud/api/v1/stems/trk_neon_drive?stem=drums' \
  -H "authorization: Bearer $TOKEN" -o drums.wav
Enter fullscreen mode Exit fullscreen mode

I verified the full flow — register, search, catalog, and a real stem download — before writing this.

Open questions

Is per-track/per-stem micro-licensing the right granularity for agent-built media? And what catalog metadata would you need before trusting an API like this in production? Brutal feedback welcome — go break it: https://levievans.cloud

Top comments (0)