A Python scraper for stats and box scores from Basketball Reference
Project description
bref-scraper
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.
🚀 Features
- ✅ 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])
📦 Installation
pip install bref-scraper
🧠 Quick Usage
from 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"]])
📘 API Reference
🏀 players.py
get_last_5_games(player_id: str) -> list
Returns the last 5 regular season games for a player as a list of dicts.
get_playoff_series_stats(player_id: str) -> list
Returns per-series playoff stats for all available years.
get_playoff_game_log(player_id: str, year: int) -> list
Returns per-game playoff stats for a given year.
🏀 teams.py
get_roster(team_abbr: str, year: int) -> list
Returns the full roster of a team for a given season, including player IDs.
🧪 Running Tests
pytest
📜 License
MIT License © 2025 Jithen Shriyan
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bref_scraper-0.1.0.tar.gz.
File metadata
- Download URL: bref_scraper-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea0102e146b49edad30462b44c5d6c4fd6803e66da8c92bbb3715db699808d0c
|
|
| MD5 |
13e8778f95271c474dfc21cecda4c7a1
|
|
| BLAKE2b-256 |
56ff7fdc752d5943b9d0e755acb8a1589f16486d3bd45d193cc3ac152644743e
|
Provenance
The following attestation bundles were made for bref_scraper-0.1.0.tar.gz:
Publisher:
publish.yml on jithenms/bref_scraper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bref_scraper-0.1.0.tar.gz -
Subject digest:
ea0102e146b49edad30462b44c5d6c4fd6803e66da8c92bbb3715db699808d0c - Sigstore transparency entry: 220060417
- Sigstore integration time:
-
Permalink:
jithenms/bref_scraper@f3f8de9fb2dc6ce92eea136372ea7f269f0ae38a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jithenms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3f8de9fb2dc6ce92eea136372ea7f269f0ae38a -
Trigger Event:
release
-
Statement type:
File details
Details for the file bref_scraper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bref_scraper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac8770e7e6242209deb9c38fc866ac873ea792b120bd5930ae3cf277a0e0e4f9
|
|
| MD5 |
4a3980c4f2578af4e621cb3f5549154e
|
|
| BLAKE2b-256 |
65e6f94300d02cea8dd114bc09b4a8ad33c258d89bf86ae5bfd7f6cb427a21ac
|
Provenance
The following attestation bundles were made for bref_scraper-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on jithenms/bref_scraper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bref_scraper-0.1.0-py3-none-any.whl -
Subject digest:
ac8770e7e6242209deb9c38fc866ac873ea792b120bd5930ae3cf277a0e0e4f9 - Sigstore transparency entry: 220060418
- Sigstore integration time:
-
Permalink:
jithenms/bref_scraper@f3f8de9fb2dc6ce92eea136372ea7f269f0ae38a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jithenms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3f8de9fb2dc6ce92eea136372ea7f269f0ae38a -
Trigger Event:
release
-
Statement type: