Step 1: Fetch the Sports List
Start by loading the list of available sports. This endpoint is public and does not require authentication.| Sport | ID |
|---|---|
| NFL | 2 |
| MLB | 3 |
| NBA | 4 |
| NCAAB | 5 |
| NHL | 6 |
Step 2: Fetch Events for a Sport and Date
Once the user selects a sport, fetch events for that sport on a given date. Includemarket_ids=1,2,3 for moneyline, spread, and total. Use main_line=true to get only the primary line for each market.
Step 3: Parse Markets for Display
Each event contains amarkets array. To build an odds screen, you need to extract moneyline, spread, and total data and organize it by team and sportsbook.
Step 4: Connect WebSocket for Real-Time Updates
Once your initial data is loaded, connect the V2 Markets WebSocket to receive live price updates. Filter by sport to reduce traffic.Step 5: Handle Price Updates in the UI
When a WebSocket message arrives, merge the update into your local state. A common pattern is to maintain a map of events keyed byevent_id, then update the specific market/participant/line that changed.
Tips for Production
Use delta endpoints for efficient polling as a fallback
Use delta endpoints for efficient polling as a fallback
If the WebSocket disconnects, use
GET /api/v2/sports/{sportID}/events/delta to fetch only events that have changed since your last request. This is much more efficient than refetching the full event list.Animate price changes
Animate price changes
When a price moves, briefly highlight the cell green (price improved for the bettor) or red (price worsened). This visual cue helps users notice live movement.
Handle the 0.0001 sentinel value
Handle the 0.0001 sentinel value
Always check for
0.0001 before displaying a price. Show “Off Board” or “N/A” instead. See Sentinel Values for details.Cache the sports and affiliates lists
Cache the sports and affiliates lists
The sports and affiliates endpoints return reference data that rarely changes. Cache these responses and refresh once per day to avoid unnecessary API calls.
Filter aggressively
Filter aggressively
Use
affiliate_ids, market_ids, and main_line=true to reduce payload size. Only request the data your UI actually displays.