An R package that documents the NBA API, providing functions to pull data from stats.nba.com.
Disclaimer: This R package is in no way affiliated with the NBA.
This package is not available on CRAN and needs to be installed from this GitHub repository. To do this you need to run the following:
devtools::install_github("imadmali/NBAapi")
The functions to pull data have the get_*
naming convention. For example if we want to access shot chart data from the "shot chart detail" endpoint we can use get_shotchart(...)
(use the documentation to understand the appropriate arguments). Similarly, if we want play-by-play data we can use the get_pbp(...)
function.
- Box Scores (boxscoretraditionalv2, boxscorescoringv2)
- Play by Play (playbyplay, playbyplayv2)
- Shot Charts (shotchartdetail)
- Draft Combine
- Player Info (commonallplayers, commonteamroster)
- Team Info (commonTeamYears)
- Player/team ID/maps
- Graphics for shot charts (scatter, hex, heat, lattice)
- Light unit tests
- ...
Details on some of the active (and seemingly inactive) endpoints are available here.