Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bref_scraper-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bref_scraper-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

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

Hashes for bref_scraper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ea0102e146b49edad30462b44c5d6c4fd6803e66da8c92bbb3715db699808d0c
MD5 13e8778f95271c474dfc21cecda4c7a1
BLAKE2b-256 56ff7fdc752d5943b9d0e755acb8a1589f16486d3bd45d193cc3ac152644743e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bref_scraper-0.1.0.tar.gz:

Publisher: publish.yml on jithenms/bref_scraper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for bref_scraper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac8770e7e6242209deb9c38fc866ac873ea792b120bd5930ae3cf277a0e0e4f9
MD5 4a3980c4f2578af4e621cb3f5549154e
BLAKE2b-256 65e6f94300d02cea8dd114bc09b4a8ad33c258d89bf86ae5bfd7f6cb427a21ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for bref_scraper-0.1.0-py3-none-any.whl:

Publisher: publish.yml on jithenms/bref_scraper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page