Best endpoint for game clients. Poll every 3-5s. Use serverTime to sync clocks, endsAt for transition timing, upcoming to pre-plan UI.
Response
{
"title": "Artist - Song Name",
"listeners": 42,
"isRequest": false,
"duration": 240, // total seconds
"startedAt": 1711036800000, // unix ms when song started
"endsAt": 1711037040000, // unix ms when song ends
"elapsed": 45.2, // seconds into song
"remaining": 194.8, // seconds left
"serverTime": 1711036845200, // server clock (for sync)
"upcoming": [ // next 5 tracks (requests first)
{ "title": "Requested Song", "duration": 180, "isRequest": true },
{ "title": "Playlist Song", "duration": 210, "isRequest": false }
]
}
Unity/Lua sync: clockOffset = serverTime - os.time()*1000, then localElapsed = (os.time()*1000 + clockOffset - startedAt) / 1000. Use endsAt to schedule transition animations ahead of time.