Make your first API call
Get up and running with Odds-API.io and fetch your first odds data.
Step 1: Get your API key
Check your email
Your API key will be sent to the email address you provided during signup.
Copy your API key
Copy the API key from the email and keep it secure!
Never share your API key publicly or commit it to version control. Use environment variables to store it securely.
Step 2: Fetch available sports
Let’s start by fetching the list of available sports.
The /sports endpoint doesn’t require authentication - you can try it before getting your API key!
curl "https://api.odds-api.io/v3/sports"
Example Response:
[
{
"name": "Football",
"slug": "football"
},
{
"name": "Basketball",
"slug": "basketball"
},
{
"name": "Tennis",
"slug": "tennis"
}
]
Step 3: Fetch events for a sport
Now let’s get upcoming football events:
curl "https://api.odds-api.io/v3/events?apiKey=YOUR_API_KEY&sport=football&limit=10"
Example Response:
[
{
"id": 123456,
"sport": {
"name": "Football",
"slug": "football"
},
"league": {
"name": "Premier League",
"slug": "england-premier-league"
},
"home": "Manchester United",
"away": "Liverpool",
"date": "2025-10-15T15:00:00Z",
"status": "pending"
}
]
Step 4: Get odds for an event
Finally, let’s fetch odds from multiple bookmakers for a specific event:
curl "https://api.odds-api.io/v3/odds?apiKey=YOUR_API_KEY&eventId=123456&bookmakers=Bet365,Unibet,Pinnacle"
Example Response:
{
"id": 123456,
"home": "Manchester United",
"away": "Liverpool",
"date": "2025-10-15T15:00:00Z",
"status": "pending",
"urls": {
"Bet365": "https://www.bet365.com/...",
"Unibet": "https://www.unibet.com/...",
"Pinnacle": "https://www.unibet.com/..."
},
"bookmakers": {
"Bet365": [
{
"name": "ML",
"odds": [
{
"home": "2.10",
"draw": "3.40",
"away": "3.20"
}
],
"updatedAt": "2025-10-04T10:30:00Z"
}
],
"Unibet": [
{
"name": "ML",
"odds": [
{
"home": "2.15",
"draw": "3.35",
"away": "3.15"
}
],
"updatedAt": "2025-10-04T10:29:45Z"
}
],
"Pinnacle": [
{
"name": "ML",
"odds": [
{
"home": "2.00",
"draw": "3.25",
"away": "3.25"
}
],
"updatedAt": "2025-10-04T10:29:42Z"
}
]
}
}
Common Use Cases
Here are quick snippets for common scenarios:
Find Best Odds for a Match
// Compare odds across bookmakers
const bestOdds = {};
Object.entries(odds.bookmakers).forEach(([bookmaker, markets]) => {
const ml = markets.find(m => m.name === 'ML')?.odds[0];
if (ml) {
if (!bestOdds.home || parseFloat(ml.home) > parseFloat(bestOdds.home.odds)) {
bestOdds.home = { bookmaker, odds: ml.home };
}
}
});
console.log(`Best home odds: ${bestOdds.home.odds} at ${bestOdds.home.bookmaker}`);
Filter Events by League
const apiKey = process.env.ODDS_API_KEY;
// Get Premier League matches only
const response = await fetch(
`https://api.odds-api.io/v3/events?apiKey=${apiKey}&sport=football&league=england-premier-league`
);
const matches = await response.json();
console.log(`Found ${matches.length} Premier League matches`);
Get Live Events
const apiKey = process.env.ODDS_API_KEY;
// Fetch events that are currently in play
const response = await fetch(
`https://api.odds-api.io/v3/events?apiKey=${apiKey}&sport=football&status=live`
);
const liveMatches = await response.json();
console.log(`${liveMatches.length} matches currently live`);
Error Handling
Always handle errors gracefully in production:
async function fetchOdds(eventId) {
const apiKey = process.env.ODDS_API_KEY;
try {
const response = await fetch(
`https://api.odds-api.io/v3/odds?apiKey=${apiKey}&eventId=${eventId}&bookmakers=Bet365`
);
if (!response.ok) {
if (response.status === 401) {
throw new Error('Invalid API key');
}
if (response.status === 429) {
throw new Error('Rate limit exceeded - please wait before retrying');
}
if (response.status === 404) {
throw new Error(`Event ${eventId} not found`);
}
throw new Error(`API error: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error('Failed to fetch odds:', error.message);
throw error;
}
}
Next steps
Now that you’ve made your first API calls, explore these guides: