The Sportrix Data 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.sportrixdata.com/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.
import json, websocket # websocket-client
ws = websocket.create_connection(
"wss://scores.sportrixdata.com/v1/stream?key=sk_your_api_key_here"
)
ws.send(json.dumps({"action": "subscribe", "match_id": 41282}))
while True:
msg = json.loads(ws.recv())
if msg["op"] in ("snapshot", "update"):
d = msg["data"]
if d["sport"] == "cricket": # cricket has its own shape (no clock/phase)
s = d["score"]
print(f'{d["batting"]} {s["runs"]}/{s["wickets"]} ({s["overs"]}) '
f'- {d["last_event"]["label"]}')
else: # soccer
clock = d["clock"]
print(f'{d["home"]} {d["score"]["home"]}-{d["score"]["away"]} {d["away"]} '
f'[{clock["minute"]}:{clock["second"]:02d} {clock["period"]}] {d["phase"]["label"]}')
elif msg["op"] == "error":
print("error:", msg["error"])
Always branch on d["sport"] — the snapshot schema is sport-specific. See the live snapshot reference for the full soccer and cricket 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.
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.