Sportsreference: A free sports API written for python
Sportsreference is a free python API that pulls the stats from www.sports-reference.com and allows them to be easily be used in python-based applications, especially ones involving data analytics and machine learning.
Sportsreference exposes a plethora of sports information from major sports leagues in North America, such as the MLB, NBA, College Football and Basketball, NFL, and NHL. Every sport has its own set of valid API queries ranging from the list of teams in a league, to the date and time of a game, to the total number of wins a team has secured during the season, and many, many more metrics that paint a more detailed picture of how a team has performed during a game or throughout a season.
Examples
The following are a few examples showcasing how easy it can be to collect an abundance of metrics and information from all of the tracked leagues. The examples below are only a miniscule subset of the total number of statistics that can be pulled using sportsreference. Visit the documentation on Read The Docs for a complete list of all information exposed by the API.
Get instances of all NHL teams for the 2018 season
from sportsreference.nhl.teams import Teams
teams = Teams(2018)
Print every NBA team’s name and abbreviation
from sportsreference.nba.teams import Teams
teams = Teams()
for team in teams:
print(team.name, team.abbreviation)
Get a specific NFL team’s season information
from sportsreference.nfl.teams import Teams
teams = Teams()
lions = teams('DET')
Print the date of every game for a NCAA Men’s Basketball team
from sportsreference.ncaab.schedule import Schedule
purdue_schedule = Schedule('purdue')
for game in purdue_schedule:
print(game.date)
Print the number of interceptions by the away team in a NCAA Football game
from sportsreference.ncaaf.boxscore import Boxscore
championship_game = Boxscore('2018-01-08-georgia')
print(championship_game.away_interceptions)
Get a Pandas DataFrame of all stats for a MLB game
from sportsreference.mlb.boxscore import Boxscore
game = Boxscore('BOS201806070')
df = game.dataframe
Documentation
Complete documentation is hosted on readthedocs.org. Refer to the documentation for a full list of all metrics and information exposed by sportsreference. The documentation is auto-generated using Sphinx based on the docstrings in the sportsreference package.
Metadata
Release files for sportsreference 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sportsreference-0.1.1.tar.gz | 124.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sportsreference-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 337.4 kB
Release files / sportsreference-0.1.1.tar.gz
| Download URL | sportsreference-0.1.1.tar.gz |
|---|---|
| Size | 124.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
741f4f78a686dfe39f70e4c67babc760c9f590be6fead84c68d98843efcee326
|
|
BLAKE2b-256 checksum How to use checksums |
67d25498d71251bf02d78949f1e4f6326b883cbac861fb40bb666daab91a82cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|
Release files / sportsreference-0.1.1-py2.py3-none-any.whl
| Download URL | sportsreference-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 212.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
07244f1ad542b9dc2d19bf23d87d9c8a893f322e285a181da06fb0c30528708e
|
|
BLAKE2b-256 checksum How to use checksums |
b723f787785d8fd2be6d5b57cf005e0ceefaca7429d5e87f9e207605f24b38a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
|
Security for sportsreference 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.