Sports WebSocket API
A WebSocket stream of score changes, live/status/final transitions, plays and odds changes. Exchange your API key for a one-hour token, connect, and subscribe with optional sport and league filters. Data is aggregated from public sources and is typically 20-30 seconds behind live play (about 1 second after our source). There is no SLA.
- Each delivered message counts toward your monthly quota.
- The server pings every 2 minutes to keep connections open behind proxies.
Paths and parameters
POSThttps://www.realtimesportsapi.com/api/websocket/auth
Get a WebSocket token. Returns the WebSocket URL and a token valid for one hour. Connect to `${url}?token=${token}`, then send `{"type":"subscribe","event":"event_score_change","filters":{"sport":"football","league":"nfl"}}`. Event types: event_score_change, event_live, event_status_change, event_play, event_final, event_odds_change. Each delivered message counts toward your quota.
Connect and subscribe
JavaScript
const auth = await fetch("https://www.realtimesportsapi.com/api/websocket/auth", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.RSA_API_KEY}` }
});
const { data } = await auth.json(); // { url, token, expiresIn: 3600 }
const ws = new WebSocket(`${data.url}?token=${data.token}`);
ws.onopen = () => ws.send(JSON.stringify({
type: "subscribe",
event: "event_score_change",
filters: { sport: "football", league: "nfl" }
}));
ws.onmessage = (msg) => console.log(JSON.parse(msg.data));Python
import os, json, requests, websocket # pip install websocket-client
auth = requests.post(
"https://www.realtimesportsapi.com/api/websocket/auth",
headers={"Authorization": f"Bearer {os.environ['RSA_API_KEY']}"},
timeout=10,
).json()["data"]
ws = websocket.create_connection(f"{auth['url']}?token={auth['token']}")
ws.send(json.dumps({"type": "subscribe", "event": "event_score_change",
"filters": {"sport": "soccer", "league": "eng.1"}}))
while True:
print(json.loads(ws.recv()))Message types: event_score_change, event_live, event_status_change, event_play, event_final, event_odds_change. Filter by sport and league in the subscribe message.
League support
All 29 monitored leagues: NFL, College Football, NBA, Men's College Basketball, MLB, NHL, MLS, U.S. Open Cup, Premier League, Champions League, Europa League, FA Cup, LaLiga, Serie A, Liga MX, FIFA World Cup, Women's Super League, Women's Champions League, Conference League, English League Cup, Bundesliga, Ligue 1, NWSL, EFL Championship, World Cup Qualifying (UEFA), World Cup Qualifying (CONMEBOL), World Cup Qualifying (AFC), World Cup Qualifying (CAF), World Cup Qualifying (CONCACAF). 29 leagues monitored live: NFL, college football, NBA, men's college basketball, MLB, NHL and 23 soccer competitions.
Rate limits and pricing
Webhooks are included on every paid plan (Starter, Growth, Pro, Scale). WebSocket is included on paid plans, and the Free plan gets a 500-message monthly preview.
| Plan | Price | Calls | Rate | WebSocket | Webhooks |
|---|---|---|---|---|---|
| Free | $0 | 125/mo (1,000 first 30 days) | 1/s | 500 msgs/mo | No |
| Starter | $29/mo ($290/yr) | 10,000/mo | 5/s | Shares monthly pool | Shares monthly pool |
| Growth | $49/mo ($490/yr) | 25,000/mo | 10/s | Shares monthly pool | Shares monthly pool |
| Pro | $99/mo ($990/yr) | 50,000/mo | 20/s | 100,000 msgs/mo | 25,000/mo |
| Scale | $299/mo ($2,990/yr) | 500,000/mo | 100/s | 500,000 msgs/mo | 100,000/mo |
Every successful REST call counts as one call. Over the limit you get HTTP 429 with a Retry-After header. No SLA. Full pricing.
FAQ
- What does the websocket endpoint return?
- A WebSocket stream of score changes, live/status/final transitions, plays and odds changes. Exchange your API key for a one-hour token, connect, and subscribe with optional sport and league filters.
- Which plans include WebSocket?
- Webhooks are included on every paid plan (Starter, Growth, Pro, Scale). WebSocket is included on paid plans, and the Free plan gets a 500-message monthly preview.
- Which message types are sent?
- event_score_change, event_live, event_status_change, event_play, event_final and event_odds_change. Odds changes only occur for leagues and games that have odds.
- How long is a token valid?
- POST /api/websocket/auth with your API key returns the WebSocket URL and a token valid for one hour. Request a new token to reconnect after it expires.
- How fresh are the messages?
- Data is aggregated from public sources and is typically 20-30 seconds behind live play (about 1 second after our source). There is no SLA.