Table of Contents
{oddsapiR} for Sports Betting Odds
oddsapiR
oddsapiR is an R package that wraps
The Odds API, giving you tidy access to bookmaker
odds across dozens of sports and sportsbooks. Moneylines, point spreads, and
totals all come back as clean data frames ready for modelling, line-shopping, or
backtesting.
Installation
From CRAN:
install.packages("oddsapiR")Or the development version from the SportsDataverse r-universe:
install.packages("oddsapiR", repos = c("https://sportsdataverse.r-universe.dev", getOption("repos")))Get an API key
oddsapiR reads your key from the ODDS_API_KEY environment variable. Sign up
for a free tier at the-odds-api.com and store the
key in your .Renviron:
usethis::edit_r_environ()
# ODDS_API_KEY=your_key_hereQuick start
library(oddsapiR)
# Which sports are available?
toa_sports()
# Current odds for upcoming NFL games
toa_sports_odds(
sport_key = "americanfootball_nfl",
markets = "h2h,spreads,totals",
odds_format = "american"
)Each request returns one row per outcome with the bookmaker, market, and price,
so a single dplyr pipeline gets you the best available number on any side.
More endpoints
oddsapiR 1.0.0 wraps the full Odds API surface, not just pre-match
moneylines. A few of the most useful functions:
toa_sports() # catalog of available sports + their keys
toa_sports_odds() # featured h2h / spreads / totals for a sport
toa_sports_events() # upcoming + live events (with event ids)
toa_event_odds() # per-event odds, including player props
toa_event_markets() # which markets a given event offers
toa_sports_odds_history() # historical odds snapshots (paid tiers)
toa_sports_scores() # live + recently completed scores
toa_sports_participants() # teams / participants for a sport
toa_quota() # remaining + used API requestsBecause every call shares The Odds API's credit model, toa_quota() lets
you keep an eye on your remaining requests as you page through events.
Learn more
- Documentation: oddsapiR.sportsdataverse.org
- The Odds API: the-odds-api.com