Skip to contents

Introduction

This vignette demonstrates how to leverage FastBreakR’s thin wrappers around the pbpstats API, developed by Daryl Blackport. This wrapper provides easy access to every endpoint of the pbpstats API — including live game data, play-by-play, team stats, player stats, and more. FastBreakR is the only R package offering a complete pbpstats API wrapper covering all available endpoints.

See https://api.pbpstats.com/docs for more info.

Load FastBreakR

# install.packages("remotes")
remotes::install_github("JesseKartes/FastBreakR", quiet = TRUE)

library(FastBreakR)
library(tibble, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)

Get Career Stats for Teams/Players/Lineups

This thin wrapper make it easy to fetch comprehensive career statistics for any team, player, or lineup. This is particularly useful for building historical performance summaries or benchmarking entities against league averages.

# Fetch career stats for Tyrese Haliburton
season_stats <- get_all_season_stats(entity_type = "Player", entity_id = "1630169")

# View Hali's regular season career stats
player_stats <- tibble(season_stats$results$`Regular Season`) %>%
  select(Season, GamesPlayed, PlusMinus, Points, FG3M)

knitr::kable(player_stats, caption = paste('Tyrese Haliburton Career Stats'))
Tyrese Haliburton Career Stats
Season GamesPlayed PlusMinus Points FG3M
2020-21 58 -179 753 121
2021-22 26 -101 454 57
2021-22 51 -225 727 104
2021-22 77 -326 1181 161
2022-23 56 -35 1160 161
2023-24 69 294 1389 195
2024-25 73 222 1359 218

Get Players Stats for Specific Lineups

Lineup analytics allow you to isolate the impact of specific player combinations. The snippet below retrieves stats for the 2024–25 Knicks playoff starting five, ideal for lineup evaluation or opponent scouting.

# Knicks Playoffs Starters
knicks_playoffs <- get_lineup_player_stats(
  season = "2024-25",
  season_type = "Playoffs",
  lineup_id = "1626157-1628384-1628404-1628969-1628973"
)

knicks_stats <- tibble(knicks_playoffs$multi_row_table_data) %>%
  select(Name, Minutes, PlusMinus, Points, FtPoints)

knitr::kable(knicks_stats, caption = '2024-25 Knicks Playoffs Starters')
2024-25 Knicks Playoffs Starters
Name Minutes PlusMinus Points FtPoints
Karl-Anthony Towns 335 -31 183 31
OG Anunoby 335 -31 108 12
Josh Hart 335 -31 100 27
Mikal Bridges 335 -31 113 5
Jalen Brunson 335 -31 236 59

Live Team and Player Stats

For live updates and streaming dashboards, pbpstats wrappers seamlessly pull in-game metrics. Here’s how to grab team-level live data from Game One of the 2024-25 NBA Finals.

# Game One 2024-25 NBA finals Live Stats
live_game <- get_live_game(game_id = "0042400401", result_type = "team")

live_stats <- head(live_game$game_data$rows, 10)

knitr::kable(live_stats, caption = paste('NBA Finals Game One'))
NBA Finals Game One
stat home visitor
Points 110 111
Possessions 102 101
Seconds Per Possession 14.186 14.188
Offensive Rating 107.843 109.901
True Shot Attempts 109 92
Shot Quality 0.556 0.533
eFG% 0.454 0.585
TS% 0.505 0.603
2pt FG% 0.412 (28/68) 0.488 (21/43)
3pt FG% 0.367 (11/30) 0.462 (18/39)

Conclusion

In this vignette, we showcased FastBreakR’s pbpstats API wrapper across three simple use cases:

  • Historical Career Analysis: Pull full career statistics for players, teams, or lineups to create performance summaries.
  • Lineup-Specific Metrics: Evaluate the impact of specific player combinations.
  • Real-Time Live Data: Integrate in-game team and player stats into dashboards or live analytics reports.

This is just a small glimpse of what’s possible with the pbpstats API. FastBreakR is the only R package with full pbpstats integration—bringing powerful, customizable NBA analytics to your workflow.