This directory contains example scripts demonstrating how to use the Odds-API.io Python SDK.
Before running the examples, make sure you have:
-
Installed the SDK:
pip install odds-api-io
-
Obtained an API key from odds-api.io
-
Set your API key as an environment variable:
export ODDS_API_KEY="your_api_key_here"
Or modify the examples to use your API key directly.
Learn the fundamentals of the SDK:
- Initializing the client
- Getting sports and leagues
- Fetching events
- Searching for games
- Working with bookmakers
python basic_usage.pyUse the async client for concurrent operations:
- Async/await syntax
- Concurrent requests with
asyncio.gather - Async context managers
python async_example.pyFind arbitrage betting opportunities:
- Discovering risk-free betting opportunities
- Comparing odds across bookmakers
- Calculating potential profits
python arbitrage_finder.pyIdentify value betting opportunities:
- Finding positive expected value bets
- Understanding implied vs true probability
- Analyzing betting edges
python value_bets.pyTrack odds movements over time:
- Monitoring odds changes
- Historical odds data
- Batch odds fetching
- Recent updates tracking
python odds_tracking.pyA Jupyter notebook, viewable without running anything at nbviewer.org/github/odds-api-io/odds-api-python/blob/main/examples/fair-odds-and-closing-lines.ipynb:
- Devigging with the multiplicative and power methods
- Bookmaker margin per fixture on moneyline and spread markets, from a real
/odds/multisnapshot of six bookmakers - Expected value of every soft-book price against the sharp consensus fair line
- Closing lines for a week of settled Premier League matches from
/historical/closing-lines - Closing line value and a line-movement chart from
/odds/movements
It runs with plain requests, pandas and matplotlib (no SDK needed). With ODDS_API_KEY set it fetches live data; without a key it uses the frozen snapshot in data/snapshot-2026-09-19.json, so every cell runs offline.
pip install jupyter requests pandas matplotlib
jupyter notebook fair-odds-and-closing-lines.ipynbOne short script per bookmaker, each paired with a guide on the blog:
bet365_odds.py: Bet365 1X2 and the 2.5 goal line for the next Premier League fixtures (guide)betfair_exchange_odds.py: Betfair Exchange back and lay prices, the gap between them and the midpoint (guide)draftkings_odds.py: DraftKings NFL moneyline, spread and total, converted to American odds (guide)
Add the bookmaker to your selected bookmakers before running its script.
python bet365_odds.py
python betfair_exchange_odds.py
python draftkings_odds.pyGrades the stored bets in data/bets.json with grade_bets and prints one line per bet: the result, the reason, whether it is final and the score it was based on (guide). The sample bets cover a quarter-line handicap, a push, extra time, a shootout, a player prop, a cancelled match and a market that is not graded. Settlement needs a paid plan.
python settle_bets.py- Rate Limits: Be mindful of the API rate limits (5,000 requests/hour)
- Error Handling: All examples use context managers for proper resource cleanup
- Free Tier: Some features may be limited on the free tier (e.g., 2 bookmakers max)
- Real Data: These examples use real API data, so results will vary