Skip to main content

An API for NBA data that is scraped from Basketball Reference

Project description

Basketball Reference Web Scraper
Basketball Reference is a great site (especially for a basketball stats nut like me), and hopefully they don't get too pissed off at me for creating this.

Basically, I created this repository as a utility for another project where I'm trying to estimate an NBA player's productivity as it relates to daily fantasy sports. For that project, I need box score and scheduling information, which is provided by this utility. Here's the PyPi package.

Installing via pip
* I wrote this library as an exercise for creating my first PyPi package. Hopefully this means that if you'd like to use this library, you can by simply downloading the package via pip like so:
* pip install basketball_reference_web_scraper

Getting Box Scores
There are two methods that return box scores for a given date:
Methods located in web_scrapers.py
* return_box_scores_for_date(date)
** Returns a list of Box Score objects
* return_json_encoded_box_scores_for_date(date)
** Returns a JSON object representation of a list of Box Score objects

Getting Season Schedule Information
There are also two methods that return scheduling information for a given season start year (note that the NBA season generally spans two calendar years):
Methods located in web_scrapers.py
* return_schedule(season_start_year)
** Returns a Schedule object
* return_json_encoded_schedule(season_start_year)
** Returns a JSON representation of a Schedule object

Methods located in web_scrapers.py

* return_player_season_statistics(season_start_year)
** Returns a list of Player Season Statistic objects
* return_json_encoded_player_season_statistics(season_start_year)
** Returns a JSON object representation of a list of all player season statistic totals for the given season

Writing to CSV
I also created utility methods that write box score and season data to csv. They are located in csv_writers.py.

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

basketball_reference_web_scraper-1.8.tar.gz (7.3 kB view details)

Uploaded Source

File details

Details for the file basketball_reference_web_scraper-1.8.tar.gz.

File metadata

File hashes

Hashes for basketball_reference_web_scraper-1.8.tar.gz
Algorithm Hash digest
SHA256 b2bb5c22f685fd366feca9f450afad0c2616d7733d12e0930e9939067dbf7041
MD5 3a3d53cdae8159b8cd079c874ddd7172
BLAKE2b-256 79799cd6d94881318b8f46b1c486008d40ad5149a5a14fa0f89fe3b6b097f8d1

See more details on using hashes here.

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