spotify-now-playing

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.

GET /api/<user>/song

The current track — but only while that user's Twitch channel is live. Offline, Spotify is not queried at all.

userthe requested user id, normalized
livethe Twitch stream is up
playinga track or podcast episode is actually playing — false while paused, during ads, or in a private session. Independent of live.
title / artisttrack + artists, or episode + show name
url / imageopen.spotify.com link and cover art
progressSec / durationSecposition 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

Ready-to-use commands

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.

Freshness

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.