bref-scraper is a Python package for scraping structured NBA data from Basketball Reference. It provides tools to retrieve player game logs, playoff statistics, and team rosters programmatically using requests and BeautifulSoup.
- ✅ Fetch last 5 games for any NBA player
- ✅ Extract full team rosters for a given year
- ✅ Retrieve playoff series stats per player (all years)
- ✅ Pull detailed playoff game logs by year
- ✅ Handles dynamic tables embedded in comments (e.g.,
#all_playoffs_series) - ✅ Cleans and formats HTML tables into structured Python dictionaries
- ✅ Output is pandas-friendly (
list[dict])
pip install bref-scraperfrom bref_scraper.players import get_last_5_games
import pandas as pd
games = get_last_5_games("jamesle01") # LeBron James
df = pd.DataFrame(games)
print(df[["date", "pts", "ast", "trb"]])Returns the last 5 regular season games for a player as a list of dicts.
Returns per-series playoff stats for all available years.
Returns per-game playoff stats for a given year.
Returns the full roster of a team for a given season, including player IDs.
pytestMIT License © 2025 Jithen Shriyan