This is a Python wrapper for the sports APIs provided by Sportradar. You'll need to sign up for an API key to use the service. Sportradar provides a free trial evaluation that provides 1,000 API queries at up to 1 query per second.
Sport | API Wrapper | Unit Tests |
---|---|---|
Soccer โฝ | โ๏ธ | โ๏ธ |
NBA ๐ | โ๏ธ | โ๏ธ |
WNBA ๐ | โ๏ธ | โ๏ธ |
NCAAMB ๐ | โ๏ธ | โ๏ธ |
NFL ๐ | โ๏ธ | โ๏ธ |
NHL ๐ | โ๏ธ | โ๏ธ |
Tennis ๐พ | โ๏ธ | โ๏ธ |
MLB โพ | โ๏ธ | โ๏ธ |
Darts ๐ฏ | โ๏ธ | โ๏ธ |
Beach volleyball ๐ด | โ๏ธ | โ๏ธ |
Golf โณ | โ๏ธ | โ๏ธ |
NASCAR ๐ | โ๏ธ | โ๏ธ |
LoL ๐ฎ | โ๏ธ | โ๏ธ |
Dota2 ๐ฎ | โ๏ธ | โ๏ธ |
Cricket ๐ฆ | โ๏ธ | โ๏ธ |
Rugby ๐ | โ๏ธ | โ๏ธ |
Handball ๐คพ | โ๏ธ | โ๏ธ |
The easiest way to start using this package is via PyPI using pip
:
$pip install sportradar
If you'd prefer to clone the repository and install the package manually, follow these steps:
- Clone this repo:
$git clone https://github.com/johnwmillr/SportradarAPIs.git
- Enter the cloned directory:
$cd SportradarAPIs
- Install:
$python setup.py install
Below is a brief demonstration of how to use the package to download data for the 2018 FIFA World Cup.
from sportradar import Soccer
# Create an instance of the Sportradar Soccer API class
sr = Soccer.Soccer("paste your api key here")
# Get a list of all tournaments
tournaments = sr.get_tournaments().json()
# Get info on the 2018 World Cup (Teams, Rounds, etc.)
worldcup = sr.get_tournament_info(tournaments['tournaments'][4]['id']).json()
# Get more information on each team in the World Cup
teams = []
team_counter = 0
for group in worldcup['groups']:
for team in group['teams']:
team_counter += 1
team_id = team['id']
team_name = team['name']
print("({}): {}, {}".format(team_counter, team_name, team_id))
try:
teams.append(sr.get_team_profile(team_id).json())
except Exception as e:
print("Error: {}".format(e))
time.sleep(5) # wait 5 seconds before next API call
# Save the team data to a .json file
print("Saving the data...", end="", flush=True)
with open("world_cup_team_data.json", "w") as outfile:
json.dump(teams, outfile)
print(" Done.")