Skip to content
datasportsAPI

WebSocketConnect

Documentation

/

Type to filter the docs by title or path.

WebSocketEndpoint 116 of 116

Connect

WS

wss://api.datasportsapi.com/?ticket={ticket}

Plan
Business
Auth
Single-use ticket
Parameters
None
Returns
Frames

Open a connection to the url returned with the ticket.

The server first sends welcome — protocol 4 from 2026-10-23 on (protocol 3 earlier that same day, protocol 2 from 2026-10-19) — and then you subscribe to channels. A subscription opens with a snapshot (or, when a lastSeq replay finishes or you subscribe again, with a subscribed frame), and every later frame carries a per-channel seq that rises by one each time.

Treat seq as opaque: it is seeded from the server clock rather than starting at 0. Whenever a fixture enters the set of a livescores, sport:{slug}, league:{id} or team:{id} channel — it kicked off, or the server sees it for the first time — it arrives as a fixture frame holding the complete Fixture.

Later deltas patch it, and deltas only ever touch fixtures you have already been sent; when a fixture leaves the set (finished, canceled), one final delta reports that.

Plan access

Requires the Business plan; on any other plan the ticket request returns 403 ws_not_available.

Worth knowing

  • With protocol 4 you must process the fixture frame: a client that ignores it misses every match kicking off while it is connected.
  • The changes in a delta form a partial Fixture — merge them field by field into your copy.
  • The merge goes into nested objects too (homeScore, clock, cricket innings, …); they are never swapped out whole.
  • Every frame includes ts, the server time in Unix milliseconds.
  • Close codes: 1008 means the ticket is invalid or expired (mint another) or, on a connection that is already open, that its API key was revoked, the account was suspended or the plan changed — the close reason says which, and these are checked the moment they happen and once a minute; 1013 means your plan’s limit on concurrent connections has been reached.
  • The server sends a protocol-level ping every heartbeatMs and drops connections that stop responding.
  • When a score goes DOWN (a goal ruled out, a corrected basket), you get it with the lowered period scores within 1.5 s of the source reporting it (5 s in football).
  • We hold it back because the source sometimes briefly repeats an older score; since 2026-10-24 those flaps are dropped.

01Example session

← server → client
← { "type": "welcome", "protocol": 4, "heartbeatMs": 30000, "maxChannels": 50, "replay": true }
→ { "type": "subscribe", "channel": "livescores" }
← { "type": "snapshot", "channel": "livescores", "seq": 1760800000000, "ts": 1760800000000, "data": [ Fixture, … ] }
← { "type": "fixture", "channel": "livescores", "seq": 1760800000001, "ts": 1760800002480,
    "id": 201330, "sport": "basketball", "data": { "id": 201330, "sport": "basketball",
    "status": { "type": "inprogress", "phase": "inprogress", "code": 13, "description": "1st quarter", "period": "period1", "finish": null }, … } }
← { "type": "delta", "channel": "livescores", "seq": 1760800000002, "ts": 1760800004120,
    "id": 201324, "sport": "football",
    "changes": { "awayScore": { "current": 1, "periods": { "period2": 1 } } } }
← { "type": "delta", "channel": "livescores", "seq": 1760800000003, "ts": 1760800009310,
    "id": 201324, "sport": "football",
    "changes": { "status": { "code": 100, "description": "Ended", "type": "finished", "phase": "finished",
                             "finish": "regular", "period": null },
                 "winner": "away", "clock": null } }

// Reconnect with the last seq you hold (Business): the missed frames, then subscribed
→ { "type": "subscribe", "channel": "livescores", "lastSeq": 1760800000003 }
← { "type": "subscribed", "channel": "livescores", "seq": 1760800000003, "ts": 1760800030000, "replayed": 0 }

// fixture:{id} — play by play appended from index start (since 2026-10-24)
← { "type": "playByPlay", "channel": "fixture:201330", "seq": 1760800040000, "ts": 1760800041900, "id": 201330, "sport": "basketball",
    "start": 117, "total": 118, "entries": [ { "type": "scoreChange", "side": "home", "period": "period3", "periodSecond": 401,
      "text": "Jump shot made", "homeScore": 69, "awayScore": 74, "scoreType": "twoPointer", … } ] }
← { "type": "shotmap", "channel": "fixture:201324", "seq": 1760800050000, "ts": 1760800050500, "id": 201324, "sport": "football",
    "shots": [ { "side": "away", "outcome": "goal", "minute": 37, "period": "period1", … }, … ] }

→ { "type": "subscribe", "channel": "fixture:999999999999" }
← { "type": "error", "code": "unknown_fixture", "channel": "fixture:999999999999", "message": "no fixture with that id", "ts": 1760800031000 }
→ { "type": "unsubscribe", "channel": "sport:tennis" }
← { "type": "error", "code": "not_subscribed", "channel": "sport:tennis", "message": "not subscribed to this channel", "ts": 1760800032000 }