Live WebSockets

Real-time scores, the full archive since 1968 and webhooks are on Pro. Free keys: 500 calls/month, live 60 s delayed, last 30 days.

Credit metering & bulk CSVs: 0–90 day, live, and bio metadata queries cost 1 credit (ceil(ids/10) for batches). Queries spanning >= 91 days cost 5x narrow (+5/?include=) or 10 * ceil(limit/25) bulk (+5 * ceil(limit/25)/?include=) against both monthly credits and your >90d sub-cap (Free/Starter 0, Legacy 25k, Pro 50k, Scale/Business REST 100k, Business CSV $299/mo & Enterprise unlimited; 429 HISTORICAL_ARCHIVE_CAP_EXCEEDED only on >90d while <=90d & live stay 200 OK). For full backtests at 0 REST credits, Business CSV ($299/mo) delivers Master Baseline + Daily Delta CSVs.

The live socket pushes every point of every live match as the scoreboard changes, live prediction-market odds updates (tennis.odds.snapshot, tennis.odds.updated), and a final event when a match ends. Available on Scale, Business, and on Pro with the Live WebSockets add-on.

Connect

text
wss://api.citoapi.com/api/v1/tennis/live/ws

Authenticate on the upgrade with the x-api-key header, Authorization: Bearer <key>, or the api_key query parameter. A key without WebSocket access is refused with HTTP 403 and error.code WEBSOCKETS_REQUIRED.

javascript
const ws = new WebSocket("wss://api.citoapi.com/api/v1/tennis/live/ws?api_key=YOUR_API_KEY");

ws.onopen = () => ws.send(JSON.stringify({ action: "subscribe", rooms: ["all"] }));

ws.onmessage = (event) => {
  const frame = JSON.parse(event.data);
  if (frame.type === "POINT_UPDATE") console.log(frame.match_id, frame.data.game_score, frame.data.sets);
  if (frame.type === "tennis.odds.updated" || frame.type === "tennis.odds.snapshot") console.log("odds", frame.match_id, frame.data.probabilities);
  if (frame.type === "MATCH_FINISHED") console.log("final", frame.match_id, frame.data.sets);
};

Messages you send

MessageEffect
{"action":"subscribe","rooms":["all"]}Every live match (points and odds events).
{"action":"subscribe","rooms":["match:m_4893994"]}One match scoreboard + point updates, by the id from /matches/live.
{"action":"subscribe","rooms":["odds:m_4893994"]}Live odds snapshot and real-time tennis.odds.updated frames for one match.
{"action":"unsubscribe","rooms":["match:m_4893994"]}Stop one match.
{"action":"ping"}The server answers pong.

Nothing is sent until you subscribe to a room. Invalid JSON or an unknown room answers an error frame (INVALID_JSON, BAD_ROOMS); the connection stays open.

Frames you receive

These three are real frames from the production socket. The point frame below shows its shape, with values abbreviated:

json
{"type":"ready","stream":"tennis.live","path":"/api/v1/tennis/live/ws","rooms":[],"protocol":{"subscribe":{"action":"subscribe","rooms":["match:{matchId}","all"]},"unsubscribe":{"action":"unsubscribe","rooms":["match:{matchId}"]},"ping":{"action":"ping"}},"events":["POINT_UPDATE","MATCH_FINISHED"]}
{"type":"subscribed","rooms":["all"],"changed":["all"]}
{"type":"ping","ts":"2026-10-02T23:06:00.037Z"}

POINT_UPDATE and MATCH_FINISHED share one shape. data carries the scoreboard: sets, the current game score, the server, the tiebreak score when one is on, the last points played and the match statistics so far.

json
{
  "type": "POINT_UPDATE",
  "match_id": "m_4893994",
  "data": {
    "match_id": "m_4893994",
    "tour": "ATP",
    "tournament_name": "ATP World Tour Finals",
    "round": "RR",
    "round_name": "Round Robin",
    "player1": { "id": "atp_…", "name": "…" },
    "player2": { "id": "atp_…", "name": "…" },
    "current_set": 2,
    "game_score": "30-40",
    "server": 1,
    "status": "IN_PROGRESS",
    "sets": [ { "set_num": 1, "score": "4-6" }, { "set_num": 2, "score": "2-1" } ],
    "tiebreak_score": null,
    "point_history": [ "…last 10 points…" ],
    "stats": [ "…match statistics so far…" ]
  }
}

Timing and recovery

  • Updates arrive within seconds of each point: the live feed is read every few seconds and each change is pushed as it lands.
  • The server sends a ping frame every 15 seconds; a socket that sees none for 45 seconds should reconnect.
  • After a reconnect, call GET /tennis/matches/live once to resynchronise every scoreboard, then keep the socket. REST and the socket carry the same ids and the same scores (checked on every live match in our launch sweep).
  • A match that ends is archived into the match history immediately, under the same id, so /tennis/matches/{id} and player match logs have it as soon as MATCH_FINISHED arrives.

Real-time scores, the full archive since 1968 and webhooks are on Pro. Free keys: 500 calls/month, live 60 s delayed, last 30 days.