Official Node.js SDK for Odds-API.io - Real-time sports betting odds from 250+ bookmakers.
- π 20+ Sports - Basketball, football, tennis, and more
- π Comprehensive Odds Data - Real-time odds from 250+ bookmakers
- π° Arbitrage Detection - Find risk-free betting opportunities
- π Value Bets - Identify positive expected value bets
- π΄ Live Events - Track in-play events and odds
- π Advanced Search - Search events, participants, and leagues
- β‘ TypeScript First - Full type safety with TypeScript
- π¦ Dual Package - Works with both ESM and CommonJS
- π‘οΈ Error Handling - Custom error classes for better debugging
npm install odds-api-ioVisit odds-api.io/#pricing to get your API key.
import { OddsAPIClient } from 'odds-api-io';
const client = new OddsAPIClient({
apiKey: 'your-api-key-here'
});
// Get all available sports
const sports = await client.getSports();
console.log(`Found ${sports.length} sports`);
// Get upcoming NBA events
const events = await client.getEvents({
sport: 'basketball',
league: 'usa-nba'
});
// Search for specific games
const lakersGames = await client.searchEvents('Lakers');
// Get live events
const liveEvents = await client.getLiveEvents('basketball');const { OddsAPIClient } = require('odds-api-io');
const client = new OddsAPIClient({
apiKey: 'your-api-key-here'
});
async function getOdds() {
const events = await client.getEvents({
sport: 'basketball',
league: 'usa-nba'
});
const odds = await client.getEventOdds({
eventId: events[0].id,
bookmakers: 'pinnacle,bet365'
});
console.log(odds);
}
getOdds();import { OddsAPIClient } from 'odds-api-io';
const client = new OddsAPIClient({
apiKey: 'your-api-key-here'
});
const sports = await client.getSports();import { OddsAPIClient } from 'odds-api-io';
const client = new OddsAPIClient({ apiKey: 'your-api-key' });
const arbs = await client.getArbitrageBets({
bookmakers: 'pinnacle,bet365',
limit: 10,
includeEventDetails: true
});
arbs.forEach(arb => {
console.log(`Profit: ${arb.profitPercentage}%`);
console.log('Legs:', arb.legs);
});// Get odds for a specific event
const odds = await client.getEventOdds({
eventId: '62924717',
bookmakers: 'pinnacle,bet365'
});
// Track how odds change over time
const movements = await client.getOddsMovement({
eventId: '62924717',
bookmaker: 'pinnacle',
market: 'moneyline'
});// Find value betting opportunities
const valueBets = await client.getValueBets({
bookmaker: 'pinnacle',
includeEventDetails: true
});
valueBets.forEach(bet => {
console.log(`Value: ${bet.valuePercentage}%`);
console.log(`Odds: ${bet.odds} (Fair: ${bet.fairOdds})`);
});// Search for teams/players
const warriors = await client.getParticipants({
sport: 'basketball',
search: 'Warriors'
});
// Get participant details by ID
const participant = await client.getParticipantById(3428);// Get all available bookmakers
const bookmakers = await client.getBookmakers();
// Select specific bookmakers for your account
await client.selectBookmakers('pinnacle,bet365');
// Check which bookmakers you've selected
const selected = await client.getSelectedBookmakers();
// Clear selected bookmakers
await client.clearSelectedBookmakers();| Method | Description | Docs |
|---|---|---|
getSports() |
Get all available sports | Docs |
getLeagues(sport) |
Get leagues for a sport | Docs |
| Method | Description | Docs |
|---|---|---|
getEvents(params) |
Get events with filters | Docs |
getEventById(eventId) |
Get specific event details | Docs |
getLiveEvents(sport) |
Get currently live events | Docs |
searchEvents(query) |
Search for events by keyword | Docs |
| Method | Description | Docs |
|---|---|---|
getEventOdds(params) |
Get odds for an event | Docs |
getOddsMovement(params) |
Track odds changes | Docs |
getOddsForMultipleEvents(params) |
Get odds for multiple events | Docs |
getUpdatedOddsSince(params) |
Get odds updated since timestamp | Docs |
| Method | Description | Docs |
|---|---|---|
getParticipants(params) |
Get participants/teams | Docs |
getParticipantById(id) |
Get participant by ID | Docs |
| Method | Description | Docs |
|---|---|---|
getBookmakers() |
Get all available bookmakers | Docs |
getSelectedBookmakers() |
Get your selected bookmakers | Docs |
selectBookmakers(bookmakers) |
Select bookmakers for your account | Docs |
clearSelectedBookmakers() |
Clear bookmaker selection | Docs |
| Method | Description | Docs |
|---|---|---|
getArbitrageBets(params) |
Find arbitrage opportunities | Docs |
getValueBets(params) |
Find value bets | Docs |
The SDK includes custom error classes for better error handling:
import {
OddsAPIClient,
OddsAPIError,
InvalidAPIKeyError,
RateLimitExceededError,
NotFoundError,
TimeoutError,
NetworkError
} from 'odds-api-io';
const client = new OddsAPIClient({ apiKey: 'your-api-key' });
try {
const events = await client.getEvents({ sport: 'basketball' });
} catch (error) {
if (error instanceof InvalidAPIKeyError) {
console.error('Your API key is invalid');
} else if (error instanceof RateLimitExceededError) {
console.error('Rate limit exceeded - wait before retrying');
} else if (error instanceof NotFoundError) {
console.error('Resource not found');
} else if (error instanceof TimeoutError) {
console.error('Request timeout');
} else if (error instanceof NetworkError) {
console.error('Network error');
} else if (error instanceof OddsAPIError) {
console.error('API error:', error.message);
}
}const client = new OddsAPIClient({
apiKey: 'your-api-key',
baseUrl: 'https://api2.odds-api.io/v3', // Optional, default shown
timeout: 10000 // Optional, default 10 seconds
});This SDK is written in TypeScript and includes complete type definitions:
import type {
Sport,
League,
Event,
Participant,
Bookmaker,
EventOdds,
ArbitrageBet,
ValueBet,
GetEventsParams
} from 'odds-api-io';The free API tier has some restrictions:
- Limited bookmakers - Only 2 bookmakers can be selected at once
- Rate limits - Check the API documentation for current limits
- No WebSocket - Free tier uses HTTP requests only
Upgrade your plan for full access.
- π API Documentation
- π Odds-API.io Website
- π³ Get Your API Key
- π Report Issues
Check the examples/ directory for more comprehensive examples:
basic-usage.ts/basic-usage.js- Getting startedarbitrage-betting.ts- Finding arbitrage opportunitiesodds-tracking.ts- Monitoring odds movements
MIT Β© Odds-API.io
This is the official SDK for Odds-API.io. This tool is for informational purposes only and should not be used as the sole basis for betting decisions.
Built with β€οΈ for the sports betting and analytics community