GithubHelp home page GithubHelp logo

johnwmillr / sportradarapis Goto Github PK

View Code? Open in Web Editor NEW
47.0 6.0 17.0 99 KB

Python wrapper for the Sportradar APIs โšฝ๏ธ๐Ÿˆ

License: MIT License

Python 100.00%
api sports sports-stats sportradar api-wrapper sportsanalytics nba nfl soccer data-mining

sportradarapis's Introduction

Sportradar APIs


Build Status PyPI version Python version

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.

Supported APIs

Sport API Wrapper Unit Tests
Soccer โšฝ โœ”๏ธ โœ”๏ธ
NBA ๐Ÿ€ โœ”๏ธ โœ”๏ธ
WNBA ๐Ÿ€ โœ”๏ธ โœ”๏ธ
NCAAMB ๐Ÿ€ โœ”๏ธ โœ”๏ธ
NFL ๐Ÿˆ โœ”๏ธ โœ”๏ธ
NHL ๐Ÿ† โœ”๏ธ โœ”๏ธ
Tennis ๐ŸŽพ โœ”๏ธ โœ”๏ธ
MLB โšพ โœ”๏ธ โœ”๏ธ
Darts ๐ŸŽฏ โœ”๏ธ โœ”๏ธ
Beach volleyball ๐ŸŒด โœ”๏ธ โœ”๏ธ
Golf โ›ณ โœ”๏ธ โœ”๏ธ
NASCAR ๐Ÿš— โœ”๏ธ โœ”๏ธ
LoL ๐ŸŽฎ โœ”๏ธ โœ”๏ธ
Dota2 ๐ŸŽฎ โœ”๏ธ โœ”๏ธ
Cricket ๐Ÿฆ— โœ”๏ธ โœ”๏ธ
Rugby ๐Ÿ‰ โœ”๏ธ โœ”๏ธ
Handball ๐Ÿคพ โœ”๏ธ โœ”๏ธ

Installation

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:

  1. Clone this repo: $git clone https://github.com/johnwmillr/SportradarAPIs.git
  2. Enter the cloned directory: $cd SportradarAPIs
  3. Install: $python setup.py install

Usage

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.")

Example projects

sportradarapis's People

Contributors

connerphillis avatar dependabot[bot] avatar johnwmillr avatar mad4ms avatar scrambldchannel avatar skoudoro avatar terefds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sportradarapis's Issues

JSON Decoder Error while testing the Sportradar Soccer example

Hi,

I was trying to reproduce the provided example on github but I'm getting JSON Decoder error. I tried to backtrack the issue and it seems like its not passing the API key correctly.

Can you please help me fixing this.

Following is the error I'm getting:

soccer-t3/intl/en/tournaments
http://api.sportradar.us/soccer-t3/intl/en/tournaments.json
Traceback (most recent call last):
File "/Users/qasimali/PycharmProjects/sportradar/main.py", line 23, in
tournaments = sr.get_tournaments().json()
File "/Users/qasimali/PycharmProjects/sportradar/venv/lib/python3.9/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Add support to Motorsport API

Is your feature request related to a problem? Please describe.
As user, It'd be nice to have support for Motorsport SportRadar API

Describe the solution you'd like
Implement new Motorsport API wrapper.

Describe alternatives you've considered
Creating a new API Class for Motorsport.

Additional context
N/A

Add support for soccer push APIs

Is your feature request related to a problem? Please describe.
No. I just need support for the push API.

Describe the solution you'd like
Implement push APIs from Soccer V3.

Describe alternatives you've considered
Writing a subclass of Soccer.

Additional context
None.

Getting a player ID

Is there a way to get a player ID from their name only? I haven't been able to figure out a way to do so.

Add support for Formula 1 API

Is your feature request related to a problem? Please describe.
It'd be nice to have support for Formula 1 SportRadar API

Describe the solution you'd like
Implement new Formula 1 API Wrapper.

Describe alternatives you've considered
Creating a new API Class for Formula 1.

Additional context
N/A

Add a data saving option

It would be convenient to have a built-in option for saving data to a JSON or XML file. The method will probably go inside the base API class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.