A thin wrapper around the pbpstats API’s “get-possessions” endpoint.
Usage
get_possessions(
league = "nba",
season,
season_type = "Regular Season",
team_id,
filter_comparison,
filter_event,
filter_value,
off_def,
start_type,
leverage,
period = NULL,
from_margin = NULL,
to_margin = NULL,
from_time = NULL,
to_time = NULL,
event_type = NULL,
event_player_id = NULL,
reb_player_id = NULL,
shooter_player_id = NULL
)
Arguments
- league
Character. Which league to query; e.g.,
"nba"
or"wnba"
; defaults to"nba"
.- season
Character or integer. The season to query; e.g.
"2024-25"
.- season_type
Character. One of:
"Regular Season"
"Playoffs"
"PlayIn"
"All"
; defaults to
"Regular Season"
.- team_id
Integer or character. The pbpstats ID of the team.
- filter_comparison
Character. One of:
"Exactly"
"GreaterThan"
"LessThan"
.
- filter_event
Character. One of:
"OnFloor"
"OffFloor"
"PlayedInGame"
"DidNotPlayInGame"
"Started"
"CameOffBench"
.
- filter_value
Numeric or character. The value to filter with the specified comparison and event.
- off_def
Character. One of:
"Offense"
"Defense"
.
- start_type
Character. The event that started the possession; see endpoint docs for available values.
- leverage
Character. One or more of:
"VeryLow"
"Low"
"Medium"
"High"
"VeryHigh"
; comma-separated for multiple values. Defaults to
NULL
.- period
Character or integer. One of:
"All"
"1"
"2"
"3"
"4"
"SecondHalf"
; defaults to
NULL
(all periods).- from_margin
Numeric. Optional starting point margin for possessions; defaults to
NULL
.- to_margin
Numeric. Optional ending point margin for possessions; defaults to
NULL
.- from_time
Integer. Optional seconds remaining at the start of a possession; defaults to
NULL
.- to_time
Integer. Optional seconds remaining at the end of a possession; defaults to
NULL
.- event_type
Character. Optional event type filter; one of:
"FG3A"
"FG2A"
"Oreb"
; defaults to
NULL
.- event_player_id
Integer or character. Optional pbpstats ID for the event player; defaults to
NULL
.- reb_player_id
Integer or character. Optional pbpstats ID for the rebounder; defaults to
NULL
.- shooter_player_id
Integer or character. Optional pbpstats ID for the shooter; defaults to
NULL
.
References
Darryl Blackport (2020). PBPStats API, MIT License. https://api.pbpstats.com/docs