Skip to main content
The SportriX WebSocket stream delivers live scores and statistics in real time — no polling required. As soon as a match state changes, you receive the full updated snapshot. Accessing the WebSocket stream requires the live_scores_statistics scope. Endpoint: wss://scores.sportrix.ai/v1/stream

Python example

The example below uses the websocket-client library to connect, subscribe to a match, and print a live score line on every update.
Always branch on d["sport"] — the snapshot schema is sport-specific. See the live snapshot reference for the full soccer, cricket, and American football shapes.

Multiplexing multiple matches

A single WebSocket connection can track any number of matches simultaneously. Send a subscribe message for each match you want to follow — there’s no need to open a separate connection per match. Because every data object carries match_id, you can always tell which match an incoming frame belongs to.

Handling ended matches

When a subscribed match leaves the live feed, you receive an ended frame with the match’s match_id:
For basketball and American football, an update frame with "status": "ended" arrives just before the ended frame. It carries the final score and stats, so you can persist it as the final result. Soccer matches finish with a "status": "ft" update instead. Cricket Tests leave the feed between days, so an ended frame alone does not mean a cricket match is over. An ended frame does not unsubscribe you. If the match reappears on the feed, for example after a transient provider gap, the stream resumes with a fresh snapshot followed by update frames. You don’t need to resubscribe. Send unsubscribe when you want to stop receiving frames for the match. See Ended frames for details.

Keeping the connection alive

The stream server sends a WebSocket ping every 30 seconds so idle connections survive client and proxy read timeouts on quiet matches. Make sure your client’s read/idle timeout is above 30 seconds (60 seconds is a good default) — you don’t need to send anything yourself, since most libraries auto-pong. See Keepalive (ping/pong) for library-specific examples.
If you only need live scores and the match clock (not full statistics), REST polling on GET /matches/{id}/live may be simpler and only requires the live_scores scope. Use the WebSocket when you need sub-second latency or want to stream stats to a live display.