Learn R Programming

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.

Installation

You can install the CRAN version of hoopR with:

install.packages("hoopR")

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.

Breaking Changes

Full News on Releases

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

Our Authors

  • Saiem Gilani (@saiemgilani)

Our Contributors (they’re awesome)

  • Jason Lee (@theFirmAISports)

  • Billy Fryer (@BillyFryer42)

  • Ross Drucker (@rossdrucker9)

  • Vladislav Shufinskiy (@vshufinskiy)

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},
  year = {2021}
}

Copy Link

Version

Install

install.packages('hoopR')

Monthly Downloads

1,515

Version

3.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Saiem Gilani

Last Published

August 25th, 2026

Functions in hoopR (3.1.0)

cbbd_draft_teams

CBD Draft Teams
cbbd_lineups_team

CBD Team Lineups
cbbd_recruiting_players

CBD Recruiting Players
cbbd_lines

CBD Betting Lines
cbbd_stats_team_season

CBD Team Season Stats
cbbd_games

CBD Games
cbbd_plays_game

CBD Plays by Game
cbbd_ratings_srs

CBD SRS Ratings
cbbd_rankings

CBD Rankings
cbbd_substitutions_game

CBD Substitutions by Game
csv_from_url

Load .csv / .csv.gz file from a remote connection
.bb_normalize_team

Normalize a team name for cross-source matching
.bb_normalize_name

Normalize a person name for cross-source matching
.bb_normalize_college_team

Normalize a college team name for cross-source matching (contracting form)
check_status

Check Status function
clean_team_names_NCAA_merge

Clean KenPom Data Frame Team Names to match NCAA Team Names for easier merging
.bb_to_eastern

Reduce a timestamp (UTC datetime, ISO string, or Date) to the local ET date
.bb_fuzzy_match

Deterministic blocked fuzzy matcher (greedy within block)
.build_player_roster

Build player roster lookup from boxscore data
cbbd_teams

CBD Teams
cbbd_venues

CBD Venues
.players_on_court

Add players on court in NBA Stats API play-by-play
.bref_table

Internal: parse a Basketball-Reference HTML table by id using data-stat keys
.parse_currency

Internal: coerce a currency-formatted character vector to numeric
.capture_args

Capture the calling function's formal arguments
.ext_html

Internal: fetch a URL and return the parsed HTML document
.realgm_pick

Internal: pick the best data table from a list of RealGM tables
.realgm_html

Internal: fetch a RealGM page through headless Chrome (clears Cloudflare)
.kp_request

Build an httr2 request with KenPom headers and cookie jar
.bref_text

Internal: GET a Basketball-Reference page and return the response body text
.interp_braces

Minimal brace-template interpolator
.realgm_tables

Internal: extract every parseable HTML table from a RealGM document
.kp_get_page

Fetch a KenPom page as parsed HTML using an authenticated cookie jar
.next_data

Internal: extract and parse the Next.js __NEXT_DATA__ JSON from a page
.players_on_court_v3

Add players on court in NBA Stats API V3 play-by-play
.cbbd_get

Internal: perform a GET against the CollegeBasketballData API
.kp_headers_list

KenPom headers as a named list (for httr2 req_headers)
.realgm_doc

Internal: fetch a RealGM page and parse it into an xml_document
.realgm_finish

Internal: finalize a RealGM table as a hoopR_data tibble
.report_api_error

Report an API-call error with full context
espn_basketball_player_core

Project an ESPN core-v2 athlete record into a player_core row
espn_mbb_athletes_index_schema

Shared column schema: espn mbb athletes index schema
.v3_to_v2_format

Convert V3 PBP columns to V2-compatible format
espn_mbb_award

Get ESPN MBB Season Award Detail
espn_mbb_athletes_index

Get ESPN Women's College Basketball Athletes Index
.resp_text

Extract response body as text
.retry_request

Perform an HTTP GET request with retry logic
.report_api_warning

Report an API-call warning with full context
espn_basketball

ESPN Basketball Endpoint Overview (NBA + MBB)
.torvik_text

Internal: GET a barttorvik.com resource and return the response body text
espn_mbb_calendar_schema

Shared column schema: espn mbb calendar schema
espn_mbb_coach_record

Get ESPN MBB Coach Career Record (Long Format)
espn_mbb_coach_season

Get ESPN MBB Coach-in-Season Detail
espn_mbb_coaches

Get ESPN Women's College Basketball Coaches
espn_mbb_calendar

Get ESPN MBB Calendar
espn_mbb_coach

Get ESPN MBB Single-Coach Detail
espn_mbb_coach_season_schema

Shared column schema: espn mbb coach season schema
espn_mbb_betting_predictor_schema

Shared column schema: espn mbb betting predictor schema
espn_mbb_betting_againstthespread_schema

Shared column schema: espn mbb betting againstthespread schema
espn_mbb_betting_pickcenter_schema

Shared column schema: espn mbb betting pickcenter schema
espn_mbb_conferences_schema

Shared column schema: espn mbb conferences schema
espn_mbb_franchise

Get ESPN MBB Franchise Detail
espn_mbb_futures

Get ESPN MBB Season Futures (Long Format)
espn_mbb_franchises

Get ESPN MBB Franchises Index
espn_mbb_coaches_schema

Shared column schema: espn mbb coaches schema
espn_mbb_game_all_plays_schema

Shared column schema: espn mbb game all plays schema
espn_mbb_conferences

Get ESPN conference names and IDs
espn_mbb_game_all_team_schema

Shared column schema: espn mbb game all team schema
espn_mbb_game_all_player_schema

Shared column schema: espn mbb game all player schema
espn_mbb_game_all

Get ESPN men's college basketball data (Pbp, Team and Player Box)
espn_mbb_game_probabilities

Get ESPN Women's College Basketball Event Win Probabilities
espn_mbb_game_odds_schema

Shared column schema: espn mbb game odds schema
espn_mbb_game_play

Get ESPN MBB Event Play Detail (Single Play)
espn_mbb_game_player_box

Get ESPN MBB Event Player Box Score (Long Format)
espn_mbb_game_official_detail

Get ESPN MBB Event Official Detail (Single Official)
espn_mbb_game_odds

Get ESPN Women's College Basketball Event Odds
espn_mbb_game_play_personnel

Get ESPN MBB Event Play Personnel (On-Court Lineup at Play)
espn_mbb_game_probabilities_schema

Shared column schema: espn mbb game probabilities schema
espn_mbb_game_officials_schema

Shared column schema: espn mbb game officials schema
espn_mbb_game_broadcasts_schema

Shared column schema: espn mbb game broadcasts schema
espn_mbb_game_propbets

Get ESPN MBB Event Prop Bets (Long Format)
espn_mbb_leaders_schema

Shared column schema: espn mbb leaders schema
espn_mbb_news

Get ESPN MBB News
espn_mbb_injuries

Get ESPN Women's College Basketball Injuries
espn_mbb_leaders

Get ESPN Women's College Basketball League Leaders
espn_mbb_player_awards

Get ESPN Women's College Basketball Athlete Awards
espn_mbb_game_team_roster_entry

Get ESPN MBB Event Competitor Roster Entry (Per-Athlete Game-Day Row)
espn_mbb_game_team_linescores

Get ESPN MBB Event Competitor Linescores (Per-Quarter)
espn_mbb_news_schema

Shared column schema: espn mbb news schema
espn_mbb_injuries_injuries_schema

Shared column schema: espn mbb injuries injuries schema
espn_mbb_player_info

Get ESPN Women's College Basketball Athlete Info
espn_mbb_player_awards_schema

Shared column schema: espn mbb player awards schema
espn_mbb_player_career_stats

Get ESPN MBB Athlete Career Stats (Long Format)
espn_mbb_player_overview

Get ESPN Women's College Basketball Athlete Overview
espn_mbb_player_eventlog_v2

Get ESPN MBB Athlete Per-Season Event Log (core-v2)
espn_mbb_player_seasons

Get ESPN MBB Athlete Career Seasons
espn_mbb_player_career_stats_schema

Shared column schema: espn mbb player career stats schema
espn_mbb_player_seasons_schema

Shared column schema: espn mbb player seasons schema
espn_mbb_player_eventlog_schema

Shared column schema: espn mbb player eventlog schema
espn_mbb_player_info_bio_schema

Shared column schema: espn mbb player info bio schema
espn_mbb_scoreboard

Get ESPN men's college basketball schedule for a specific year
espn_mbb_season_group_schema

Shared column schema: espn mbb season group schema
espn_mbb_powerindex

Get ESPN MBB Season Power Index (Long Format)
espn_mbb_season_awards

Get ESPN MBB Season Awards Index
espn_mbb_position

Get ESPN MBB Position Detail
espn_mbb_positions

Get ESPN MBB Positions Index
espn_mbb_season_group

Get ESPN MBB Season Group Detail
espn_mbb_rankings

Get men's college basketball AP and Coaches Poll rankings from ESPN
espn_mbb_season_group_children_schema

Shared column schema: espn mbb season group children schema
espn_mbb_player_stats

Get ESPN men's college basketball player stats data
espn_mbb_season_ranking

Get ESPN MBB Season Ranking Detail
espn_mbb_season_groups

Get ESPN MBB Season Groups Index
espn_mbb_season_leaders

Get ESPN MBB Season Leaders (Long Format)
espn_mbb_season_info_info_schema

Shared column schema: espn mbb season info info schema
espn_mbb_season_info

Get ESPN Women's College Basketball Season Info
espn_mbb_season_rankings

Get ESPN MBB Season Rankings Index
espn_mbb_season_group_teams_schema

Shared column schema: espn mbb season group teams schema
espn_mbb_season_leaders_schema

Shared column schema: espn mbb season leaders schema
espn_mbb_season_ranking_schema

Shared column schema: espn mbb season ranking schema
espn_mbb_season_groups_schema

Shared column schema: espn mbb season groups schema
espn_mbb_season_weeks_schema

Shared column schema: espn mbb season weeks schema
espn_mbb_season_type

Get ESPN MBB Season-Type Detail
espn_mbb_seasons

Get ESPN Women's College Basketball Seasons
espn_mbb_season_weeks

Get ESPN MBB Season Weeks Index
espn_mbb_season_week_schema

Shared column schema: espn mbb season week schema
espn_mbb_season_week

Get ESPN MBB Season-Week Detail
espn_mbb_season_types

Get ESPN MBB Season Types Index
espn_mbb_standings

Get ESPN men's college basketball standings
espn_mbb_seasons_schema

Shared column schema: espn mbb seasons schema
espn_mbb_season_type_schema

Shared column schema: espn mbb season type schema
espn_mbb_team_info_schema

Shared column schema: espn mbb team info schema
espn_mbb_team_news

Get ESPN MBB Team News
espn_mbb_team

Get ESPN Women's College Basketball Team Detail
espn_mbb_team_injuries

Get ESPN Women's College Basketball Team Injuries
espn_mbb_team_record

Get ESPN MBB Team Record (Per Season Type)
espn_mbb_team_odds_records

Get ESPN MBB Team Odds-Records (Long Format)
espn_mbb_team_odds_records_schema

Shared column schema: espn mbb team odds records schema
espn_mbb_team_injuries_injuries_schema

Shared column schema: espn mbb team injuries injuries schema
espn_mbb_team_leaders_schema

Shared column schema: espn mbb team leaders schema
espn_mbb_team_current_roster

Get ESPN men's college basketball current team roster
espn_mbb_team_roster_schema

Shared column schema: espn mbb team roster schema
espn_mbb_team_season_roster

Get ESPN MBB Team Roster (Per-Season, core-v2)
espn_mbb_team_schedule

Get ESPN Women's College Basketball Team Schedule
espn_mbb_tournament

Get ESPN MBB Tournament Detail
espn_mbb_team_season_statistics

Get ESPN MBB Team Season Statistics (Long Format with Rank)
espn_mbb_team_record_detail

Get ESPN MBB Team Record Detail (Long Format)
espn_mbb_team_season_roster_schema

Shared column schema: espn mbb team season roster schema
espn_mbb_team_schedule_schema

Shared column schema: espn mbb team schedule schema
espn_mbb_team_stats

Get ESPN men's college basketball team stats data
espn_mbb_teams

Get ESPN men's college basketball team names and IDs
espn_mbb_week_ranking_schema

Shared column schema: espn mbb week ranking schema
espn_mbb_tournament_seasons

Get ESPN MBB Tournament Seasons List
espn_mbb_tournaments

Get ESPN MBB Tournaments Index
espn_mbb_week_rankings

Get ESPN MBB Per-Week Rankings Index
espn_mbb_venues

Get ESPN Women's College Basketball Venues
espn_mbb_week_ranking

Get ESPN MBB Per-Week Ranking Detail
espn_mbb_tournament_season

Get ESPN MBB Tournament Season Detail
espn_mbb_week_rankings_schema

Shared column schema: espn mbb week rankings schema
espn_mbb_venues_schema

Shared column schema: espn mbb venues schema
espn_mbb_wp

Men's College Basketball win probability chart data from ESPN
fox_basketball_boxscore

Get Fox Sports Basketball Boxscore
espn_nba_game_all_team_schema

Shared column schema: espn nba game all team schema
fox_basketball_league_leaders

Get Fox Sports Basketball Statistical Leaders
espn_nba_team_depthchart

Get ESPN NBA Team Depth Chart (Long Format)
espn_nba_freeagents

Get ESPN NBA Free Agents
espn_nba_player_contracts

Get ESPN NBA Athlete Contracts Index
espn_nba_transactions

Get ESPN NBA Transactions
espn_nba_draft_pick

Get ESPN NBA Draft Pick Detail
espn_nba_game_all_plays_schema

Shared column schema: espn nba game all plays schema
espn_nba_game_all_player_schema

Shared column schema: espn nba game all player schema
helper_espn_mbb_pbp

Parse ESPN MBB PBP, helper function
fox_basketball_standings

Get Fox Sports Basketball Standings
helper_espn_nba_pbp

Parse ESPN NBA PBP, helper function
fox_basketball_odds

Get Fox Sports Basketball Game Odds
fox_basketball_team_gamelog

Get Fox Sports Basketball Team Game Log
fox_basketball_team_stats

Get Fox Sports Basketball Team Stat Leaders
fox_mbb_teams_all

Get the full Fox Sports men's college basketball team directory
fox_basketball_teams

Get Fox Sports Basketball Team Directory
fox_basketball_pbp

Get Fox Sports Basketball Play-by-Play
fox_basketball_team_roster

Get Fox Sports Basketball Team Roster
kp

KenPom Scraper Overview
kp_trends

Get Division-I statistical trends
kp_confhistory

Get KenPom's historical conference ratings
hoopR_loaders

hoopR Data Loaders Overview
hoopR-package

hoopR: Access Men's Basketball Play by Play Data
hoopshype_salaries

HoopsHype Player Salaries
kp_coach_history

Get KenPom's coaching resume data
kp_box

Get KenPom Game Box Score
kp_confstats

Get KenPom's conference comparison stats
kp_conf

Get KenPom's conference-wide stats
bref_player_game_log

Basketball-Reference Player Game Log
bref_teams_stats

Basketball-Reference Team Season Stats
bref_players_stats

Basketball-Reference Player Season Stats
bref_injuries

Basketball-Reference NBA Injury Report
bref_standings

Basketball-Reference Standings
bref_awards

Basketball-Reference Awards Voting
bref_team_roster

Basketball-Reference Team Roster
bref_draft

Basketball-Reference Draft
bref_player_bios

Basketball-Reference Player Bios / Index
cbbd_conferences

CBD Conferences