A free sports API written for python
Project description
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.
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 Distributions
Hashes for sportsreference-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b325f9a5bcf2847b73b2cf26830a66fa88ec9e55e3f7760a172389fa036d128 |
|
MD5 | 0e4ac052a231636f9aa235827fc7584a |
|
BLAKE2b-256 | 3923e503fc75e8d141ee9f551924dddfeacb288cfe0efdf1bd260303779f7f4c |
Hashes for sportsreference-0.1.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ea0ac74b7a1d46f9369ca8d59921ca379b2f4b0e873f66a44035ae26e4d759e |
|
MD5 | a63aa6dde7512261ea9d0afc372b7c55 |
|
BLAKE2b-256 | ea8e7becdebc22bfc96fa5390fe2b455581d8c6f9fcc3b554eb55adc08068629 |