Docs/Tennis API/WebSocket

Tennis Live WebSocket API

wss://api.citoapi.com/api/v1/tennis/live/ws · real-time point updates, match completions, and live prediction-market odds · +$15/mo add-on on Pro, included on Scale, Business & Enterprise

Stream real-time tennis points and odds without polling

Pro (+$15/mo WebSocket add-on) and Scale/Business/Enterprise plans receive real-time push frames with zero artificial delay.

Connection & Authentication

Authenticate server-side connections with the x-api-key or Authorization: Bearer <KEY> header during the WebSocket upgrade. Browser clients that cannot attach custom upgrade headers should pass the subprotocol array ["cito.v1", "cito.key.<KEY>"].

TypeScript
import WebSocket from "ws";

const apiKey = process.env.CITO_API_KEY!;
const url = "wss://api.citoapi.com/api/v1/tennis/live/ws";

const ws = new WebSocket(url, {
  headers: { "x-api-key": apiKey },
});

ws.on("open", () => {
  ws.send(JSON.stringify({
    action: "subscribe",
    rooms: ["all", "odds:m_2026_4893994"],
    snapshot: true,
  }));
});

ws.on("message", (raw) => {
  const frame = JSON.parse(raw.toString());
  if (frame.type === "ready") {
    console.log("connected, delay:", frame.delay_seconds);
  } else if (frame.type === "subscribed") {
    console.log("subscribed rooms:", frame.rooms);
  } else if (frame.type === "POINT_UPDATE") {
    console.log("point:", frame.match_id, frame.data?.game_score);
  } else if (frame.type === "MATCH_FINISHED") {
    console.log("finished:", frame.match_id);
  } else if (frame.type === "tennis.odds.snapshot" || frame.type === "tennis.odds.updated") {
    console.log("odds:", frame.match_id, frame.data);
  }
});

Rooms & Client Commands

Send a JSON command after receiving ready to subscribe to all (every live match), match:{matchId} (point and score updates for one match), or odds:{matchId} (live prediction-market odds snapshots and ticks for one match). Pass "snapshot": true to hydrate the current state immediately upon subscribing.

JSON
// Subscribe to all live matches with an immediate snapshot
{ "action": "subscribe", "rooms": ["all"], "snapshot": true }

// Subscribe to a specific match scoreboard and its live odds room
{ "action": "subscribe", "rooms": ["match:m_2026_4893994", "odds:m_2026_4893994"], "snapshot": true }

// Unsubscribe from rooms
{ "action": "unsubscribe", "rooms": ["match:m_2026_4893994"] }

Server Frames & Event Payloads

The socket emits ready on connect, subscribed after room changes, POINT_UPDATE and MATCH_FINISHED for match rooms, tennis.odds.snapshot and tennis.odds.updated for odds rooms, ping every 15 seconds, and error on invalid commands. Ignore frame types and fields you do not recognize.

JSON
// 1) Initial handshake & subscription confirmation
{ "type": "ready", "delay_seconds": 0 }
{ "type": "subscribed", "rooms": ["all", "odds:m_2026_4893994"] }

// 2) Point update frame (room: "all" or "match:{matchId}")
{
  "type": "POINT_UPDATE",
  "match_id": "m_2026_4893994",
  "data": {
    "id": "m_2026_4893994",
    "tour": "ATP",
    "status": "IN_PROGRESS",
    "current_set": 2,
    "game_score": "30-15",
    "server": 1,
    "player1": { "id": "atp_210097", "name": "Ben Shelton", "sets_won": 1, "current_game_score": "30", "is_serving": true },
    "player2": { "id": "atp_209950", "name": "Arthur Fils", "sets_won": 0, "current_game_score": "15", "is_serving": false },
    "sets": [
      { "set_number": 1, "player1_games": 6, "player2_games": 4, "is_completed": true },
      { "set_number": 2, "player1_games": 3, "player2_games": 2, "is_completed": false }
    ]
  }
}

// 3) Match finished frame (fetch /tennis/matches/{matchId} for the final box score)
{
  "type": "MATCH_FINISHED",
  "match_id": "m_2026_4893994",
  "data": { "id": "m_2026_4893994", "status": "COMPLETED" }
}

// 4) Live prediction-market odds frames (room: "odds:{matchId}")
{
  "type": "tennis.odds.snapshot",
  "match_id": "m_2026_4893994",
  "data": {
    "live": true,
    "market_status": "open",
    "h2h": { "player1_prob": 0.78, "player1_odds": 1.28, "player2_prob": 0.22, "player2_odds": 4.55 }
  }
}
{
  "type": "tennis.odds.updated",
  "match_id": "m_2026_4893994",
  "data": {
    "h2h": { "player1_prob": 0.81, "player1_odds": 1.23, "player2_prob": 0.19, "player2_odds": 5.26 }
  }
}

Heartbeats & Reconnect Backoff

A ping frame arrives every 15 seconds and there is no idle close. On disconnect, reconnect with exponential backoff plus jitter, re-send your subscribe message with "snapshot": true, or hydrate via GET /api/v1/tennis/matches/live so no point or match finish is missed while offline.

TypeScript
import WebSocket from "ws";

const ROOMS = ["all", "odds:m_2026_4893994"];
let attempt = 0;

function connect() {
  const ws = new WebSocket("wss://api.citoapi.com/api/v1/tennis/live/ws", {
    headers: { "x-api-key": process.env.CITO_API_KEY! },
  });

  ws.on("open", () => {
    attempt = 0;
  });

  ws.on("message", (raw) => {
    const msg = JSON.parse(raw.toString());
    if (msg.type === "ready") {
      ws.send(JSON.stringify({ action: "subscribe", rooms: ROOMS, snapshot: true }));
    } else if (msg.type === "POINT_UPDATE" || msg.type === "MATCH_FINISHED") {
      handleMatchEvent(msg);
    } else if (msg.type === "tennis.odds.snapshot" || msg.type === "tennis.odds.updated") {
      handleOddsEvent(msg);
    } else if (msg.type === "error" && msg.code === "MONTHLY_LIMIT_EXCEEDED") {
      console.error("Monthly API quota exhausted; stopping reconnect loop.");
      ws.close();
    }
  });

  ws.on("close", (code) => {
    if (code === 4029) return;
    const delay = Math.min(30_000, 1000 * 2 ** attempt++) + Math.random() * 500;
    setTimeout(connect, delay);
  });
}

connect();

Quota Metering & Plan Access

RuleBehavior
Pushed frames0 per-frame charges. Receiving POINT_UPDATE, MATCH_FINISHED, or tennis.odds.* frames never adds per-message fees.
Open connection meteringCounts 1 request on upgrade plus 1 request per 15 seconds open (identical to /tennis/live/stream SSE).
Plan access & delayRequires Pro (+$15/mo WebSocket add-on), Scale, Business, or Enterprise. Eligible WebSocket plans run in real time (delay_seconds: 0). Free and Starter receive 403 WEBSOCKETS_REQUIRED on upgrade.
Error framesServer sends structured error frames for invalid rooms, bad JSON, or quota limits (MONTHLY_LIMIT_EXCEEDED).

Transport Comparison

TransportEndpointMeteringBest for
WebSocketWSS /api/v1/tennis/live/ws1 req at connect + 1 req / 15s open (0 per pushed frame)Multiplexed match: & odds: rooms, real-time points & odds
SSEGET /api/v1/tennis/live/stream1 req at connect + 1 req / 15s openHTTP-only scoreboard streams; works on Free/Starter (60s delay) & Pro+
REST PollGET /api/v1/tennis/matches/live1 req per HTTP callInitial hydration, cron jobs, and Free/Starter delayed widgets

Frequently Asked Questions

What is the Tennis Live WebSocket URL?

Connect to wss://api.citoapi.com/api/v1/tennis/live/ws. Once connected, send {"action":"subscribe","rooms":["all"],"snapshot":true} (or target match:{matchId} and odds:{matchId} rooms).

How do I authenticate to the Tennis WebSocket endpoint?

Server-side clients send either the x-api-key header or Authorization: Bearer <KEY> on the WebSocket upgrade request. Browser clients pass the subprotocol array ["cito.v1", "cito.key.<KEY>"].

Which rooms and events are supported?

Rooms are all, match:{matchId}, and odds:{matchId}. Server events include ready, subscribed, POINT_UPDATE, MATCH_FINISHED, tennis.odds.snapshot, tennis.odds.updated, ping (every 15 seconds), and error. Ignore unknown frame types and extra fields for forward compatibility.

Do pushed WebSocket frames count toward my monthly API quota?

No per-frame charges apply to POINT_UPDATE, MATCH_FINISHED, or tennis.odds.* frames. An open connection meters 1 request on upgrade plus 1 request per 15 seconds while connected—the same cadence as /tennis/live/stream SSE.

Which plans include Tennis Live WebSockets?

Tennis Live WebSockets are included on Scale ($100/mo), Business CSV ($299/mo), and Enterprise, or available as a +$15/mo add-on on Pro ($59/mo). Free and Starter keys receive HTTP 403 WEBSOCKETS_REQUIRED during upgrade and should use /tennis/live/stream SSE or /tennis/matches/live REST (60-second delay).

Was this page helpful?