Authentication
All Odds On API requests require authentication using an API key. This guide covers everything you need to know about obtaining and using your API keys.
Getting an API Key
- Sign Up: Create an account at app.oddson.com
- Navigate to API Keys: Go to Settings → API Keys
- Generate Key: Click "Generate New API Key"
- Name Your Key: Give it a descriptive name (e.g., "Production App", "Development")
- Copy & Save: Save your key immediately - it won't be shown again!
Using Your API Key
Include your API key in the X-API-Key header with every request:
curl -H "X-API-Key: oddson_live_abc123..." \
https://api.oddson.com/v1/rankings?week=5
JavaScript Example
const apiKey = 'oddson_live_abc123...';
const response = await fetch('https://api.oddson.com/v1/rankings?week=5', {
headers: {
'X-API-Key': apiKey
}
});
const data = await response.json();
console.log(data);
Python Example
import requests
api_key = 'oddson_live_abc123...'
response = requests.get(
'https://api.oddson.com/v1/rankings',
params={'week': 5},
headers={'X-API-Key': api_key}
)
data = response.json()
print(data)
Rate Limits
Each API tier has different rate limits:
| Tier | Limit | Response Header |
|---|---|---|
| Free | 100 requests/hour | X-RateLimit-Limit: 100 |
| Pro | 1,000 requests/hour | X-RateLimit-Limit: 1000 |
| Enterprise | 10,000 requests/hour | X-RateLimit-Limit: 10000 |
Rate Limit Headers
Every API response includes rate limit information:
HTTP/1.1 200 OK
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1696723200000
- X-RateLimit-Limit: Total requests allowed per hour
- X-RateLimit-Remaining: Requests remaining in current window
- X-RateLimit-Reset: Unix timestamp (ms) when limit resets
Handling Rate Limits
When you exceed your rate limit, you'll receive a 429 Too Many Requests response:
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. You can make 100 requests per hour. Try again after 2024-10-07T15:00:00Z."
}
}
Best Practices:
- Monitor
X-RateLimit-Remainingheader - Implement exponential backoff on 429 errors
- Cache responses when possible
- Upgrade to Pro tier for higher limits
Security Best Practices
✅ Do
- Store keys securely - Use environment variables or secret managers
- Use HTTPS only - Never send keys over HTTP
- Rotate keys regularly - Generate new keys every 90 days
- Use separate keys - Different keys for dev, staging, production
- Monitor usage - Watch for unexpected API activity
❌ Don't
- Commit keys to Git - Add
*.envto.gitignore - Share keys publicly - Never expose in client-side code
- Reuse keys across apps - Use unique keys per application
- Ignore rate limits - Implement proper error handling
Managing API Keys
Viewing Your Keys
See all your API keys in the dashboard:
- Key name and creation date
- Usage statistics (requests today/month)
- Last used timestamp
- Active/inactive status
Revoking Keys
If a key is compromised:
- Go to Settings → API Keys
- Click "Revoke" next to the compromised key
- Generate a new key immediately
- Update your application with the new key
Note: Revoking a key is immediate and irreversible. All requests using that key will fail.
Troubleshooting
401 Unauthorized
Cause: Missing or invalid API key
{
"success": false,
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid or expired API key."
}
}
Solutions:
- Check that
X-API-Keyheader is present - Verify key hasn't been revoked
- Ensure no extra spaces or characters
429 Rate Limit Exceeded
Cause: Too many requests in the current hour
Solutions:
- Wait until the reset time (see
X-RateLimit-Resetheader) - Implement caching to reduce requests
- Upgrade to a higher tier
Need Help?
- Email: [email protected]
- Discord: discord.gg/oddson
- Status Page: status.oddson.com