Skip to main content
This page documents every message you can send to the SportriX WebSocket stream and every frame the server can send back. For connection setup and a quick-start example, see the WebSocket overview.

Client → Server messages

Send JSON objects to subscribe or unsubscribe from a match. The match_id is the integer id returned by the REST /matches endpoints. Subscribe:
Unsubscribe:

Control message fields

Server → Client frames

Every frame the server sends is a JSON object with an op field that identifies the frame type. The data object is a complete live snapshot, and always includes a match_id field. This lets a single connection multiplex updates from many matches — inspect data.match_id to route each frame to the right handler.

Example frames

Ended frames

The server sends an ended frame when a subscribed match leaves the live feed. The frame has no data object. Read the match id from the top-level match_id field. An ended frame does not unsubscribe you. Your subscription stays active until you send unsubscribe or close the connection. If the match reappears on the feed afterwards, for example after a transient provider gap, the server resumes the stream with a fresh snapshot frame followed by update frames. You don’t need to resubscribe.

Final snapshot for basketball and American football

For basketball and American football, SportriX sends a final update frame with "status": "ended" immediately before the ended frame. This update carries the full final snapshot: score, periods, stats, and box score. SportriX also stores it, so GET /matches/{id}/live returns the same final snapshot after the match ends.
SportriX does not send this final update in these cases:
  • Soccer: the last update already carries "status": "ft".
  • Cricket: multi-day Tests leave the live feed between days, so ended does not mean the match is over.
  • Matches that never started: no final snapshot is published.
For these cases, treat ended as “no longer live” rather than as a final state. For basketball and American football, use the "status": "ended" snapshot as the final result. If you no longer want frames for the match, send an unsubscribe message:
v1 sends a full snapshot on every update frame — there are no field-level deltas. Your handler can replace its local state entirely on each frame.
Subscribing to a match outside your enabled sport allowlist returns an error frame. The error message will indicate that the sport is not enabled for your API key.