-
Notifications
You must be signed in to change notification settings - Fork 0
Getting API Key
Complete guide to obtaining and configuring your API key from The Odds API for BetTrack.
- Why You Need An API Key
- Registration Process
- Free Tier Details
- Finding Your API Key
- Configuring BetTrack
- Rate Limiting
- Paid Tiers
- Best Practices
- Troubleshooting
The Odds API provides real-time sports betting data that powers BetTrack:
- Live betting odds from 10+ bookmakers (DraftKings, FanDuel, BetMGM, etc.)
- Real-time scores and game results
- Multiple markets (moneyline, spreads, totals, player props)
- Historical odds for line movement tracking
- 7 sports leagues (NFL, NBA, NHL, MLB, NCAAB, EPL, UEFA)
Required for:
- ✅ MCP Server (Claude Desktop integration)
- ✅ Dashboard (bet tracking web app)
Navigate to https://the-odds-api.com/
- Click "Sign Up" or "Get Started" in the top navigation
- Fill out registration form:
- Email address
- Password (8+ characters)
- Company/Organization (optional for free tier)
- Use case (select "Personal Project" or "Sports Analytics")
- Check your email inbox
- Click verification link from
noreply@the-odds-api.com - Complete email verification
- Log in at https://the-odds-api.com/account/
- You'll be redirected to your account dashboard
- API key will be displayed immediately
The Odds API offers a generous free tier:
- 500 requests per month
- Resets on the 1st of each month
- No credit card required
- ✅ All sports and leagues
- ✅ All betting markets (h2h, spreads, totals, props)
- ✅ Live scores and results
- ✅ Multiple bookmakers
- ✅ Historical odds (within request limit)
- ❌ 500 requests per month (not per day)
- ❌ No commercial use
- ❌ No webhook support
- ❌ Standard support only
Different endpoints consume requests differently:
| Endpoint | Requests Consumed |
|---|---|
| List sports | 1 request |
| Get odds (single sport) | 1 request |
| Get scores (single sport) | 1 request |
| Player props (single sport) | 1 request |
Example: Fetching odds for NBA games consumes 1 request, regardless of how many games are returned.
- Log in to https://the-odds-api.com/account/
- Your API key is displayed at the top of the page
- Look for a section labeled "Your API Key"
- Click "Copy" button or manually copy the key
Key Format: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (32 alphanumeric characters)
- Navigate to https://the-odds-api.com/liveapi/guides/v4/
- Your API key is automatically included in code examples
- Look for
apiKey=YOUR_KEYin example URLs
If you need to regenerate your API key:
- Go to account dashboard
- Click "Regenerate API Key"
- Confirm regeneration (old key will stop working immediately)
- Update BetTrack configuration with new key
Edit your Claude Desktop configuration file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"bettrack": {
"command": "python",
"args": ["C:/path/to/BetTrack/mcp/sports_mcp_server.py"],
"env": {
"ODDS_API_KEY": "your_32_character_api_key_here"
}
}
}
}Create .env file in BetTrack/mcp/ directory:
ODDS_API_KEY=your_32_character_api_key_here
BOOKMAKERS_FILTER=draftkings,fanduel,betmgm
BOOKMAKERS_LIMIT=5Edit .env file in dashboard/backend/ directory:
# Required
DATABASE_URL=postgresql://user:password@localhost:5432/bettrack
ODDS_API_KEY=your_32_character_api_key_here
# Optional
SESSION_SECRET=generate_random_string_here
PORT=3001
NODE_ENV=development
CORS_ORIGIN=http://localhost:5173MCP Server:
cd mcp
python sports_mcp_server.py
# Should see "MCP Server initialized successfully"Dashboard Backend:
cd dashboard/backend
npm run dev
# Should see "Server running on port 3001"
# Check logs for "Odds API connected successfully"The Odds API includes usage information in response headers:
x-requests-remaining: 487
x-requests-used: 13
BetTrack automatically logs remaining requests:
[INFO] Odds API request completed. Remaining: 487/500
The dashboard runs automated odds syncing:
- Frequency: Every 5 minutes
- Consumption: 7 requests per sync (one per sport)
- Daily usage: ~2,000 requests per day
- Monthly usage: ~60,000 requests per month
To disable automatic odds syncing:
Option 1: Comment out cron job in dashboard/backend/src/jobs/odds-sync.job.ts:
// cron.schedule('*/5 * * * *', async () => {
// await oddsSyncService.syncOdds();
// });Option 2: Use manual sync only via admin API:
curl -X POST http://localhost:3001/api/admin/sync-oddsThe MCP server makes requests only when Claude asks for data:
- No automatic syncing
- On-demand requests only
- Typical usage: 10-50 requests per day
- Monthly usage: 300-1,500 requests per month
✅ Free tier is sufficient for MCP server usage
If you exceed free tier limits, The Odds API offers paid plans:
- $25/month
- 10,000 requests per month
- All sports and markets
- Email support
- $75/month
- 50,000 requests per month
- Priority support
- Webhook notifications
- Commercial use allowed
- Custom pricing
- Unlimited requests
- Dedicated support
- SLA guarantees
- Custom integrations
- Log in to https://the-odds-api.com/account/
- Click "Upgrade Plan"
- Select desired tier
- Enter payment information
- API key remains the same (no configuration changes needed)
DO:
- ✅ Store in
.envfile (never commit to git) - ✅ Use environment variables
- ✅ Add
.envto.gitignore - ✅ Use different keys for dev/prod
DON'T:
- ❌ Hardcode in source code
- ❌ Commit to version control
- ❌ Share publicly in screenshots
- ❌ Use same key across multiple projects
Filter Sports:
# Only fetch odds for sports you care about
BOOKMAKERS_FILTER=draftkings,fanduel
BOOKMAKERS_LIMIT=3Cache Results:
- MCP server caches results for 5 minutes
- Dashboard stores odds in database
- Avoid redundant API calls
Batch Requests:
- Fetch all games for a sport in single request
- Use
regionsparameter to limit bookmakers
Check remaining requests:
# Dashboard backend logs
[INFO] Odds API usage: 487/500 requests remaining
# MCP server logs
[DEBUG] x-requests-remaining: 487Set up alerts:
- Monitor logs for low quota warnings
- Disable auto-sync if approaching limit
- Upgrade plan before running out
BetTrack includes built-in error handling:
try {
const odds = await fetchOdds();
} catch (error) {
if (error.status === 429) {
// Rate limit exceeded - wait and retry
console.error('Rate limit exceeded. Requests remaining: 0');
}
}Error: 401 Unauthorized or Invalid API key
Solutions:
- Verify key copied correctly (32 characters, no spaces)
- Check
.envfile syntax:ODDS_API_KEY=key(no quotes) - Restart MCP server or backend after changing
.env - Regenerate key on The Odds API dashboard
Error: 429 Too Many Requests or Monthly quota exceeded
Solutions:
- Check usage:
x-requests-remainingheader - Wait until next month for quota reset
- Disable dashboard auto-sync
- Upgrade to paid tier
Error: Empty results or No games found
Solutions:
- Verify API key is active (not expired trial)
- Check if sport is in season (NFL, NBA, NHL have off-seasons)
- Verify bookmakers are available for your region
- Test with The Odds API documentation examples
Error: ETIMEDOUT or Request timeout
Solutions:
- Check internet connection
- Verify firewall allows HTTPS connections
- Test API endpoint directly:
curl https://api.the-odds-api.com/v4/sports - Check The Odds API status page for outages
Error: ODDS_API_KEY is required
Solutions:
- Verify
.envfile exists in correct directory - Check file permissions (must be readable)
- Restart application after editing
.env - Use absolute path in Claude Desktop config instead
# Replace YOUR_API_KEY with your actual key
curl "https://api.the-odds-api.com/v4/sports?apiKey=YOUR_API_KEY"
# Expected output:
[
{
"key": "basketball_nba",
"group": "Basketball",
"title": "NBA",
"description": "US Basketball",
"active": true
},
...
]cd mcp
python sports_mcp_server.py
# In Claude Desktop, ask:
"Show me NBA games today"
# Should return formatted game list with odds# Start backend
cd dashboard/backend
npm run dev
# Initialize sports
curl -X POST http://localhost:3001/api/admin/init-sports
# Sync odds (manual)
curl -X POST http://localhost:3001/api/admin/sync-odds
# Check stats
curl http://localhost:3001/api/admin/stats- API Documentation: https://the-odds-api.com/liveapi/guides/v4/
- API Explorer: https://the-odds-api.com/sports-odds-data/api-explorer.html
- FAQ: https://the-odds-api.com/faq
- Quick Start Guide - Complete setup walkthrough
- MCP Server Guide - MCP configuration details
- Dashboard Guide - Backend API setup
- The Odds API Support: support@the-odds-api.com
- BetTrack Issues: GitHub Issues
- Create account at https://the-odds-api.com/
- Verify email address
- Copy API key from dashboard
- Add key to MCP
.envor Claude config - Add key to Dashboard backend
.env - Test MCP server: "Show me NBA games"
- Test dashboard: Initialize sports + sync odds
- Monitor usage with
x-requests-remainingheader - Disable dashboard auto-sync if using free tier
- Secure API key (never commit to git)
Status: Production Ready ✅
Last Updated: January 13, 2026