Skip to main content

Overview

The WebSocket feed delivers real-time odds updates with the same response format as the REST API /odds endpoint. Instead of polling, you receive instant updates whenever odds change.
Early Access: The WebSocket is currently in early access. To enable it, contact us at hello@odds-api.io.

Connection

Endpoint:
wss://api.odds-api.io/v3/ws?apiKey=YOUR_API_KEY
Authentication:
  • API key passed as query parameter
  • One connection per API key
  • New connections automatically close older ones
Pricing:
  • 2x the REST API price
  • One-time implementation fee

Message Types

TypeDescription
createdNew match added
updatedMatch or market changed
deletedMatch removed
no_marketsMatch exists but currently no markets available

Message Format

{
  "type": "updated",
  "timestamp": "2025-08-18T14:52:52.983Z",
  "id": "63017989",
  "bookie": "Pinnacle",
  "markets": [
    {
      "name": "ML",
      "updatedAt": "2024-01-15T10:30:00Z",
      "odds": [
        {
          "home": "1.85",
          "draw": "3.25",
          "away": "2.10",
          "max": 500
        }
      ]
    },
    {
      "name": "Totals",
      "updatedAt": "2024-01-15T10:30:00Z",
      "odds": [
        {
          "hdp": 2.5,
          "over": "1.85",
          "under": "2.10",
          "max": 500
        }
      ]
    }
  ]
}

Quick Start

const WebSocket = require('ws');

const apiKey = process.env.ODDS_API_KEY;
const ws = new WebSocket(`wss://api.odds-api.io/v3/ws?apiKey=${apiKey}`);

ws.onopen = () => {
  console.log("Connected to Odds-API WebSocket");
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);

  console.log(`Type: ${data.type}`);
  console.log(`Match ID: ${data.id}`);
  console.log(`Bookmaker: ${data.bookie}`);
  console.log(`Markets: ${data.markets.length}`);
};

ws.onerror = (err) => {
  console.error("WebSocket error:", err);
};

ws.onclose = () => {
  console.log("Disconnected from WebSocket");
};

Handling Message Types

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);

  switch (data.type) {
    case 'created':
      console.log(`New match: ${data.id} at ${data.bookie}`);
      // Add match to your database/UI
      break;

    case 'updated':
      console.log(`Match updated: ${data.id} at ${data.bookie}`);
      // Update existing match odds
      break;

    case 'deleted':
      console.log(`Match deleted: ${data.id} at ${data.bookie}`);
      // Remove match from your database/UI
      break;

    case 'no_markets':
      console.log(`No markets available for match: ${data.id}`);
      // Handle temporarily unavailable markets
      break;
  }
};

Best Practices

Always implement exponential backoff for reconnections to handle network issues gracefully.
Don’t just listen for updated - also handle created, deleted, and no_markets to keep your data in sync.
Remember that new connections automatically close older ones. Don’t create multiple connections with the same API key.
If receiving many updates, process them asynchronously to avoid blocking your main thread.

Benefits Over REST API

FeatureREST APIWebSocket
Latency100-500ms (polling)<150ms (push)
Request overheadMultiple HTTP requestsSingle persistent connection
Real-time updatesManual pollingAutomatic push
BandwidthHigher (repeated headers)Lower (single connection)
Best forBatch requestsLive updates

Get Access

Request WebSocket Access

Contact us at hello@odds-api.io to enable WebSocket access for your account
I