The Sportrix Data WebSocket stream gives you a persistent, low-latency connection for real-time live scores and statistics. Rather than polling the REST API, you subscribe to one or more matches and receive an immediate snapshot followed by pushed updates whenever the match state changes.
Endpoint
wss://scores.sportrixdata.com/v1/stream
Required scope: live_scores_statistics
Authentication
Pass your API key as a ?key= query parameter or an X-API-Key header. The query parameter is the most convenient option for WebSocket clients that cannot set custom headers:
wss://scores.sportrixdata.com/v1/stream?key=sk_your_api_key_here
The connection is rejected with HTTP 401 if the key is invalid, disabled, expired, or does not have the live_scores_statistics scope.
How it works
- Connect to the endpoint with your API key.
- Send a subscribe message with the
match_id of the match you want to follow (the same id returned by the REST /matches endpoints).
- Receive a snapshot immediately after subscribing, then receive update frames whenever the match state changes.
- Send an unsubscribe message when you no longer need updates for a match.
A single connection can subscribe to multiple matches simultaneously. Every data frame includes a match_id field so you can demultiplex frames from different matches on the same connection.
Subscribe and unsubscribe
Send JSON control messages to the server:
{"action": "subscribe", "match_id": 41282}
{"action": "unsubscribe", "match_id": 41282}
Only matches in your enabled sports can be subscribed. Attempting to subscribe to a match outside your sport allowlist returns an error frame instead of a snapshot.
Python example
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"]
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"])
If you only need scores without full match statistics, the REST GET /matches/{id}/live endpoint with the live_scores scope may be simpler than maintaining a WebSocket connection.
Next steps
See the WebSocket Message Reference for the complete specification of every client message and server frame.