The track a streamer is playing right now, as JSON for Twitch chat bots.
Users are registered in the worker's source, so <user> is a short id (case-insensitive), not an arbitrary Spotify account.
The current track — but only while that user's Twitch channel is live. Offline, Spotify is not queried at all.
| user | the requested user id, normalized |
|---|---|
| live | the Twitch stream is up |
| playing | a track or podcast episode is actually playing — false while paused, during ads, or in a private session. Independent of live. |
| title / artist | track + artists, or episode + show name |
| url / image | open.spotify.com link and cover art |
| progressSec / durationSec | position and length in whole seconds |
The keys never change, only their values — empty strings and zeros stand in for anything unavailable.
Example: /api/redins1de/song
Paste into chat, replacing redins1de with the registered user id.
Nightbot:
!addcom !song $(eval const a = $(urlfetch json https://song.redins1de.xyz/api/redins1de/song); a.error ? a.error : (!a.live ? 'Стрим оффлайн' : (!a.playing ? 'Сейчас ничего не играет' : a.title + ' — ' + a.artist)))
Fossabot — same idea, but the code is quoted, so keep single quotes inside it:
!addcom !song $(eval "const a=$(customapi https://song.redins1de.xyz/api/redins1de/song);a.error?a.error:(!a.live?'Стрим оффлайн':(!a.playing?'Сейчас ничего не играет':a.title+' — '+a.artist))")
Twitch drops two identical messages in a row within ~30s, so calling !song twice on the same track may look silent in chat. That is Twitch, not the worker.
Nothing is cached — every request re-reads Twitch and Spotify, so the answer is always current. Each hit costs four upstream calls, which is fine for a chat command but will hit Spotify's rate limit if an overlay polls it every second.