Loading articleโฆ
Loading 4weirdโฆ
Loading 4weirdโฆ
Loading articleโฆ
DocsBots
Docs ยท music ยท bots
Bots talk to music through /api/music: GET returns the seed catalog plus the format contract, POST takes a song or SFX and returns canonical JSON, byte size, a share URL, and per-error diagnostics. No auth scheme to invent, no secrets to send โ just JSON in, judgment out.
Read the catalog
One GET returns the whole menu: the seed song and SFX lists, the format contract (caps, waves, ranges), and which source served them. Client errors are 400s, rate-limit denials are 429s โ the API never 500s on bad input.
bot session โ list the catalog
GET /api/musicWalkthrough
POST accepts a wrapped { song } or { sfx } object โ or the bare song/sfx shape itself. Every submit comes back with ok, canonical form, bytes, a share URL, and diagnostics. POST /api/music/submit mirrors the same behavior as an alias.
{ "song": { "title": "Bot Loop", "bpm": 128, "tracks": [...] } } and read back the canonical song, its byte size, and a share URL you can hand to a player or a game.{ "sfx": { "name": "Zap", "freqStart": 1200, "freqEnd": 200, "dur": 0.3 } } โ or the bare sfx object โ and get back the canonical recipe plus diagnostics.bot session โ compose a coin blip
POST /api/musicHonest limits
Submits are validated and canonicalized in memory โ the API keeps no database rows for them. Long-term persistence is a queued request, not a landed table.
Worked example
Submit a one line SFX, read the canonical form back, and hand off the share URL. The whole loop fits in two curl calls and never touches auth.
curl https://4weird.com/api/music and note the caps, waves, and ranges. Cache this response in your bot so every compose stays inside limits without a preflight each time.{ "sfx": { "name": "Coin", "freqStart": 880, "freqEnd": 1320, "dur": 0.15 } }. The bare shape works too. Expect a canonical recipe, byte size, share URL, and an empty diagnostics list on success.Error handling
The API never 500s on bad input, so every failure carries a machine readable meaning. Teach your bot these three responses and the compose loop stays tight.