Skip to contents

hoopR

hoopR is an R package for working with men’s basketball data.

The package has functions to access live play by play and box score data from ESPN with shot locations when available. As of version 1.3.0, hoopR is also a full NBA Stats API wrapper with 127 functions added in this release.

It is additionally a scraping and aggregating interface for Ken Pomeroy’s men’s college basketball statistics website, kenpom.com. It provides users with an active subscription the capability to scrape the website tables and analyze the data for themselves.

As of version 3.1.0, the package exports 600+ functions spanning the NBA Stats API (nba_*), ESPN (espn_nba_* / espn_mbb_*), KenPom (kp_*), CollegeBasketballData (cbbd_*), Basketball-Reference (bref_*), Bart Torvik (torvik_*), RealGM (realgm_*), Fox Sports (fox_*), NCAA (ncaa_mbb_*), and NBA G-League (nbagl_*), plus load_nba_*() / load_mbb_*() / load_ncaa_mbb_*() bulk-data loaders backed by the sportsdataverse-data release repos.

Data status

The load_*() functions read release assets on sportsdataverse-data. The badges below are rebuilt nightly from each producer’s latest workflow run and newest release files; idle means the sport is out of season. Full detail: sportsdataverse.org/status.

Dataset Data updated Through Pipeline Update workflows
Men’s college basketball (ESPN) hoopR-mbb-data data updated hoopR-mbb-data through season hoopR-mbb-data pipeline state hoopR-mbb-data daily_mbb hoopR-mbb-data mbb_models_cron
Men’s college basketball (stats.ncaa.org) ncaa-mbb-hoops-data data updated ncaa-mbb-hoops-data through season ncaa-mbb-hoops-data pipeline state ncaa-mbb-hoops-data ncaa_mbb_models
NBA (ESPN) hoopR-nba-data data updated hoopR-nba-data through season hoopR-nba-data pipeline state hoopR-nba-data daily_nba
NBA Stats API hoopR-nba-stats-data data updated hoopR-nba-stats-data through season hoopR-nba-stats-data pipeline state hoopR-nba-stats-data daily_nba_stats hoopR-nba-stats-data nba_models hoopR-nba-stats-data annual_nba_stats_draft
Conference, division and ballpark reference sdv-reference-data data updated sdv-reference-data through season sdv-reference-data pipeline state —

Installation

You can install the CRAN version of hoopR with:

You can install the released version of hoopR from GitHub with:

# You can install using the pak package using the following code:
if (!requireNamespace('pak', quietly = TRUE)){
  install.packages('pak')
}
pak::pak("sportsdataverse/hoopR")

Quick Start

NBA full play-by-play seasons (2002-2026) ~ 1-2 minutes

tictoc::tic()
progressr::with_progress({
  nba_pbp <- hoopR::load_nba_pbp()
})
tictoc::toc()
## 4.05 sec elapsed

## 642472 rows of NBA play-by-play data from 1325 games.

Men’s college basketball full play-by-play seasons (2006-2026) ~ 2-3 minutes

tictoc::tic()
progressr::with_progress({
  mbb_pbp <-  hoopR::load_mbb_pbp()
})
tictoc::toc()
## 12.98 sec elapsed

## 2915731 rows of men's college basketball play-by-play data from 6275 games.

Documentation

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

There is also a printable hoopR cheat sheet (PDF), one of a set covering every SportsDataverse package.

Breaking Changes

Full News on Releases

Follow the SportsDataverse (@SportsDataverse) on X and star this repo

X Follow

GitHub stars

Our Authors

  • Saiem Gilani (@saiemgilani) @saiemgilani

@saiemgilani

Our Contributors (they’re awesome)

  • Jason Lee (@theFirmAISports) @theFirmAISports @papagorgio23

  • Billy Fryer (@BillyFryer42) @BillyFryer42 @billyfryer

  • Ross Drucker (@rossdrucker9) @rossdrucker9 @rossdrucker

  • Vladislav Shufinskiy (@vshufinskiy) @vshufinskiy @shufinskiy

Cheat sheet

A printable one-page reference for hoopR — the function families, the loaders, and what each one returns.

📄 Download the hoopR cheat sheet (PDF)

Free to download, print and hand out; light and dark, US Letter landscape. Every SportsDataverse package has one — browse them all at sportsdataverse.org/cheatsheets.

Citations

To cite the hoopR R package in publications, use:

BibTex Citation

@misc{gilani_2021_hoopR,
  author = {Gilani, Saiem},
  title = {hoopR: The SportsDataverse's R Package for Men's Basketball Data.},
  url = {https://hoopR.sportsdataverse.org},
  doi = {10.32614/CRAN.package.hoopR},
  year = {2026}
}