Skip to main content

Overview

The V1 WebSocket provides real-time score updates with adaptive polling: 1-second intervals when live games exist, 2-second when no live games. This delivers the fastest possible score updates.

Connection

wss://v1.{sport}.sportsapipro.com/ws?x-api-key=YOUR_API_KEY
Replace {sport} with any supported sport slug (e.g., football, tennis, baseball).
The WebSocket connection requires authentication via the x-api-key query parameter.

Welcome Message

On successful connection, you receive:
{
  "type": "connected",
  "version": "1.0",
  "sports": [
    { "id": 1, "name": "Football", "slug": "football" },
    { "id": 2, "name": "Basketball", "slug": "basketball" },
    { "id": 3, "name": "Tennis", "slug": "tennis" },
    { "id": 4, "name": "Hockey", "slug": "hockey" },
    { "id": 5, "name": "Handball", "slug": "handball" },
    { "id": 6, "name": "American Football", "slug": "american-football" },
    { "id": 7, "name": "Baseball", "slug": "baseball" },
    { "id": 8, "name": "Volleyball", "slug": "volleyball" },
    { "id": 9, "name": "Rugby", "slug": "rugby" }
  ],
  "channels": ["all", "live", "football", "basketball", "tennis", "hockey", "handball", "american-football", "baseball", "volleyball", "rugby"]
}

Client Messages

Subscribe

{ "type": "subscribe", "channel": "football" }
{ "type": "subscribe", "channel": "live" }
{ "type": "subscribe", "channel": "match:4467358" }

Unsubscribe

{ "type": "unsubscribe", "channel": "football" }

Ping / Pong

{ "type": "ping" }
Response:
{ "type": "pong", "ts": 1712345678000 }

Server Messages

Sport Channel Updates

{
  "type": "scores",
  "channel": "football",
  "games": [{ ... }],
  "updateId": 5612062220,
  "ts": 1712345678000
}

Live Channel (All Sports)

{
  "type": "scores",
  "channel": "live",
  "games": [{ ... }],
  "updateId": 5612062220,
  "ts": 1712345678000
}

Match-Specific Updates

{
  "type": "match-update",
  "channel": "match:4467358",
  "game": { ... },
  "updateId": 5612062220,
  "ts": 1712345678000
}

Available Channels

ChannelDescription
allAll updates across all sports (default on connect)
liveOnly live games across all 9 sports
footballFootball updates only
basketballBasketball updates only
tennisTennis updates only
hockeyHockey updates only
handballHandball updates only
american-footballAmerican Football updates only
baseballBaseball updates only
volleyballVolleyball updates only
rugbyRugby updates only
match:{gameId}Single game updates

Code Examples

const ws = new WebSocket('wss://v1.football.sportsapipro.com/ws?x-api-key=YOUR_API_KEY');

ws.onopen = () => {
  console.log('Connected to V1 WebSocket');
  ws.send(JSON.stringify({ type: 'subscribe', channel: 'live' }));
};

ws.onmessage = (event) => {
  const msg = JSON.parse(event.data);
  
  if (msg.type === 'connected') {
    console.log(`Connected — ${msg.sports.length} sports available`);
  }
  
  if (msg.type === 'scores') {
    console.log(`${msg.channel}: ${msg.games.length} games updated`);
    msg.games.forEach(game => {
      console.log(`${game.homeCompetitor.name} ${game.homeCompetitor.score} - ${game.awayCompetitor.score} ${game.awayCompetitor.name}`);
    });
  }
  
  if (msg.type === 'match-update') {
    const g = msg.game;
    console.log(`Match update: ${g.homeCompetitor.name} ${g.homeCompetitor.score} - ${g.awayCompetitor.score} ${g.awayCompetitor.name}`);
  }
};

ws.onclose = () => console.log('Disconnected');

Update Frequency

ConditionPolling Interval
Live games in progress1 second
No live games2 seconds
The V1 WebSocket uses adaptive polling to minimize latency during live games while reducing server load during quiet periods.