๐ฒ Betting odds with sportsdataverse-py
Welcome! In a few lines of Python you're about to pull live betting odds
from a whole market of sportsbooks โ moneylines, spreads, totals, player
props, scores, even point-in-time history. sportsdataverse.odds wraps
The Odds API v4 and hands you back tidy polars
DataFrames that are ready to model. ๐
If you've used the R package oddsapiR,
the toa_* names will feel right at home. Let's dive in!
๐งฐ The toolboxโ
Every function returns a tidy polars DataFrame by default โ pass
return_as_pandas=True for pandas, or return_parsed=False for the raw JSON.
Here's the whole kit (click any name for the full reference):
| Function | What it gives you | Quota |
|---|---|---|
toa_sports | Every in-season sport/league key (the sport= value) | ๐ free |
toa_sports_odds | Current odds for a sport โ one row per outcome | ๐ณ paid |
toa_event_odds | Odds for a single game, including player props | ๐ณ paid |
toa_event_markets | Which markets a game has on offer | ๐ free |
toa_sports_scores | Live + recently-completed scores | ๐ free |
toa_sports_events | Upcoming + live event list (grab event_ids here) | ๐ free |
toa_sports_participants | Teams / participants for a sport | ๐ free |
toa_sports_odds_history | Historical odds snapshot (paid plans) | ๐ณ paid |
toa_sports_events_history | Historical event snapshot | ๐ณ paid |
toa_event_odds_history | Historical single-game odds | ๐ณ paid |
toa_usage | Your remaining quota (reads cached headers) | ๐ free |
๐ Setupโ
pip install sportsdataverse
The Odds API needs a key โ grab a free one at
the-odds-api.com. Set it once as the
ODDS_API_KEY environment variable (the same name oddsapiR uses) or pass
api_key= to any call. The live cells below run only when a key is present,
so this page is happy either way. ๐
import os
import polars as pl
import sportsdataverse.odds as odds
HAS_KEY = bool(os.environ.get("ODDS_API_KEY"))
print("ODDS_API_KEY set:", HAS_KEY, "โ live cells will" + ("" if HAS_KEY else " NOT") + " run")
ODDS_API_KEY set: False โ live cells will NOT run