Tennis API in Node.js & TypeScript: fetch, WebSockets, and webhooks
Use Node 18+ native fetch for typed REST queries, connect to wss://api.citoapi.com/api/v1/tennis/live/ws for pushed POINT_UPDATE and tennis.odds.updated frames, or verify HMAC-SHA256 webhook deliveries in Express.
Pro $59/mo: real-time scores, full archive since 1968, match webhooks. Free: 500 calls/month, live 60 s delayed, last 30 days. Read the docs
$ curl "https://api.citoapi.com/api/v1/tennis/matches/live?page_size=2" \
-H "x-api-key: YOUR_API_KEY"In short
Call GET /api/v1/tennis/* from Node.js 18+ with built-in fetch, stream real-time points and live odds over wss://api.citoapi.com/api/v1/tennis/live/ws (rooms: all or match:{id}), and verify X-Cito-Signature HMAC-SHA256 webhooks.
1. Typed REST client with native fetch (Node 18+)
No wrapper package is required: send x-api-key from process.env.CITO_API_KEY and type the JSON payloads directly in TypeScript. Keep your API key on your Node.js server or API route — never expose it in browser JavaScript.
tennis-client.ts — Typed live board & odds helper
const API = "https://api.citoapi.com/api/v1/tennis";
const KEY = process.env.CITO_API_KEY!;
export interface LiveMatch {
id: string;
tour: "ATP" | "WTA" | string;
tournament_name: string;
round_name: string;
surface: string;
status: string;
game_score: string | null;
tiebreak_score: string | null;
player1: { id: string; name: string; sets_won: number; is_serving: boolean };
player2: { id: string; name: string; sets_won: number; is_serving: boolean };
sets: Array<{ set_number: number; score: string; is_completed: boolean }>;
}
export async function getTennis<T>(path: string): Promise<T> {
const res = await fetch(`${API}${path}`, {
headers: { "x-api-key": KEY, Accept: "application/json" },
});
if (!res.ok) throw new Error(`Tennis API ${res.status}: ${await res.text()}`);
return (await res.json()) as T;
}
const live = await getTennis<{ items: LiveMatch[]; total: number }>("/matches/live?page_size=10");
for (const m of live.items) {
console.log(`${m.player1.name} vs ${m.player2.name} | ${m.sets.map((s) => s.score).join(" ")} | ${m.game_score}`);
}Live matches JSON payload
curl "https://api.citoapi.com/api/v1/tennis/matches/live?page_size=2" \
-H "x-api-key: YOUR_API_KEY"{
"success": true,
"items": [
{
"id": "m_2026_4893994",
"tour": "ATP",
"tournament_name": "John McEnroe",
"round_name": "Round not recorded",
"surface": "Unknown",
"best_of": 3,
"status": "IN_PROGRESS",
"player1": {
"id": "atp_210097",
"name": "Ben Shelton",
"ioc": "USA",
"seed": null,
"sets_won": 1,
"current_game_score": "15",
"is_serving": true
},
"player2": {
"id": "atp_209950",
"name": "Arthur Fils",
"ioc": "FRA",
"seed": null,
"sets_won": 1,
"current_game_score": "15",
"is_serving": false
},
"current_set": 3,
"game_score": "15-15",
"server": 1,
"tiebreak_score": null,
"sets": [
{
"set_number": 1,
"score": "6-2",
"tiebreak": null,
"is_completed": true
},
{
"set_number": 2,
"score": "3-6",
"tiebreak": null,
"is_completed": true
},
{
"set_number": 3,
"score": "5-3",
"tiebreak": null,
"is_completed": false
}
],
"last_updated_at": "2026-11-15T21:37:36.349237+00:00"
}
],
"total": 5
}2. Live WebSocket client with heartbeat & reconnect
Subscribe to rooms ["all"] or ["match:{match_id}"] (up to 32 rooms per connection) on wss://api.citoapi.com/api/v1/tennis/live/ws. Authenticate with the x-api-key header (or ?apiKey=, or browser subprotocols ["cito.v1", "cito.key." + key]). Pass snapshot: true on subscribe to receive immediate SNAPSHOT state, and receive POINT_UPDATE, MATCH_FINISHED, tennis.odds.snapshot, and tennis.odds.updated frames. The server pings every 15 seconds; reconnect with backoff if silent for 45 seconds and resync via GET /tennis/matches/live.
live-ws.mjs — Reconnecting Node.js WebSocket consumer (points + live odds)
import WebSocket from "ws";
const WS_URL = "wss://api.citoapi.com/api/v1/tennis/live/ws";
const KEY = process.env.CITO_API_KEY;
let delayMs = 1000;
function connect() {
const ws = new WebSocket(WS_URL, { headers: { "x-api-key": KEY } });
let lastSeen = Date.now();
ws.on("open", () => {
delayMs = 1000;
ws.send(JSON.stringify({ action: "subscribe", rooms: ["all"], snapshot: true }));
});
ws.on("message", (buf) => {
lastSeen = Date.now();
const msg = JSON.parse(buf.toString("utf8"));
if (msg.type === "ping" || msg.type === "pong") return;
if (msg.type === "POINT_UPDATE") {
console.log("POINT", msg.match_id, msg.data?.game_score, msg.data?.sets);
} else if (msg.type === "tennis.odds.updated" || msg.type === "tennis.odds.snapshot") {
console.log("ODDS", msg.matchId ?? msg.match_id, msg.odds ?? msg.data);
} else if (msg.type === "MATCH_FINISHED") {
console.log("FINAL", msg.match_id, msg.data?.sets);
}
});
const watchdog = setInterval(() => {
if (Date.now() - lastSeen > 45_000) ws.terminate();
}, 5000);
ws.on("close", () => {
clearInterval(watchdog);
const wait = delayMs + Math.random() * 1000;
delayMs = Math.min(delayMs * 2, 30_000);
setTimeout(connect, wait);
});
}
connect();import crypto from "node:crypto";
import express from "express";
const app = express();
const seen = new Set();
app.post("/hooks/tennis", express.raw({ type: "application/json" }), (req, res) => {
const expected = crypto.createHmac("sha256", process.env.CITO_WEBHOOK_SECRET).update(req.body).digest("hex");
const got = req.get("X-Cito-Signature") ?? "";
if (got.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected))) {
return res.sendStatus(401);
}
const eventId = req.get("X-Cito-Event-Id");
if (seen.has(eventId)) return res.sendStatus(200);
seen.add(eventId);
res.sendStatus(200);
const payload = JSON.parse(req.body.toString("utf8"));
console.log(payload.event, payload.match_id, payload.data);
});
app.listen(3000);Live prediction-market odds payload
curl "https://api.citoapi.com/api/v1/tennis/odds/live?limit=3" \
-H "x-api-key: YOUR_API_KEY"{
"success": true,
"total": 251,
"items": [
{
"match_id": "m_2026_4891297",
"tour": "WTA",
"tournament": "WTA Finals, Final Stage",
"commence_time": "2026-11-15T20:10:00+00:00",
"home": {
"name": "Mirra Andreeva",
"player_id": "wta_259799",
"id": "wta_259799"
},
"away": {
"name": "Elina Svitolina",
"player_id": "wta_202494",
"id": "wta_202494"
},
"live": true,
"market_status": "open",
"liquidity_usd": 251462.12,
"volume_usd": 600112.4,
"price_timestamp": "2026-11-15T21:37:45.129000+00:00",
"h2h": {
"market_id": "mkt_7052659",
"player1_odds": 1.21,
"player2_odds": 5.71,
"player1_prob": 0.825,
"player2_prob": 0.175,
"open_player1_odds": 1.53,
"open_player2_odds": 2.9,
"best_bid": 0.82,
"best_ask": 0.83,
"spread": 0.01,
"status": "open"
},
"markets": ["h2h","set_handicap","set_winner","spreads","totals","set_totals"],
"market_count": 9
},
{
"match_id": "m_2026_4893994",
"tour": "ATP",
"tournament": "ATP World Tour Finals, John McEnroe Group",
"commence_time": "2026-11-15T19:35:00+00:00",
"home": {
"name": "Ben Shelton",
"player_id": "atp_210097",
"id": "atp_210097"
},
"away": {
"name": "Arthur Fils",
"player_id": "atp_209950",
"id": "atp_209950"
},
"live": true,
"market_status": "open",
"liquidity_usd": 214342.38,
"volume_usd": 308203.09,
"price_timestamp": "2026-11-15T21:37:45.135000+00:00",
"h2h": {
"market_id": "mkt_7001803",
"player1_odds": 1.02,
"player2_odds": 48.78,
"player1_prob": 0.9795,
"player2_prob": 0.0205,
"open_player1_odds": 1.18,
"open_player2_odds": 6.45,
"best_bid": 0.979,
"best_ask": 0.98,
"spread": 0.001,
"status": "open"
},
"markets": ["h2h","spreads","set_handicap","set_winner","totals","set_totals"],
"market_count": 8
}
]
}Signed tennis.set.completed webhook payload
curl "https://api.citoapi.com/api/v1/tennis/webhooks/events" \
-H "x-api-key: YOUR_API_KEY"{
"event": "tennis.set.completed",
"id": "0b8e9b52-5a8e-4f0e-9a43-3c2a7d0c1f11",
"timestamp": "2026-11-08T15:12:41.000Z",
"match_id": "m_2026_4891241",
"data": {
"id": "m_2026_4891241",
"tour": "ATP",
"tournament_name": "Paris",
"round_name": "Final",
"status": "IN_PROGRESS",
"current_set": 2,
"player1": {
"id": "atp_210097",
"name": "Ben Shelton"
},
"player2": {
"id": "atp_207989",
"name": "Carlos Alcaraz"
},
"set_number": 1,
"set_score": "6-7",
"set_winner_side": 2,
"set": {
"set_number": 1,
"score": "6-7",
"tiebreak": "5-7",
"is_completed": true
}
}
}SSE (/tennis/live/stream) works on every plan. Webhooks and live odds start on Pro ($59/mo); live WebSockets (points + tennis.odds.*) are included on Scale ($100/mo) and Business ($299/mo), or +$15/mo on Pro.
Plans for tennis
| Free | Starter | Pro | Scale | Business CSV | |
|---|---|---|---|---|---|
| Price | $0 | $15/mo | $59/mo | $100/mo | $299/mo (+$99/mo extra sport) |
| Credits / mo | 500/month | 10,000/month | 250,000/month | 1,000,000/month | 3,000,000/month |
| Rate limit | 10/min | 30/min | 100/min | 400/min | 600/min |
| Live scores | 60 s delayed | 60 s delayed | Real time | Real time | Real time |
| History | Last 30 days | Last 90 days | Full archive (1968-) | Full archive (1968-) | Full archive (1968-) + Master/Delta CSV |
| Deep-history (>90d) sub-cap | 0 | 0 | 50,000/mo (5x narrow / bulk) | 100,000/mo (5x narrow / bulk) | Unlimited in quota |
| Prediction-market odds | 3-day free trial | Upgrade to Pro | Pre-match, live & history | Pre-match, live & history | API + opening/closing CSV |
| Point-in-time Elo | 3-day free trial | Career & leaders | Full 1968- history | Full 1968- history | API + pre-match CSV |
| Webhooks | No | No | Yes | Yes | Yes |
| WebSockets | No | No | +$15/mo (points + odds) | Included | Included (points + odds) |
| Bulk CSV exports | Sample CSV | — | — | — | Master + Daily Delta CSV (0 REST credits) |
| Commercial use | No | 1 product | Yes | Yes | Yes |
Tennis on each plan, as the API enforces it (checked 15 Nov 2026). Paid API plans: 7-day money-back guarantee.
Frequently asked
Ready to go
live ?
Pro unlocks real-time scores, point-by-point, prediction-market odds, point-in-time Elo back to 1968, and webhooks for $59/mo with a 7-day money-back guarantee. Free includes a 3-day odds & Elo trial; Business ($299/mo) delivers full CSV datasets.
Compare every plan