Skip to contents

helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots

helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots

helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots

helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots

helper that loads multiple seasons of ESPN NBA standings from the sportsdataverse-data release repo (tidy long format: one row per team-per-stat), either into memory or into a database via forwarded arguments in the dots.

helper that loads multiple seasons of ESPN NBA per-game rosters from the sportsdataverse-data release repo, either into memory or into a database via forwarded arguments in the dots.

helper that loads multiple seasons of ESPN NBA per-game officials from the sportsdataverse-data release repo, either into memory or into a database via forwarded arguments in the dots.

helper that loads multiple seasons of ESPN NBA draft results (overall pick, round, drafted player, and team) from the sportsdataverse-data release repo, either into memory or into a database via forwarded arguments in the dots.

helper that loads multiple seasons of ESPN NBA per-player season stats (averages / totals / miscellaneous categories, long format) from the sportsdataverse-data release repo, either into memory or into a database via forwarded arguments in the dots.

helper that loads multiple seasons of ESPN NBA per-team season stats (general / offensive / defensive categories, long format) from the sportsdataverse-data release repo, either into memory or into a database via forwarded arguments in the dots.

helper that loads multiple seasons of ESPN NBA team rosters (one row per athlete) from the sportsdataverse-data release repo, either into memory or into a database via forwarded arguments in the dots. NOTE: ESPN's roster endpoint returns the current roster, so season files are snapshots as-of-scrape rather than true historical rosters.

helper that loads multiple seasons of ESPN NBA athlete core records – identity and biographical fields, one row per athlete who appeared in the season – from the sportsdataverse-data release repo, either into memory or into a database via forwarded arguments in the dots.

This is the only source of athlete bio in the pipeline: the player season stats payload carries no identity at all – not even the athlete id.

Two properties of the source are worth knowing before joining:

  • current_team_id is the athlete's CURRENT team, not their team in the requested season. Season team lives in load_nba_player_box() / load_nba_player_stats().

  • Bio (height / weight / jersey) is a current snapshot that ESPN overwrites in place; it is not era-correct for a historical season. The season dimension here is participation, not the bio's vintage.

Field coverage is era-dependent by nature – headshots exist only for modern players, while college and date of birth thin out the other way.

Loads shot events parsed from ESPN NBA play-by-play feeds. One row per shot attempt (made or missed), with court coordinates and shot metadata. Backed by the hoopR-nba-data pipeline, publishing parquet/rds artifacts to the espn_nba_shots release tag.

Usage

load_nba_pbp(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_team_box(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_player_box(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_schedule(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_standings(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_game_rosters(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_officials(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_draft(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_player_stats(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_team_stats(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_rosters(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_player_core(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

load_nba_shots(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

Arguments

seasons

A vector of 4-digit years associated with given NBA seasons. (Min: 2002)

...

Additional arguments passed to an underlying function that writes the season data into a database (used by update_nba_db()).

dbConnection

A DBIConnection object, as returned by

tablename

The name of the play by play data table within the database

Value

Returns a tibble

col_nametypesdescription
idnumericId.
sequence_numbercharacterSequence number representing a shot-possession (V3 PBP).
type_idintegerType identifier (numeric).
type_textcharacterDisplay text for the type field.
textcharacterText description of the play / record.
away_scoreintegerAway team score at the time of the play.
home_scoreintegerHome team score at the time of the play.
period_numberintegerNumeric period (1-4 for quarters; 5+ for OT).
period_display_valuecharacterPeriod display label (e.g. '1st Quarter', 'OT').
clock_display_valuecharacterGame clock display string (e.g. '8:32').
scoring_playlogicalTRUE if the play resulted in points scored.
score_valueintegerPoint value of the play (2 / 3 / 1).
team_idintegerUnique team identifier.
athlete_id_1integerPrimary athlete identifier (e.g. shooter).
athlete_id_2integerSecondary athlete identifier (e.g. assister / fouler).
athlete_id_3integerAthlete id 3.
wallclockcharacterWallclock.
shooting_playlogicalTRUE if the play was a shooting attempt.
coordinate_x_rawnumericX coordinate as returned by the API before any adjustment.
coordinate_y_rawnumericY coordinate as returned by the API before any adjustment.
seasonintegerSeason identifier (4-digit year or 'YYYY-YY' string).
season_typeintegerSeason type (1=pre-season, 2=regular season, 3=postseason, 4=off-season for ESPN; or string label for WNBA Stats).
away_team_idintegerUnique identifier for the away team.
away_team_namecharacterAway team name.
away_team_mascotcharacterAway team mascot.
away_team_abbrevcharacterAway team three-letter abbreviation.
away_team_name_altcharacterAlternate away team name.
home_team_idintegerUnique identifier for the home team.
home_team_namecharacterHome team name.
home_team_mascotcharacterHome team mascot.
home_team_abbrevcharacterHome team three-letter abbreviation.
home_team_name_altcharacterAlternate home team name.
home_team_spreadnumericHome team's point spread.
game_spreadnumericGame spread (signed; positive = home favored).
home_favoritelogicalTRUE if the home team is the betting favorite.
game_spread_availablelogicalTRUE if a point spread was available.
game_idintegerUnique game identifier.
qtrintegerQuarter (1-4) or OT period (5+).
timecharacterTime / clock value.
clock_minutesintegerClock minutes split out for convenience.
clock_secondsnumericClock seconds split out for convenience.
halfcharacterHalf of the game (1 or 2).
game_halfcharacterHalf of the game (1 or 2).
lead_qtrintegerQuarter lead (the next-play's quarter).
lead_game_halfcharacterHalf lead (the next-play's half).
start_quarter_seconds_remainingintegerSeconds remaining in the period at the start of the play.
start_half_seconds_remainingintegerSeconds remaining in the half at the start of the play.
start_game_seconds_remainingintegerSeconds remaining in the game at the start of the play.
game_play_numberintegerSequential play number within the game.
end_quarter_seconds_remainingintegerSeconds remaining in the period at the end of the play.
end_half_seconds_remainingintegerSeconds remaining in the half at the end of the play.
end_game_seconds_remainingintegerSeconds remaining in the game at the end of the play.
periodintegerPeriod of the game (1-4 quarters; 5+ for OT).
lag_qtrintegerQuarter lag (the previous-play's quarter).
lag_game_halfcharacterHalf lag (the previous-play's half).
coordinate_xnumericX coordinate on the court (half-court layout).
coordinate_ynumericY coordinate on the court (half-court layout).
game_dateDateGame date (YYYY-MM-DD).
game_date_timePOSIXctGame start date/time (ISO 8601).
type_abbreviationcharacterType abbreviation.

Returns a tibble

Columns as documented in the shared espn_nba_game_all_team_schema table.

Returns a tibble

Columns as documented in the shared espn_nba_game_all_player_schema table.

Returns a tibble

col_nametypesdescription
idintegerId.
uidcharacterESPN UID string (universal identifier).
datecharacterDate in YYYY-MM-DD format.
attendanceintegerReported attendance.
time_validlogicalTime valid.
neutral_sitelogicalNeutral site.
conference_competitionlogicalConference competition.
recentlogicalRecent.
start_datecharacterStart date (YYYY-MM-DD).
notes_typecharacterNotes type.
notes_headlinecharacterNotes headline.
type_idintegerType identifier (numeric).
type_abbreviationcharacterType abbreviation.
venue_idintegerUnique venue identifier.
venue_full_namecharacterVenue full name.
venue_address_citycharacterVenue address city.
venue_capacityintegerVenue seating capacity.
venue_indoorlogicalTRUE if the venue is indoors.
status_clockintegerStatus clock.
status_display_clockcharacterStatus display clock.
status_periodintegerStatus period.
status_type_idintegerUnique identifier for status type.
status_type_namecharacterStatus type name.
status_type_statecharacterStatus type state.
status_type_completedlogicalStatus type completed.
status_type_descriptioncharacterStatus type description.
status_type_detailcharacterStatus type detail.
status_type_short_detailcharacterStatus type short detail.
format_regulation_periodsintegerFormat regulation periods.
home_idintegerUnique identifier for home.
home_uidcharacterHome team's uid.
home_locationcharacterHome team's location.
home_namecharacterHome name.
home_abbreviationcharacterHome team's abbreviation.
home_display_namecharacterHome display name.
home_short_display_namecharacterHome short display name.
home_colorcharacterColor code (hex) for home.
home_alternate_colorcharacterColor code (hex) for home alternate.
home_is_activelogicalHome team's is active.
home_venue_idintegerUnique identifier for home venue.
home_logocharacterHome team logo URL.
home_scoreintegerHome team score at the time of the play.
home_winnerlogicalHome team's winner.
away_idintegerUnique identifier for away.
away_uidcharacterAway team's uid.
away_locationcharacterAway team's location.
away_namecharacterAway name.
away_abbreviationcharacterAway team's abbreviation.
away_display_namecharacterAway display name.
away_short_display_namecharacterAway short display name.
away_colorcharacterColor code (hex) for away.
away_alternate_colorcharacterColor code (hex) for away alternate.
away_is_activelogicalAway team's is active.
away_venue_idintegerUnique identifier for away venue.
away_logocharacterAway team logo URL.
away_scoreintegerAway team score at the time of the play.
away_winnerlogicalAway team's winner.
game_idintegerUnique game identifier.
seasonintegerSeason identifier (4-digit year or 'YYYY-YY' string).
season_typeintegerSeason type (1=pre-season, 2=regular season, 3=postseason, 4=off-season for ESPN; or string label for WNBA Stats).
venue_address_statecharacterVenue address state / region.
status_type_alt_detailcharacterStatus type alt detail.
PBPlogical
team_boxlogicalTeam box.
player_boxlogicalPlayer box.
game_date_timePOSIXctGame start date/time (ISO 8601).
game_dateDateGame date (YYYY-MM-DD).

Returns a tibble of per-season NBA standings.

Returns a tibble of per-game NBA rosters.

Returns a tibble of per-game NBA officials.

Returns a tibble of NBA draft picks.

Returns a tibble of NBA player season stats (long format).

Returns a tibble of NBA team season stats (long format).

Returns a tibble of NBA team rosters.

Returns a tibble of NBA athlete core records (one row per athlete-season).

Returns a tibble with one row per shot attempt.

col_nametypesdescription
game_idintegerUnique game identifier.
seasonintegerSeason identifier (4-digit year).
period_numberintegerNumeric period (1-4 for quarters; 5+ for OT).
clock_display_valuecharacterGame clock display string (e.g. '8:32').
team_idintegerUnique team identifier.
athlete_id_1integerPrimary athlete identifier (the shooter).
athlete_id_2integerSecondary athlete identifier (e.g. assister / fouler).
type_idintegerType identifier (numeric).
type_textcharacterDisplay text for the shot/play type.
scoring_playlogicalTRUE if the play resulted in points scored.
score_valueintegerPoint value of the shot (2 / 3 / 1).
coordinate_xnumericX coordinate on the court (half-court layout).
coordinate_ynumericY coordinate on the court (half-court layout).
coordinate_x_rawnumericX coordinate as returned by the API before any adjustment.
coordinate_y_rawnumericY coordinate as returned by the API before any adjustment.
athlete_name_1characterDisplay name of the primary athlete (the shooter).
athlete_name_2characterDisplay name of the secondary athlete, when present.
team_namecharacterFull team display name.
team_mascotcharacterTeam mascot / nickname.
team_abbrevcharacterShort team abbreviation.

See also

Other hoopR Loader Functions: load_mbb_pbp()

Examples

# \donttest{
load_nba_pbp(seasons = most_recent_nba_season())
#> ── ESPN NBA pbp from hoopR data repository ────────────────────── hoopR 3.1.0 ──
#>  Data updated: 2026-08-26 06:19:35 UTC
#> # A tibble: 642,472 × 67
#>    game_play_number        id sequence_number type_id type_text text  away_score
#>               <int>     <dbl>           <int>   <int> <chr>     <chr>      <int>
#>  1                1   4.02e 9               4     615 Jumpball  Karl…          0
#>  2                2   4.02e 9               7     144 Driving … Jale…          0
#>  3                3   4.02e 9               8     155 Defensiv… Juli…          0
#>  4                4   4.02e 9               9      92 Jump Shot Step…          0
#>  5                5   4.02e10              10     155 Defensiv… OG A…          0
#>  6                6   4.02e10              11     136 Turnarou… Josh…          0
#>  7                7   4.02e10              12     155 Defensiv… Vict…          0
#>  8                8   4.02e10              13      63 Lost Bal… Step…          0
#>  9                9   4.02e10              15     131 Pullup J… Mika…          0
#> 10               10   4.02e10              16     156 Offensiv… Knic…          0
#> # ℹ 642,462 more rows
#> # ℹ 60 more variables: home_score <int>, period_number <int>,
#> #   period_display_value <chr>, clock_display_value <chr>, scoring_play <lgl>,
#> #   score_value <int>, team_id <int>, athlete_id_1 <int>, athlete_id_2 <int>,
#> #   athlete_id_3 <int>, wallclock <chr>, shooting_play <lgl>,
#> #   coordinate_x_raw <dbl>, coordinate_y_raw <dbl>, points_attempted <int>,
#> #   short_description <chr>, game_id <int>, season <int>, season_type <int>, …
# }
# \donttest{
load_nba_team_box(seasons = most_recent_nba_season())
#> ── ESPN NBA team_box from hoopR data repository ───────────────── hoopR 3.1.0 ──
#>  Data updated: 2026-08-26 06:09:43 UTC
#> # A tibble: 2,652 × 59
#>      game_id season season_type game_date  game_date_time      team_id team_uid 
#>        <int>  <int>       <int> <date>     <dttm>                <int> <chr>    
#>  1 401859967   2026           3 2026-06-13 2026-06-13 20:30:00      18 s:40~l:4…
#>  2 401859967   2026           3 2026-06-13 2026-06-13 20:30:00      24 s:40~l:4…
#>  3 401859966   2026           3 2026-06-10 2026-06-10 20:30:00      24 s:40~l:4…
#>  4 401859966   2026           3 2026-06-10 2026-06-10 20:30:00      18 s:40~l:4…
#>  5 401859965   2026           3 2026-06-08 2026-06-08 20:30:00      24 s:40~l:4…
#>  6 401859965   2026           3 2026-06-08 2026-06-08 20:30:00      18 s:40~l:4…
#>  7 401859964   2026           3 2026-06-05 2026-06-05 20:30:00      18 s:40~l:4…
#>  8 401859964   2026           3 2026-06-05 2026-06-05 20:30:00      24 s:40~l:4…
#>  9 401859963   2026           3 2026-06-03 2026-06-03 20:30:00      18 s:40~l:4…
#> 10 401859963   2026           3 2026-06-03 2026-06-03 20:30:00      24 s:40~l:4…
#> # ℹ 2,642 more rows
#> # ℹ 52 more variables: team_slug <chr>, team_location <chr>, team_name <chr>,
#> #   team_abbreviation <chr>, team_display_name <chr>,
#> #   team_short_display_name <chr>, team_color <chr>,
#> #   team_alternate_color <chr>, team_logo <chr>, team_home_away <chr>,
#> #   team_score <int>, team_winner <lgl>, assists <int>, blocks <int>,
#> #   defensive_rebounds <int>, fast_break_points <chr>, field_goal_pct <dbl>, …
# }
# \donttest{
load_nba_player_box(seasons = most_recent_nba_season())
#> ── ESPN NBA player_box from hoopR data repository ─────────────── hoopR 3.1.0 ──
#>  Data updated: 2026-08-26 06:09:55 UTC
#> # A tibble: 34,883 × 57
#>      game_id season season_type game_date  game_date_time      athlete_id
#>        <int>  <int>       <int> <date>     <dttm>                   <int>
#>  1 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    3934719
#>  2 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    3136195
#>  3 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    3062679
#>  4 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    3147657
#>  5 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    3934672
#>  6 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    4610139
#>  7 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    4351852
#>  8 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    4871141
#>  9 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    2528426
#> 10 401859967   2026           3 2026-06-13 2026-06-13 20:30:00    3914044
#> # ℹ 34,873 more rows
#> # ℹ 51 more variables: athlete_display_name <chr>, team_id <int>,
#> #   team_name <chr>, team_location <chr>, team_short_display_name <chr>,
#> #   minutes <dbl>, field_goals_made <int>, field_goals_attempted <int>,
#> #   three_point_field_goals_made <int>,
#> #   three_point_field_goals_attempted <int>, free_throws_made <int>,
#> #   free_throws_attempted <int>, offensive_rebounds <int>, …
# }
# \donttest{
load_nba_schedule(seasons = most_recent_nba_season())
#> ── ESPN NBA schedules from hoopR data repository ──────────────── hoopR 3.1.0 ──
#>  Data updated: 2026-08-12 06:00:11 UTC
#> # A tibble: 1,330 × 77
#>         id uid   date  attendance time_valid neutral_site conference_competition
#>      <int> <chr> <chr>      <dbl> <lgl>      <lgl>        <lgl>                 
#>  1  4.02e8 s:40… 2026…      18984 TRUE       FALSE        FALSE                 
#>  2  4.02e8 s:40… 2026…      19812 TRUE       FALSE        FALSE                 
#>  3  4.02e8 s:40… 2026…      19812 TRUE       FALSE        FALSE                 
#>  4  4.02e8 s:40… 2026…      19014 TRUE       FALSE        FALSE                 
#>  5  4.02e8 s:40… 2026…      18835 TRUE       FALSE        FALSE                 
#>  6  4.02e8 s:40… 2026…      18203 TRUE       FALSE        FALSE                 
#>  7  4.02e8 s:40… 2026…      19066 TRUE       FALSE        FALSE                 
#>  8  4.02e8 s:40… 2026…      18203 TRUE       FALSE        FALSE                 
#>  9  4.02e8 s:40… 2026…      19432 TRUE       FALSE        FALSE                 
#> 10  4.02e8 s:40… 2026…      19405 TRUE       FALSE        FALSE                 
#> # ℹ 1,320 more rows
#> # ℹ 70 more variables: play_by_play_available <lgl>, recent <lgl>,
#> #   start_date <chr>, broadcast <chr>, highlights <chr>, notes_type <chr>,
#> #   notes_headline <chr>, broadcast_market <chr>, broadcast_name <chr>,
#> #   type_id <int>, type_abbreviation <chr>, venue_id <int>,
#> #   venue_full_name <chr>, venue_address_city <chr>, venue_indoor <lgl>,
#> #   status_clock <dbl>, status_display_clock <chr>, status_period <dbl>, …
# }
# \donttest{
load_nba_shots(seasons = most_recent_nba_season())
#> ── ESPN NBA shots from hoopR data repository ──────────────────── hoopR 3.1.0 ──
#>  Data updated: 2026-08-12 06:00:26 UTC
#> # A tibble: 298,411 × 20
#>      game_id season period_number clock_display_value team_id athlete_id_1
#>        <int>  <int>         <int> <chr>                 <int>        <int>
#>  1 401859967   2026             1 11:35                    18      3934672
#>  2 401859967   2026             1 11:12                    24      4845367
#>  3 401859967   2026             1 10:45                    18      3062679
#>  4 401859967   2026             1 10:16                    18      3147657
#>  5 401859967   2026             1 10:06                    18      3062679
#>  6 401859967   2026             1 9:57                     18      3136195
#>  7 401859967   2026             1 9:44                     24      5104157
#>  8 401859967   2026             1 9:30                     18      3934672
#>  9 401859967   2026             1 9:15                     24      4066259
#> 10 401859967   2026             1 8:58                     18      3136195
#> # ℹ 298,401 more rows
#> # ℹ 14 more variables: athlete_id_2 <int>, type_id <int>, type_text <chr>,
#> #   scoring_play <lgl>, score_value <int>, coordinate_x <dbl>,
#> #   coordinate_y <dbl>, coordinate_x_raw <dbl>, coordinate_y_raw <dbl>,
#> #   athlete_name_1 <chr>, athlete_name_2 <chr>, team_name <chr>,
#> #   team_mascot <chr>, team_abbrev <chr>
# }