a paused spotify track still returns 200

i built the now-playing widget assuming 200 meant "playing" and anything else meant "not playing". so the card sat there with the equalizer bars bouncing and the label reading "now playing", for a track that was paused.

the now playing card, bars bouncing
the now playing card, bars bouncing

the endpoint has three states, not two:

  • 204 — nothing playing at all
  • 202 — the player is between states
  • 200 — there is a track, and it may be paused

a paused track comes back with the complete item: name, artists, album art, everything. the only difference is is_playing: false.

if (current.status === 200) {
  const data = await current.json();
  return normalize(data.item, Boolean(data.is_playing));
}

the nice side effect is that a paused track is by definition the last thing you played, so it doubles as the recently-played fallback and saves a second request.

also worth knowing: podcasts come back with currently_playing_type: 'episode' and a different item shape with no artists array, so anything that maps over artists will throw.