Skip to main content

basketball_reference_scraper

Basketball Reference is a resource to aggregate statistics on NBA teams, seasons, players, and games. This package provides methods to acquire data for all these categories in pre-parsed and simplified formats.

Installing

Via pip

I wrote this library as an exercise for creating my first PyPi package. Hopefully, you find it easy to use. Install using the following command:

pip install basketball-reference-scraper

Via GitHub

Alternatively, you can just clone this repo and import the libraries at your own discretion.

Selenium

This package can also capture dynamically rendered content that is being added to the page via JavaScript, rather than baked into the HTML. To achieve this, it uses Python Selenium. Please refer to their installation instructions and ensure you have Chrome webdriver installed in and in your PATH variable.

Wait, don't scrapers like this already exist?

Yes, scrapers and APIs do exist. The primary API used currently is for stats.nba.com, but the website blocks too many requests, hindering those who want to acquire a lot of data. Additionally, scrapers for Basketball Reference do exist, but none of them load dynamically rendered content. These scrapers can only acquire statically loaded content, preventing those who want statistics in certain formats (for example, Player Advanced Stats Per Game).

Most of the scrapers use outdated methodologies of scraping from 'https://widgets.sports-reference.com/'. This is outdated and Basketball Reference no longer acquires their data from there. Additionally, Sports Reference recently instituted a rate limiter preventing users from making an excess of 20 requests/minute. This package abstracts the waiting logic to ensure you never hit this threshold.

API

Currently, the package contains 5 modules: teams, players, seasons, box_scores, pbp, shot_charts, and injury_report. The package will be expanding to include other content as well, but this is a start.

For full details on the API please refer to the documentation.

Release files for basketball-reference-scraper 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for basketball-reference-scraper 2.0.0
File Size Uploaded
basketball_reference_scraper-2.0.0.tar.gz 46.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for basketball-reference-scraper 2.0.0
File Interpreter ABI Platform
basketball_reference_scraper-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 98.6 kB

Release files / basketball_reference_scraper-2.0.0.tar.gz

Download URL basketball_reference_scraper-2.0.0.tar.gz
Size 46.7 kB
Tags Source
SHA-256 checksum
How to use checksums
64465aae00f77c73ca2940d810e9311a091b6335fac63b467417c55a33b5674a
BLAKE2b-256 checksum
How to use checksums
1955e47c7b646366359413bcd798962a2aa6629cf9404c12e01cc69fc4cce4aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.18

Release files / basketball_reference_scraper-2.0.0-py3-none-any.whl

Download URL basketball_reference_scraper-2.0.0-py3-none-any.whl
Size 51.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6567096ce632a645f36f8956230b93814d16dd1339710be74eb952428e0c2ab5
BLAKE2b-256 checksum
How to use checksums
bd874ccef2cf6882d1e62ea4c901725250fc5c61400604053ab9cc72a511c509
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.8.18

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.31

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.25

2 release files

1.0.24

1 release file

1.0.23

1 release file

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page