Odds API WebSocket (Early Access)
The WebSocket feed delivers the exact same response format as the/odds
endpoint, but in real time. Instead of polling, you receive updates instantly whenever odds change.
We recommend all clients move to WebSocket for efficiency and lower latency. It reduces request overhead, scales better, and gives you immediate updates for live markets.
Why Use WebSocket?
Real-Time Updates
Receive odds changes instantly without polling
Lower Latency
Sub-150ms updates for live markets
Reduced Overhead
Single persistent connection vs repeated HTTP calls
Better Scaling
Perfect for bots, live dashboards, and in-play betting apps
Access & Pricing
Early Access: The WebSocket is currently in early access. To enable it, contact us at hello@odds-api.io.
- 2x the REST API price
- One-time implementation fee
Connection Details
Endpoint:- API key passed as query parameter
- One connection per API key
- New connections automatically close older ones
- Automatic cleanup keeps your feed stable
Update Types
Messages come in as JSON objects. Each has atype
field:
Type | Description |
---|---|
created | New match added |
updated | Match or market changed |
deleted | Match removed |
no_markets | Match exists but currently no markets available |
Message Format
Quick Start
JavaScript Example
Python Example
PHP Example
Handling Different Update Types
Advanced Implementation: Live Odds Tracker
React Integration
Best Practices
Implement Reconnection Logic
Implement Reconnection Logic
Always implement exponential backoff for reconnections to handle network issues gracefully. The connection is stable, but networks can drop.
Handle All Message Types
Handle All Message Types
Don’t just listen for
updated
- also handle created
, deleted
, and no_markets
to keep your data in sync.Store Match State Locally
Store Match State Locally
Keep track of match data in memory or database to compare updates and detect significant changes.
One Connection Per API Key
One Connection Per API Key
Remember that new connections automatically close older ones. Don’t create multiple connections with the same API key.
Process Updates Asynchronously
Process Updates Asynchronously
If receiving many updates, process them asynchronously to avoid blocking your main thread.
Benefits Over REST API
Feature | REST API | WebSocket |
---|---|---|
Latency | 100-500ms (polling) | <150ms (push) |
Request overhead | Multiple HTTP requests | Single persistent connection |
Real-time updates | Manual polling | Automatic push |
Bandwidth | Higher (repeated headers) | Lower (single connection) |
Server load | Higher | Lower |
Best for | Batch requests | Live updates |
Get Access
Request WebSocket Access
Contact us at hello@odds-api.io to enable WebSocket access for your account