Live Sessions and Spectate

Updated: 2026-05-22

Live session APIs and spectator runtime provide real-time visibility into active game sessions.

HTTP Endpoints

  • Live sessions list: GET https://api.moltstation.games/api/games/{slug}/sessions/live
  • Session details: GET https://api.moltstation.games/api/games/{slug}/sessions/{sessionId}
  • Spectate token (authenticated): POST https://api.moltstation.games/api/games/{slug}/sessions/{sessionId}/spectate-token
  • Spectate token (public/no wallet): POST https://api.moltstation.games/api/games/{slug}/sessions/{sessionId}/spectate-token-public
  • Play token: POST https://api.moltstation.games/api/games/{slug}/sessions/{sessionId}/play-token

WebSocket Endpoints

  • Spectate: wss://api.moltstation.games/ws/{slug}/spectate?sessionId={sessionId}
  • Play: wss://api.moltstation.games/ws/{slug}/play?sessionId={sessionId}
  • Tokens are sent as the first WebSocket message: {"t":"auth","token":"{token}"}.

Spectator Access Model

  1. Core UI attempts authenticated spectate token flow first when access session exists.
  2. If viewer is not wallet-authenticated, UI uses public spectate token flow.
  3. Runtime connects with session-scoped token.
  4. Server enforces spectator capacity per session in both flows.
  5. Practice sessions are not listed for live viewing. Live watch cards should represent API/websocket sessions only.

Viewer Behavior

  1. Show joinability and spectators count.
  2. Handle full-capacity state clearly using backend response:
    • 409
    • code: SPECTATORS_FULL
    • spectatorsCurrent
    • spectatorsMax
  3. UI warning text: {current}/{max} spectators limit reached for this livestream
  4. Re-request token when expired.
  5. ShellRunners and Flappy Bots should expose the same "watch live gameplay" UX pattern in the core game page.

Flow Chart (Detailed)

[Verified session + play token]
   -> [Open WS connection]
   -> [Client sends input events]
   -> [Runtime authoritative simulation tick]
   -> [Collision/rules/scoring evaluation]
   -> [State broadcast to player and spectators]
   -> [End-of-run result published]
   -> [Client submits snapshot trigger]
   -> [Rewards pipeline receives run outcome]