Access Live Sports Odds from the Odds API

A utility to quickly obtain clean and tidy sports odds from The Odds API < https://the-odds-api.com>. Provides wrappers for every version 4 endpoint -- featured-market and single-event odds (including player props and alternate lines), historical odds snapshots, scores, events, participants, and usage-quota reporting -- returning tidy tibbles ready for analysis.


oddsapiR

CRANversion CRANdownloads R-universeversion Version-Number R-CMD-check Lifecycle:maturing Contributors TwitterFollow

oddsapiR is an R package for accessing live and historical sports betting odds, scores, events, and participants from The Odds API — spanning dozens of sports and 60+ bookmakers worldwide. Every endpoint returns a clean, tidy data.frame/tibble ready for analysis, built on a single httr2-based request layer with automatic API-key handling and usage-quota tracking.

Part of the SportsDataverse family of R & Python packages for sports analytics. To access the API, get a free API key at https://the-odds-api.com.

Installation

You can install the CRAN version of oddsapiR with:

install.packages("oddsapiR")

You can install the development version of oddsapiR from GitHub with:

# using the pak package (recommended):
if (!requireNamespace('pak', quietly = TRUE)){
  install.packages('pak')
}
pak::pak("sportsdataverse/oddsapiR")
# or using the devtools package:
if (!requireNamespace('devtools', quietly = TRUE)){
  install.packages('devtools')
}
devtools::install_github(repo = "sportsdataverse/oddsapiR")
# or clone and install locally
git clone https://github.com/sportsdataverse/oddsapiR
cd oddsapiR
Rscript -e "pak::local_install()"  # or: Rscript -e "devtools::install()"

Odds API Keys

The Odds API requires an API key, here’s a quick run-down:

  • Using the key: You can save the key for consistent usage by adding ODDS_API_KEY=XXXX-YOUR-API-KEY-HERE-XXXXX to your .Renviron file (easily accessed via usethis::edit_r_environ()). Run usethis::edit_r_environ(), a new script will pop open named .Renviron, THEN paste the following in the new script that pops up (without quotations)
ODDS_API_KEY = XXXX-YOUR-API-KEY-HERE-XXXXX

Save the script and restart your RStudio session, by clicking Session (in between Plots and Build) and click Restart R (there also exists the shortcut Ctrl + Shift + F10 to restart your session). If set correctly, from then on you should be able to use any of the functions without any other changes.

  • For less consistent usage: At the beginning of every session or within an R environment, save your API key as the environment variable ODDS_API_KEY (with quotations) using a command like the following.
Sys.setenv(ODDS_API_KEY = "XXXX-YOUR-API-KEY-HERE-XXXXX")

Documentation

For more information on the package and function reference, please see the oddsapiR documentation website.

Breaking Changes

Full News on Releases

Follow the SportsDataverse on Twitter and star this repo

TwitterFollow

GitHubstars

The SportsDataverse

oddsapiR is part of the SportsDataverse, a family of open-source R, Python, and Node.js packages for sports data. Related packages you can pair odds data with:

Package Sport / Scope
cfbfastR College football
hoopR Men’s basketball (NBA & NCAA)
wehoop Women’s basketball (WNBA & NCAA)
fastRhockey Hockey (NHL & PWHL)
baseballr Baseball (MLB, MiLB, NCAA)
sportsdataverse-R Umbrella R metapackage
sportsdataverse-py · sportsdataverse.js Python & Node.js

See the full ecosystem at sportsdataverse.org.

Our Authors

Citations

To cite the oddsapiR R package in publications, use:

BibTex Citation

@misc{gilani_2022_oddsapiR,
  author = {Gilani, Saiem},
  title = {oddsapiR: The SportsDataverse's R Package for The Odds API.},
  url = {https://oddsapiR.sportsdataverse.org},
  year = {2022}
}

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("oddsapiR")

1.0.1 by Saiem Gilani, 2 months ago


https://oddsapiR.sportsdataverse.org/, https://github.com/sportsdataverse/oddsapiR


Report a bug at https://github.com/sportsdataverse/oddsapiR/issues


Browse source code at https://github.com/cran/oddsapiR


Authors: Saiem Gilani [aut, cre, cph] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, data.table, dplyr, glue, httr2, jsonlite, magrittr, rlang, rvest, tibble, tidyr

Suggests crayon, curl, DBI, ggplot2, ggrepel, gt, knitr, progressr, Rcpp, RcppParallel, rmarkdown, RSQLite, stats, stringi, stringr, testthat, tidyselect, usethis, xml2

System requirements: pandoc (>= 1.12.3), pandoc-citeproc


See at CRAN