Skip to contents

Get NBA Stats API Play-by-Play V3

Get NBA Stats API Play-by-Play V3

Get NBA Stats API play-by-play

Get NBA Stats API play-by-play

Get NBA Stats API play-by-play (Multiple Games)

Get NBA Stats API play-by-play (Multiple Games)

Get NBA Stats API Live play-by-play

Get NBA Stats API Live play-by-play

Get NBA Stats API Live Boxscore

Get NBA Stats API Live Boxscore

Usage

nba_playbyplayv3(game_id, start_period = 0, end_period = 0, ...)

nba_pbp(game_id, on_court = TRUE, version = "v3", p = NULL, ...)

nba_pbps(
  game_ids = NULL,
  on_court = TRUE,
  version = "v3",
  nest_data = FALSE,
  ...
)

nba_live_pbp(game_id, ...)

nba_live_boxscore(game_id, ...)

Arguments

game_id

Game ID

start_period

Start period filter (default: 0 = all periods). Use 1-4 for regulation quarters, 5+ for overtime.

end_period

End period filter (default: 0 = all periods). Use 1-4 for regulation quarters, 5+ for overtime.

...

Additional arguments passed to an underlying function like httr.

on_court

If TRUE (default), on-court player IDs are added for each play event. V3 uses nba_gamerotation() stint data; V2 infers lineups from substitution events.

version

Play-by-play version - "v3" (default) or "v2". V3 returns richer data with shot coordinates, shot values, and V3 action types. V2 is available from 2016-17 onwards.

p

Optional progress object from progressr (default: NULL). Used internally by nba_pbps().

game_ids

Game IDs

nest_data

If TRUE returns nested data by game

Value

Returns a named list of data frames: PlayByPlay, AvailableVideo

PlayByPlay

col_nametypesdescription
game_idcharacterUnique game identifier.
action_numberintegerSequential action number within a game (V3 PBP).
clockcharacterGame clock value.
periodintegerPeriod of the game (1-4 quarters; 5+ for OT).
team_idintegerUnique team identifier.
team_tricodecharacterThree-letter team code (e.g. 'LAS' / 'NYL').
person_idintegerUnique player identifier (V3 endpoints).
player_namecharacterPlayer name.
player_name_icharacterPlayer name i.
x_legacyintegerV2-format X coordinate (preserved for V3-to-V2 compatibility).
y_legacyintegerV2-format Y coordinate (preserved for V3-to-V2 compatibility).
shot_distancenumericShot distance from the basket, in feet.
shot_resultcharacterShot result ('Made' / 'Missed').
is_field_goalinteger1 if the action was a field goal; 0 otherwise.
score_homecharacterScore home.
score_awaycharacterScore away.
points_totalintegerRunning total of points scored.
locationcharacterLocation.
descriptioncharacterLong-form description text.
action_typecharacterAction type label (e.g. 'Made Shot', 'Substitution').
sub_typecharacterAction sub-type label.
video_availableintegerVideo available.
shot_valueintegerPoint value of the shot (2 or 3).
action_idintegerUnique action identifier within a game (V3 PBP).

AvailableVideo

col_nametypesdescription
video_availableintegerVideo available.

Returns a data frame: PlayByPlay

Columns as documented in the shared nba_pbp_schema table.

Returns a data frame: PlayByPlay

Columns as documented in the shared nba_pbp_schema table.

Returns a data frame: PlayByPlay

Columns as documented in the shared nba_live_pbp_schema table.

Returns a named list of data frames: game_details, arena, officials, home_team_boxscore, away_team_boxscore, home_team_player_boxscore, away_team_player_boxscore, home_team_linescores, away_team_linescores

game_details

Columns as documented in the shared nba_live_boxscore_game_details_schema table.

arena

Columns as documented in the shared nba_live_boxscore_arena_schema table.

officials

Columns as documented in the shared nba_live_boxscore_officials_schema table.

home_team_boxscore

Columns as documented in the shared nba_live_boxscore_home_team_boxscore_schema table.

away_team_boxscore

Columns as documented in the shared nba_live_boxscore_home_team_boxscore_schema table.

home_team_player_boxscore

Columns as documented in the shared nba_live_boxscore_home_team_player_boxscore_schema table.

away_team_player_boxscore

Columns as documented in the shared nba_live_boxscore_home_team_player_boxscore_schema table.

home_team_linescores

col_nametypesdescription
periodintegerPeriod of the game (1-4 quarters; 5+ for OT).
period_typecharacterPeriod type.
scoreintegerFinal score.

away_team_linescores

col_nametypesdescription
periodintegerPeriod of the game (1-4 quarters; 5+ for OT).
period_typecharacterPeriod type.
scoreintegerFinal score.

Details

 nba_playbyplayv3(game_id = "0022201086")

 nba_pbp(game_id = '0022201086')
 nba_pbp(game_id = '0022201086', version = "v2")

y <- c("0022201086", "0022200021")

nba_pbps(game_ids = y)
nba_pbps(game_ids = y, version = "v2")

 nba_live_pbp(game_id = '0022201086')

 nba_live_boxscore(game_id = "0022201086")

See also

Other NBA PBP Functions: nba_data_pbp(), nba_schedule()

Other NBA Live Functions: nba_schedule()

Other NBA Boxscore Functions: nba_boxscoretraditionalv2(), nba_boxscoretraditionalv3()

Author

Saiem Gilani

Jason Lee