Automatically generate new Python files from Sportradar API info page



In [1]:
import time
import json
import re
from selenium import webdriver

Start the Selenium browser (Chrome)


In [438]:
# Start a new instance of Chrome
url = "https://developer.sportradar.com/io-docs"
browser = webdriver.Chrome()
browser.get(url)

Get the method names and descriptions for a given API


In [440]:
def getEndpointInfo():
    """Return a list with info on each endpoint listed on the Sportradar API info page.
    The method will only return info on an API that is currently displayed on page.
    """
    list_of_endpoints = browser.find_elements_by_class_name('endpointList')
    for n,item in enumerate(list_of_endpoints):
        eps = item.find_element_by_class_name('endpoint')
        title = eps.find_element_by_class_name('title')

        name = title.find_element_by_class_name('name')
        if name.text != "":
            print(name.text + '\n'+str(n))

            # Expand all endpoint descriptions.
            actions = title.find_element_by_class_name('actions')
            expand = actions.find_element_by_class_name('expand-methods')
            expand.click()
            time.sleep(0.5)

            # Scrape the GET method names, URIs, and descriptions
            endpoints = []
            method_list = eps.find_element_by_class_name("methods")
            methods = method_list.find_elements_by_class_name('method')
            for method in methods:
                m = method.find_element_by_class_name('title')

                # Get the name of and URI for the current endpoint
                name = m.find_element_by_class_name('name').text
                uri = m.find_element_by_class_name('uri').text

                # Get the endpoint's description 
                h = method.find_element_by_class_name('hidden')
                d = method.find_element_by_class_name('description')    
                p = d.find_element_by_tag_name('p')
                description = p.text    
                                
                # Get default values for the parameters for each method (for tests)
                table_items = h.find_elements_by_class_name('type-pathReplace')
                param_names, param_values = [], []
                for t in table_items[:-1]:
                    param_name = t.find_element_by_class_name('name')
                    p_name = param_name.get_attribute('textContent').strip().split(':',1)[-1]
                    param_names.append(p_name)
                    if p_name in ['year', 'month', 'day']:
                        options = t.find_elements_by_tag_name('option')
                        for o in options:
                            if o.get_property('selected'):
                                param_values.append(o.get_property('value'))                                
                    else:                        
                        try:
                            options = t.find_elements_by_tag_name('option')
                            param_values.append(t.find_elements_by_tag_name('option')[-1].get_property('value'))                     
                        except:
                            param_values.append(t.find_elements_by_tag_name('input')[-1].get_property('value'))

                default_params = dict(zip(param_names, param_values))
                
                endpoints.append({'name':name, 'uri': uri,
                      'description': description, 'defaults': default_params})
                print('-'*20)
                print(default_params)                
                print('{n}: {u}\n{d}'.format(n=name, u=uri, d=description))        
                
    return endpoints

Get information on all possible APIs provided by Sportradar


In [441]:
api_names_to_scrape = ['Beach Volleyball Trial', 'Darts Trial', 'eSports Dota 2 Trial', 'Global Basketball Trial', 'Global Ice Hockey Trial', 'Golf Trial', 'eSports LoL Trial', 'MLB v6.5 Trial', 'NASCAR Official Trial', 'NBA Official Trial', 'NFL Official Trial v2', 'NHL Official Trial', 'Rugby v2 API', 'Soccer EU Trial v3', 'Tennis v2 Trial', 'WNBA Trial']

In [442]:
services = browser.find_element_by_class_name("services")

# Names of the APIs
api_selector = services.find_element_by_tag_name('h2')
selector = api_selector.find_element_by_tag_name('select')
options = selector.find_elements_by_tag_name('option')[1:]

# Descriptions of the APIs
api_elems = services.find_elements_by_class_name('apiDescriptionList')

# Extract the names and descriptions of the desired APIs
apis = []
for api, option in zip(api_elems, options):
    name = option.text    
    
    if name in api_names_to_scrape:
        description = api.get_attribute('textContent').strip()
        print("-----------\n{n}: {d}".format(n=name, d=description))
        option.click() # Select the API, changing the displayed methods
        time.sleep(1)
        
        # Extract the endpoint names and descriptions for the current API
        endpoint_info = getEndpointInfo()     
        apis.append({'name': name, 'description': description, 'endpoints': endpoint_info})

# Save the API information
filename = 'api_names_and_endpoints'
with open(filename + '.json', 'w') as outfile:
    json.dump(apis, outfile)


-----------
Beach Volleyball Trial: Sportradar's Beach Volleyball API
Beach Volleyball
15
--------------------
{'competitor_id': 'sr:competitor:151994'}
Competitor Profile: volleyball-t1/beach/en/competitors/:competitor_id/profile:format
Provides information for a given competitor
--------------------
{'competitor_id': 'sr:competitor:151994'}
Competitor Results: volleyball-t1/beach/en/competitors/:competitor_id/results:format
Provides past match results for a given competitor
--------------------
{'competitor_id': 'sr:competitor:151994'}
Competitor Schedule: volleyball-t1/beach/en/competitors/:competitor_id/schedule:format
Provides the schedule for a given competitor
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Results: volleyball-t1/beach/en/schedules/:year-:month-:day/results:format
Provides the match scoring for all matches played on a given day
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: volleyball-t1/beach/en/schedules/:year-:month-:day/schedule:format
Provides the schedule for all matches played on a given day
--------------------
{'competitor_id1': 'sr:competitor:151994', 'competitor_id2': 'sr:competitor:128398'}
Head to Head: volleyball-t1/beach/en/competitors/:competitor_id1/versus/:competitor_id2/matches:format
Provides team versus team data
--------------------
{}
Live Schedule: volleyball-t1/beach/en/schedules/live/schedule:format
Provides a list of matches in progress
--------------------
{'match_id': ''}
Sport Event Probabilities: volleyball-t1/beach/en/sport_events/:match_id/probabilities:format
Provides probabilities for a given match; prematch only
--------------------
{'match_id': 'sr:match:9803091'}
Sport Event Timeline: volleyball-t1/beach/en/sport_events/:match_id/timeline:format
Provides detailed information for a given match
--------------------
{'tournament_id': 'sr:tournament:552'}
Tournament Info: volleyball-t1/beach/en/tournaments/:tournament_id/info:format
Provides a list of Competitors from a given Tournament
--------------------
{}
Tournament List: volleyball-t1/beach/en/tournaments:format
Provides a list of all tournaments
--------------------
{'tournament_id': 'sr:tournament:552'}
Live Standings: volleyball-t1/beach/en/tournaments/:tournament_id/live_standings:format
Provides the live standings for a given Tournament
--------------------
{'tournament_id': 'sr:tournament:551'}
Seasons: volleyball-t1/beach/en/tournaments/:tournament_id/seasons:format
Provides the seasons for a given Tournament
--------------------
{'tournament_id': 'sr:tournament:552'}
Tournament Results: volleyball-t1/beach/en/tournaments/:tournament_id/results:format
Provides the results for a given tournament
--------------------
{'tournament_id': 'sr:tournament:552'}
Tournament Schedule: volleyball-t1/beach/en/tournaments/:tournament_id/schedule:format
Provides the schedule for a given Tournament
--------------------
{'tournament_id': 'sr:tournament:552'}
Tournament Standings: volleyball-t1/beach/en/tournaments/:tournament_id/standings:format
Provides the standings for a given Tournament
-----------
Darts Trial: Sportradar's Darts API
Darts
21
--------------------
{'competitor_id': 'sr:competitor:26280'}
Competitor Profile: darts-t1/en/competitors/:competitor_id/profile:format
Provides information for a given competitor
--------------------
{'competitor_id': 'sr:competitor:26280'}
Competitor Results: darts-t1/en/competitors/:competitor_id/results:format
Provides past match results for a given competitor
--------------------
{'competitor_id': 'sr:competitor:26280'}
Competitor Schedule: darts-t1/en/competitors/:competitor_id/schedule:format
Provides the schedule for a given competitor
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Results: darts-t1/en/schedules/:year-:month-:day/results:format
Provides the match scoring for all matches played on a given day
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: darts-t1/en/schedules/:year-:month-:day/schedule:format
Provides the schedule for all matches played on a given day
--------------------
{'competitor_id1': 'sr:competitor:208784', 'competitor_id2': 'sr:competitor:301456'}
Head to Head: darts-t1/en//competitors/:competitor_id1/versus/:competitor_id2/matches:format
Provides team versus team data
--------------------
{}
Live Schedule: darts-t1/en/schedules/live/schedule:format
Provides a list of matches in progress
--------------------
{'tournament_id': 'sr:tournament:597'}
Seasons: darts-t1/en/tournaments/:tournament_id/seasons:format
Provides the seasons for a given Tournament
--------------------
{'match_id': ''}
Sport Event Probabilities: darts-t1/en/sport_events/:match_id/probabilities:format
Provides probabilities for a given match; prematch only
--------------------
{'match_id': 'sr:match:10653440'}
Sport Event Timeline: darts-t1/en/sport_events/:match_id/timeline:format
Provides detailed information for a given match
--------------------
{'tournament_id': 'sr:tournament:774'}
Tournament Info: darts-t1/en/tournaments/:tournament_id/info:format
Provides a list of Competitors from a given Tournament
--------------------
{}
Tournament List: darts-t1/en/tournaments:format
Provides a list of all tournaments
--------------------
{'tournament_id': 'sr:tournament:774'}
Tournament Live Standings: darts-t1/en/tournaments/:tournament_id/live_standings:format
Provides the live standings for a given Tournament
--------------------
{'tournament_id': 'sr:tournament:774'}
Tournament Results: darts-t1/en/tournaments/:tournament_id/results:format
Provides the results for a given tournament
--------------------
{'tournament_id': 'sr:tournament:774'}
Tournament Schedule: darts-t1/en/tournaments/:tournament_id/schedule:format
Provides the schedule for a given Tournament
--------------------
{'tournament_id': 'sr:tournament:774'}
Tournament Standings: darts-t1/en/tournaments/:tournament_id/standings:format
Provides the standings for a given Tournament
-----------
eSports Dota 2 Trial: Sportradar's Dota 2 API
Dota 2 Version 1
22
--------------------
{'sport': 'dota2', 'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Results: :sport-t1/:language_code/schedules/:year-:month-:day/results:format
Provides the match scoring for all matches played on a given day
--------------------
{'sport': 'dota2', 'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: :sport-t1/:language_code/schedules/:year-:month-:day/schedule:format
Provides the schedule for all matches played on a given day
--------------------
{'sport': 'dota2', 'language_code': 'en'}
Deleted Matches: :sport-t1/:language_code/schedules/deleted_matches:format
Provides information for matches which have been removed from the schedule
--------------------
{'sport': 'dota2', 'language_code': 'en', 'team_id_1': 'sr:competitor:247431', 'team_id_2': 'sr:competitor:242738'}
Head-2-Head: :sport-t1/:language_code/teams/:team_id_1/versus/:team_id_2/matches:format
Provides team vs team match data
--------------------
{'sport': 'dota2', 'language_code': 'en', 'match_id': 'sr:match:12206428'}
Match Lineups: :sport-t1/:language_code/matches/:match_id/lineups:format
Provides match lineup data for a given match
--------------------
{'sport': 'dota2', 'language_code': 'en', 'match_id': 'sr:match:9824725'}
Match Probabilities: :sport-t1/:language_code/matches/:match_id/probabilities:format
Provides pre-match probabilities for a given match
--------------------
{'sport': 'dota2', 'language_code': 'en', 'match_id': 'sr:match:12206428'}
Match Summary: :sport-t1/:language_code/matches/:match_id/summary:format
Provides match summary data for a given match
--------------------
{'sport': 'dota2', 'language_code': 'en', 'player_id': 'sr:player:971065'}
Player Profile: :sport-t1/:language_code/players/:player_id/profile:format
Provides the Player profile information for a given player
--------------------
{'sport': 'dota2', 'language_code': 'en', 'team_id': 'sr:competitor:247431'}
Team Profile: :sport-t1/:language_code/teams/:team_id/profile:format
Provides the profile information for a given team
--------------------
{'sport': 'dota2', 'language_code': 'en', 'team_id': 'sr:competitor:247431'}
Team Results: :sport-t1/:language_code/teams/:team_id/results:format
Provides the results for a given team
--------------------
{'sport': 'dota2', 'language_code': 'en', 'team_id': 'sr:competitor:247431'}
Team Schedule: :sport-t1/:language_code/teams/:team_id/schedule:format
Provides the schedule for a given team
--------------------
{'sport': 'dota2', 'language_code': 'en', 'tournament_id': 'sr:tournament:14029'}
Tournament Info: :sport-t1/:language_code/tournaments/:tournament_id/info:format
Provides information for dota2 tournaments
--------------------
{'sport': 'dota2', 'language_code': 'en'}
Tournament Live Summary: :sport-t1/:language_code/schedules/live/summaries:format
Provides summary information for live Dota2 matches
--------------------
{'sport': 'dota2', 'language_code': 'en', 'tournament_id': 'sr:tournament:14029'}
Tournament Results: :sport-t1/:language_code/tournaments/:tournament_id/results:format
Provides information for dota2 tournaments
--------------------
{'sport': 'dota2', 'language_code': 'en', 'tournament_id': 'sr:tournament:14029'}
Tournament Schedule: :sport-t1/:language_code/tournaments/:tournament_id/schedule:format
Provides information for dota2 tournaments
--------------------
{'sport': 'dota2', 'language_code': 'en', 'tournament_id': 'sr:tournament:14029'}
Tournament Seasons: :sport-t1/:language_code/tournaments/:tournament_id/seasons:format
Provides information for Dota2 tournament seasons
--------------------
{'sport': 'dota2', 'language_code': 'en', 'tournament_id': 'sr:tournament:14029'}
Tournament Standings: :sport-t1/:language_code/tournaments/:tournament_id/standings:format
Provides standing information for a given tournament
--------------------
{'sport': 'dota2', 'language_code': 'en', 'tournament_id': 'sr:tournament:14029'}
Tournament Summary: :sport-t1/:language_code/tournaments/:tournament_id/summaries:format
Provides summary information for a given tournament
--------------------
{'sport': 'dota2', 'language_code': 'en'}
Tournaments: :sport-t1/:language_code/tournaments:format
Provides information for dota2 tournaments
-----------
Global Basketball Trial: Sportradar's Global Basketball API
Global Basketball
28
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Results: basketball-t1/en/schedules/:year-:month-:day/results:format
Provides game results for all games played on a given day
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: basketball-t1/en/schedules/:year-:month-:day/schedule:format
Provides the schedule for a given day
--------------------
{'competitor_id_1': 'sr:competitor:3432', 'competitor_id_2': 'sr:competitor:3415'}
Head to Head: basketball-t1/en/teams/:competitor_id_1/versus/:competitor_id_2/matches:format
Compares past results and upcoming games given two team IDs
--------------------
{'match_id': ''}
Match Probabilities: basketball-t1/en/matches/:match_id/probabilities:format
Provides pre-match probabilities
--------------------
{'match_id': 'sr:match:9954153'}
Match Summary: basketball-t1/en/matches/:match_id/summary:format
Provides summarized information for a match
--------------------
{'match_id': 'sr:match:9954153'}
Match Timeline: basketball-t1/en/matches/:match_id/timeline:format
Provides an events timeline for a match
--------------------
{'player_id': 'sr:player:852120'}
Player Profile: basketball-t1/en/players/:player_id/profile:format
Provides player information
--------------------
{'season_id': 'sr:season:33359'}
Seasons: basketball-t1/en/tournaments/:season_id/seasons:format
Provides a listing of seasons
--------------------
{'team_id': 'sr:competitor:3501'}
Team Profile: basketball-t1/en/teams/:team_id/profile:format
Provides information and stats for a team
--------------------
{'team_id': 'sr:competitor:3501'}
Team Results: basketball-t1/en/teams/:team_id/results:format
Provides a list of match results for a given team
--------------------
{'team_id': 'sr:competitor:3501'}
Team Schedule: basketball-t1/en/teams/:team_id/schedule:format
Provides a list of scheduled matches for a given team
--------------------
{'tournament_id': 'sr:tournament:132'}
Tournament Info: basketball-t1/en/tournaments/:tournament_id/info:format
Provides information pertaining to a given tournament/league
--------------------
{}
Tournament List: basketball-t1/en/tournaments:format
Provides a list of all tournaments
--------------------
{'tournament_id': 'sr:tournament:262'}
Tournament Live Standings: basketball-t1/en/tournaments/:tournament_id/live_standings:format
Provides live standings for a given tournament/league
--------------------
{'tournament_id': 'sr:tournament:132'}
Tournament Results: basketball-t1/en/tournaments/:tournament_id/results:format
Provides a list of results for a given tournament/league
--------------------
{'tournament_id': 'sr:tournament:262'}
Tournament Schedule: basketball-t1/en/tournaments/:tournament_id/schedule:format
Provides a list of scheduled games for a given tournament/league
--------------------
{'tournament_id': 'sr:tournament:262'}
Tournament Standings: basketball-t1/en/tournaments/:tournament_id/standings:format
Provides the current standings for a given tournament/league
-----------
Global Ice Hockey Trial: Sportradar's Global Ice Hockey API
Global Ice Hockey
29
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Results: hockey-t1/ice/en/schedules/:year-:month-:day/results:format
Provides match information and scoring, for all matches played on a given day
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: hockey-t1/ice/en/schedules/:year-:month-:day/schedule:format
Provides match information and scoring, for all matches played on a given day
--------------------
{'team_id_1': 'sr:competitor:119596', 'team_id_2': 'sr:competitor:119598'}
Head to Head: hockey-t1/ice/en/teams/:team_id_1/versus/:team_id_2/matches:format
Provides team vs team information, include scores over multiple games
--------------------
{'match_id': 'sr:match:10037289'}
Match Probabilities: hockey-t1/ice/en/matches/:match_id/probabilities:format
Provides the probability for a given match
--------------------
{'match_id': 'sr:match:10037289'}
Match Summary: hockey-t1/ice/en/matches/:match_id/summary:format
Provides the summary for a given match
--------------------
{'match_id': 'sr:match:10037289'}
Match Timeline: hockey-t1/ice/en/matches/:match_id/timeline:format
Provides the timeline for a given match
--------------------
{'tournament_id': 'sr:tournament:268'}
Seasons Information: hockey-t1/ice/en/tournaments/:tournament_id/seasons:format
Provides the seasons information for a tournament
--------------------
{'team_id': 'sr:competitor:6333'}
Team Profile: hockey-t1/ice/en/teams/:team_id/profile:format
Provides a team profile
--------------------
{'team_id': 'sr:competitor:6333'}
Team Results: hockey-t1/ice/en/teams/:team_id/results:format
Provides the results for a given team
--------------------
{'team_id': 'sr:competitor:6333'}
Team Schedule: hockey-t1/ice/en/teams/:team_id/schedule:format
Provides the schedule for a given team
--------------------
{'tournament_id': 'sr:tournament:844', 'team_id': 'sr:competitor:45159'}
Team Statistics: hockey-t1/ice/en/tournaments/:tournament_id/teams/:team_id/statistics:format
Provides the statistics for a given team
--------------------
{'tournament_id': 'sr:tournament:844'}
Tournament Info: hockey-t1/ice/en/tournaments/:tournament_id/info:format
Provides the information for a given tournament
--------------------
{'tournament_id': 'sr:tournament:225'}
Tournament Leaders: hockey-t1/ice/en/tournaments/:tournament_id/leaders:format
Provides the leaders for a given tournament
--------------------
{}
Tournament List: hockey-t1/ice/en/tournaments:format
Provides a list of all tournaments
--------------------
{'tournament_id': 'sr:tournament:225'}
Tournament Live Standings: hockey-t1/ice/en/tournaments/:tournament_id/live_standings:format
Provides the live standings for a given tournament
--------------------
{'tournament_id': 'sr:tournament:844'}
Tournament Results: hockey-t1/ice/en/tournaments/:tournament_id/results:format
Provides the results for a given tournament
--------------------
{'tournament_id': 'sr:tournament:844'}
Tournament Schedule: hockey-t1/ice/en/tournaments/:tournament_id/schedule:format
Provides the schedule for a given tournament
--------------------
{'tournament_id': 'sr:tournament:844'}
Tournament Standings: hockey-t1/ice/en/tournaments/:tournament_id/standings:format
Provides the standings for a given tournament
-----------
Golf Trial: Sportradar's Golf API
Golf
30
--------------------
{'golf_tour': 'lpga', 'year': '2018'}
Tournament Schedule: golf-t2/schedule/:golf_tour/:year/tournaments/schedule:format
Obtain the schedules for a given tour.
--------------------
{'golf_tour': 'lpga', 'year': '2012'}
Player Profiles: golf-t2/profiles/:golf_tour/:year/players/profiles:format
Obtain the profiles for a given year.
--------------------
{'golf_tour': 'lpga', 'year': '2017', 'tournament_id': 'b95ab96b-9a0b-4309-880a-ad063cb163ea'}
Tournament Summary: golf-t2/summary/:golf_tour/:year/tournaments/:tournament_id/summary:format
Obtain summary information for a given tournament.
--------------------
{'golf_tour': 'lpga', 'year': '2017', 'tournament_id': 'b95ab96b-9a0b-4309-880a-ad063cb163ea'}
Tournament Leaderboard: golf-t2/leaderboard/:golf_tour/:year/tournaments/:tournament_id/leaderboard:format
Obtain the leaderboard for a given tournament.
--------------------
{'golf_tour': 'lpga', 'year': '2017', 'tournament_id': 'b95ab96b-9a0b-4309-880a-ad063cb163ea'}
Tournament Hole Statistics: golf-t2/hole_stats/:golf_tour/:year/tournaments/:tournament_id/hole-statistics:format
Obtain the hole statistics for a given tournament.
--------------------
{'golf_tour': 'lpga', 'year': '2017', 'tournament_id': 'b95ab96b-9a0b-4309-880a-ad063cb163ea', 'round_number': '4'}
Tee Times Per Round: golf-t2/teetimes/:golf_tour/:year/tournaments/:tournament_id/rounds/:round_number/teetimes:format
Obtain the tee times for a given round.
--------------------
{'golf_tour': 'lpga', 'year': '2017', 'tournament_id': 'b95ab96b-9a0b-4309-880a-ad063cb163ea', 'round_number': '4'}
Scorecards Per Round: golf-t2/scorecards/:golf_tour/:year/tournaments/:tournament_id/rounds/:round_number/scores:format
Obtain the scores for a given round.
--------------------
{'golf_tour': 'lpga', 'year': '2017'}
Player Statistics: golf-t2/seasontd/:golf_tour/:year/players/statistics:format
Obtain statistics for each golfer.
--------------------
{'golf_tour': 'lpga', 'year': '2017', 'month': '06', 'day': '01'}
Daily Change Log: golf-t2/changelog/:golf_tour/:year/:month/:day/changes:format
Provides all changes related to player, tournaments, schedules, and statistics
--------------------
{'year': '2017'}
Official World Golf Rankings: golf-t2/players/wgr/:year/rankings:format
Obtain the World Golf Rankings.
-----------
eSports LoL Trial: Sportradar's LoL API
League of Legends Version 1
33
--------------------
{'sport': 'lol', 'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Results: :sport-t1/:language_code/schedules/:year-:month-:day/results:format
Provides the match scoring for all matches played on a given day
--------------------
{'sport': 'lol', 'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: :sport-t1/:language_code/schedules/:year-:month-:day/schedule:format
Provides the schedule for all matches played on a given day
--------------------
{'sport': 'lol', 'language_code': 'en'}
Deleted Matches: :sport-t1/:language_code/schedules/deleted_matches:format
Provides information for matches which have been removed from the schedule
--------------------
{'sport': 'lol', 'language_code': 'en', 'team_id_1': 'sr:competitor:240582', 'team_id_2': 'sr:competitor:240564'}
Head-2-Head: :sport-t1/:language_code/teams/:team_id_1/versus/:team_id_2/matches:format
Provides team vs team match data
--------------------
{'sport': 'lol', 'language_code': 'en', 'match_id': 'sr:match:11753058'}
Match Lineups: :sport-t1/:language_code/matches/:match_id/lineups:format
Provides match lineup data for a given match
--------------------
{'sport': 'lol', 'language_code': 'en', 'match_id': 'sr:match:9477497'}
Match Probabilities: :sport-t1/:language_code/matches/:match_id/probabilities:format
Provides pre-match probabilities for a given match
--------------------
{'sport': 'lol', 'language_code': 'en', 'match_id': 'sr:match:11753058'}
Match Summary: :sport-t1/:language_code/matches/:match_id/summary:format
Provides match summary data for a given match
--------------------
{'sport': 'lol', 'language_code': 'en', 'player_id': 'sr:player:949022'}
Player Profile: :sport-t1/:language_code/players/:player_id/profile:format
Provides the Player profile information for a given player
--------------------
{'sport': 'lol', 'language_code': 'en', 'team_id': 'sr:competitor:240582'}
Team Profile: :sport-t1/:language_code/teams/:team_id/profile:format
Provides the profile information for a given team
--------------------
{'sport': 'lol', 'language_code': 'en', 'team_id': 'sr:competitor:240582'}
Team Results: :sport-t1/:language_code/teams/:team_id/results:format
Provides the results for a given team
--------------------
{'sport': 'lol', 'language_code': 'en', 'team_id': 'sr:competitor:240582'}
Team Schedule: :sport-t1/:language_code/teams/:team_id/schedule:format
Provides the schedule for a given team
--------------------
{'sport': 'lol', 'language_code': 'en', 'tournament_id': 'sr:tournament:2450'}
Tournament Info: :sport-t1/:language_code/tournaments/:tournament_id/info:format
Provides information for lol tournaments
--------------------
{'sport': 'lol', 'language_code': 'en'}
Tournament Live Summary: :sport-t1/:language_code/schedules/live/summaries:format
Provides summary information for live LOL matches
--------------------
{'sport': 'lol', 'language_code': 'en', 'tournament_id': 'sr:tournament:2450'}
Tournament Results: :sport-t1/:language_code/tournaments/:tournament_id/results:format
Provides information for lol tournaments
--------------------
{'sport': 'lol', 'language_code': 'en', 'tournament_id': 'sr:tournament:2450'}
Tournament Schedule: :sport-t1/:language_code/tournaments/:tournament_id/schedule:format
Provides information for lol tournaments
--------------------
{'sport': 'lol', 'language_code': 'en', 'tournament_id': 'sr:tournament:2450'}
Tournament Seasons: :sport-t1/:language_code/tournaments/:tournament_id/seasons:format
Provides information for LOL tournament seasons
--------------------
{'sport': 'lol', 'language_code': 'en', 'tournament_id': 'sr:tournament:2450'}
Tournament Standings: :sport-t1/:language_code/tournaments/:tournament_id/standings:format
Provides standing information for a given tournament
--------------------
{'sport': 'lol', 'language_code': 'en', 'tournament_id': 'sr:tournament:2450'}
Tournament Summary: :sport-t1/:language_code/tournaments/:tournament_id/summaries:format
Provides summary information for a given tournament
--------------------
{'sport': 'lol', 'language_code': 'en'}
Tournaments: :sport-t1/:language_code/tournaments:format
Provides information for lol tournaments
-----------
MLB v6.5 Trial: Sportradar's MLB API
MLB
34
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Boxscore: mlb/trial/v6.5/en/games/:year/:month/:day/boxscore:format
Obtain Daily Boxscores for MLB for a given season. NOTE: The 2012 sample data is an abbreviated season.
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Change Log: mlb/trial/v6.5/en/league/:year/:month/:day/changes:format
Obtain changes made to previously closed events, team rosters, or player profiles for a given day.
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: mlb/trial/v6.5/en/games/:year/:month/:day/schedule:format
Obtain Schedule for the MLB for a given day. NOTE: The 2012 sample data is an abbreviated season.
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Summary: mlb/trial/v6.5/en/games/:year/:month/:day/summary:format
Obtain Daily Summary for the MLB for a given day. NOTE: The 2012 sample data is an abbreviated season.
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Transactions: mlb/trial/v6.5/en/league/:year/:month/:day/transactions:format
Obtain information concerning all transactions taking place on a given MLB defined day.
--------------------
{'event_id': 'b6f922df-46c6-483c-8d3b-4235a6fc4520'}
Game Boxscore: mlb/trial/v6.5/en/games/:event_id/boxscore:format
Obtain a boxscore for a specific MLB game.
--------------------
{'event_id': '27eba71e-d530-4953-9e37-363faf52f3dc'}
Game Pitch Metrics: mlb/trial/v6.5/en/games/:event_id/pitch_metrics:format
Obtain pitch metrics for a specific MLB game.
--------------------
{'event_id': 'b6f922df-46c6-483c-8d3b-4235a6fc4520'}
Game Summary: mlb/trial/v6.5/en/games/:event_id/summary:format
Obtain a game summary for a specific MLB game.
--------------------
{}
Glossary: mlb/trial/v6.5/en/league/glossary:format
Obtain the pitch types, player statuses, pitch outcomes, runner outcomes, game status and postseason game IDs.
--------------------
{}
Injuries: mlb/trial/v6.5/en/league/injuries:format
Obtain information concerning all current injuries across the league.
--------------------
{}
League Depth Chart: mlb/trial/v6.5/en/league/depth_charts:format
Obtain league depth charts for MLB.
--------------------
{}
League Hierarchy: mlb/trial/v6.5/en/league/hierarchy:format
Obtain list of MLB teams.
--------------------
{'year': '2018', 'mlb_season': 'REG'}
League Leaders: mlb/trial/v6.5/en/seasons/:year/:mlb_season/leaders/statistics:format
Obtain leaders for a given year.
--------------------
{'year': '2018', 'mlb_season': 'PST'}
League Schedule: mlb/trial/v6.5/en/games/:year/:mlb_season/schedule:format
Obtain Schedule for the MLB for a given season. NOTE: The 2012 sample data is an abbreviated season.
--------------------
{'event_id': 'b6f922df-46c6-483c-8d3b-4235a6fc4520'}
Play-By-Play: mlb/trial/v6.5/en/games/:event_id/pbp:format
Obtain the play-by-play data for a specific MLB game.
--------------------
{'player_id': '6e1cac5c-b059-4b80-a267-5143b19efb27'}
Player Profile: mlb/trial/v6.5/en/players/:player_id/profile:format
Obtain a profile for a given player.
--------------------
{'year': '2018', 'mlb_season': 'REG'}
Rankings: mlb/trial/v6.5/en/seasons/:year/:mlb_season/rankings:format
Obtain league and division rank for each team, including post season clinching status (available beginning with 2014 season)
--------------------
{'player_id': '46734ad0-e55b-4e2f-8a0d-72387470fcdf'}
Seasonal Pitch Metrics: mlb/trial/v6.5/en/players/:player_id/pitch_metrics:format
Obtain pitch metrics for a specific season
--------------------
{'year': '2018', 'mlb_season': 'PST', 'team_id': 'aa34e0ed-f342-4ec6-b774-c79b47b60e2d'}
Seasonal Splits: mlb/trial/v6.5/en/seasons/:year/:mlb_season/teams/:team_id/splits:format
Obtain season splits for MLB -- Not available pre-2015
--------------------
{'year': '2018', 'mlb_season': 'PST', 'team_id': 'aa34e0ed-f342-4ec6-b774-c79b47b60e2d'}
Seasonal Statistics: mlb/trial/v6.5/en/seasons/:year/:mlb_season/teams/:team_id/statistics:format
Obtain season statistics for MLB
--------------------
{'year': '2018'}
Seasonal Transactions: mlb/trial/v6.5/en/league/:year/transactions:format
Obtain information concerning all transactions taking place during a given season.
--------------------
{'year': '2018', 'mlb_season': 'PST'}
Series Schedule: mlb/trial/v6.5/en/series/:year/:mlb_season/schedule:format
Obtain Series Schedule for the MLB for the postseason.
--------------------
{'series_id': '0e85bf84-517b-46af-b75e-37514468e06e', 'team_id': 'ef64da7f-cfaf-4300-87b0-9313386b977c'}
Series Statistics: mlb/trial/v6.5/en/series/:series_id/teams/:team_id/statistics:format
Obtain series statistics for a given series. Please note that this feed will not return data until the 2017 playoffs begin
--------------------
{'series_id': ''}
Series Summary: mlb/trial/v6.5/en/series/:series_id/summary:format
Obtain series summary info for a given series. Please note that this feed will not return data until the 2017 playoffs begin
--------------------
{'year': '2018', 'mlb_season': 'PST'}
Standings: mlb/trial/v6.5/en/seasons/:year/:mlb_season/standings:format
Obtain Standings for the MLB for a given season. Standing data is not valid for 2012 as we do not have a full season available.
--------------------
{'team_id': 'aa34e0ed-f342-4ec6-b774-c79b47b60e2d'}
Team Depth Chart: mlb/trial/v6.5/en/teams/:team_id/depth_chart:format
Obtain team depth chart information.
--------------------
{'team_id': 'aa34e0ed-f342-4ec6-b774-c79b47b60e2d'}
Team Profile: mlb/trial/v6.5/en/teams/:team_id/profile:format
Obtain team profile information.
--------------------
{}
Venues: mlb/trial/v6.5/en/league/venues:format
Obtain venue data for the current season.
-----------
NASCAR Official Trial: Sportradar's NASCAR Official v3 API
NASCAR Official
38
--------------------
{'nascar_series': 'cw', 'year': '2017'}
Drivers: nascar-ot3/:nascar_series/:year/drivers/list:format
Obtain driver information for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{}
Tracks: nascar-ot3/tracks/list:format
Obtain track information for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'year': '2017'}
Schedule: nascar-ot3/:nascar_series/:year/races/schedule:format
Obtain schedule for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'race_id': '87f618bf-2ee5-4e6e-b558-7bbc0337e5c7'}
Entry List: nascar-ot3/:nascar_series/races/:race_id/entry_list:format
Obtain entry list information for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'race_id': '87f618bf-2ee5-4e6e-b558-7bbc0337e5c7'}
Practice Leaderboard: nascar-ot3/:nascar_series/races/:race_id/practices:format
Obtain practice leaderboard information for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'race_id': '87f618bf-2ee5-4e6e-b558-7bbc0337e5c7'}
Qualifying Leaderboard: nascar-ot3/:nascar_series/races/:race_id/qualifying:format
Obtain qualifying leaderboard information for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'race_id': '87f618bf-2ee5-4e6e-b558-7bbc0337e5c7'}
Starting Grid: nascar-ot3/:nascar_series/races/:race_id/starting_grid:format
Obtain starting grid information for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'race_id': 'cf82b04d-cc9c-4621-aa9b-cbc6ee269de7'}
Race Leaderboard: nascar-ot3/:nascar_series/races/:race_id/results:format
Obtain race leaderboard information for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'year': '2017', 'standings_type': 'manufacturers'}
Driver, Rookie, Owner, and Manufacturer Standings: nascar-ot3/:nascar_series/:year/standings/:standings_type:format
Obtain standings for drivers, rookies, owners, and manufacturers. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'nascar_series': 'cw', 'year': '2017'}
Driver Statistics: nascar-ot3/:nascar_series/drivers/:year/drivers:format
Obtain driver statistics for NASCAR. NOTE: The 2012 sample data is an abbreviated season
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Change Log: nascar-ot3/:year/:month/:day/changes:format
information on any changes made to race information, race results, driver information, track information, or standings
-----------
NBA Official Trial: Sportradar's NBA Official API
NBA Official API
40
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Change Log: nba/trial/v4/en/league/:year/:month/:day/changes:format
Provides information on any changes made to teams, players, game statistics, and standings
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: nba/trial/v4/en/games/:year/:month/:day/schedule:format
Provides the schedule for a given day
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Transfers: nba/trial/v4/en/league/:year/:month/:day/transfers:format
Provides information on player transfers for a given day
--------------------
{}
Free Agents: nba/trial/v4/en/league/free_agents:format
Get boxscore data for NBA Games
--------------------
{'game_id': '114844aa-3c31-4ac7-9afa-0a4f2ae65e0c'}
Game Boxscore: nba/trial/v4/en/games/:game_id/boxscore:format
Provide top-level team scores by quarter
--------------------
{'game_id': '114844aa-3c31-4ac7-9afa-0a4f2ae65e0c'}
Game Summary: nba/trial/v4/en/games/:game_id/summary:format
Provides top-level boxscore information, along with detailed game stats at the team and player levels
--------------------
{}
Injuries: nba/trial/v4/en/league/injuries:format
Provides active player injuries for all teams within the league
--------------------
{}
League Hierarchy: nba/trial/v4/en/league/hierarchy:format
League, conference, division, and team identification
--------------------
{'season_year': '2017', 'season_type': 'PST'}
League Leaders: nba/trial/v4/en/seasons/:season_year/:season_type/leaders:format
Provides the league leaders
--------------------
{'game_id': '114844aa-3c31-4ac7-9afa-0a4f2ae65e0c'}
Play By Play: nba/trial/v4/en/games/:game_id/pbp:format
Provides information on every team possession and game event.
--------------------
{'player_id': 'ab532a66-9314-4d57-ade7-bb54a70c65ad'}
Player Profile: nba/trial/v4/en/players/:player_id/profile:format
Provides detailed player information
--------------------
{'season_year': '2017', 'season_type': 'PST'}
Rankings: nba/trial/v4/en/seasons/:season_year/:season_type/rankings:format
Provides conference and division rank for each team
--------------------
{'season_year': '2017', 'season_type': 'PRE'}
Schedule: nba/trial/v4/en/games/:season_year/:season_type/schedule:format
Get the schedule for a given NBA Season
--------------------
{'season_year': '2017', 'season_type': 'PST', 'team_id': '583eca2f-fb46-11e1-82cb-f4ce4684ea4c'}
Seasonal Statistics (Season to Date): nba/trial/v4/en/seasons/:season_year/:season_type/teams/:team_id/statistics:format
Provides detailed team and player statistics for the defined season
--------------------
{'season_year': '2017', 'season_type': 'PST'}
Series Schedule: nba/trial/v4/en/series/:season_year/:season_type/schedule:format
Provides playoff participant and scheduling information
--------------------
{'series_id': 'a0ce3990-36a1-4ef3-939b-10d4feab0386', 'team_id': '583ec825-fb46-11e1-82cb-f4ce4684ea4c'}
Series Statistics: nba/trial/v4/en/series/:series_id/teams/:team_id/statistics:format
Provides detailed team and player statistics for the defined series
--------------------
{'season_year': '2017', 'season_type': 'PST'}
Standings: nba/trial/v4/en/seasons/:season_year/:season_type/standings:format
Get the standings for the NBA
--------------------
{'team_id': '583ec825-fb46-11e1-82cb-f4ce4684ea4c'}
Team Profile (Rosters): nba/trial/v4/en/teams/:team_id/profile:format
Provides detailed team information including league affiliation information and player roster information.
-----------
NFL Official Trial v2: Sportradar's NFL Official API
NFL Official
47
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Change Log: nfl-ot2/league/:year/:month/:day/changes:format
Obtain changes made to previously closed events, team rosters, or player profiles for a given day.
--------------------
{'game_id': 'b1dbf64f-822a-49b7-9bf3-070f5d6da827'}
Game Boxscore: nfl-ot2/games/:game_id/boxscore:format
Obtain the scoring information for each team, including drive and play information for all scoring events.
--------------------
{'game_id': 'c8dc876a-099e-4e95-93dc-0eb143c6954f'}
Game Roster: nfl-ot2/games/:game_id/roster:format
Obtain the roster information for each teams, as well as player profile data.
--------------------
{'game_id': 'c8dc876a-099e-4e95-93dc-0eb143c6954f'}
Game Statistics: nfl-ot2/games/:game_id/statistics:format
Obtain team and player level game statistics for each team.
--------------------
{}
League Hierarchy: nfl-ot2/league/hierarchy:format
Obtain the complete league hierarchy.
--------------------
{'game_id': 'c8dc876a-099e-4e95-93dc-0eb143c6954f'}
Play-By-Play: nfl-ot2/games/:game_id/pbp:format
Obtain complete play-by-play narrative.
--------------------
{'game_id': 'c8dc876a-099e-4e95-93dc-0eb143c6954f'}
Player Participation: nfl-ot2/plays/:game_id/participation:format
Obtain player participation for a given game.
--------------------
{'player_id': '9634e162-5ff5-4372-b72b-ee1b0cb73a0d'}
Player Profile: nfl-ot2/players/:player_id/profile:format
Obtain complete player biographical information.
--------------------
{'year': '2017', 'nfl_season': 'PST'}
Schedule: nfl-ot2/games/:year/:nfl_season/schedule:format
Obtain complete schedule information.
--------------------
{'year': '2017', 'nfl_season': 'PST', 'team_id': '33405046-04ee-4058-a950-d606f8c30852'}
Seasonal Statistics: nfl-ot2/seasontd/:year/:nfl_season/teams/:team_id/statistics:format
Obtain complete team and player seasonal statistics.
--------------------
{'year': '2017'}
Standings: nfl-ot2/seasontd/:year/standings:format
Obtain standings information for each team.
--------------------
{'team_id': '33405046-04ee-4058-a950-d606f8c30852'}
Team Profile: nfl-ot2/teams/:team_id/profile:format
Obtain franchise team information.
--------------------
{'team_id': '33405046-04ee-4058-a950-d606f8c30852'}
Team Roster: nfl-ot2/teams/:team_id/full_roster:format
Obtain the complete roster of players for a given team
--------------------
{'year': '2017', 'nfl_season': 'PST', 'nfl_season_week': '10'}
Weekly Schedule: nfl-ot2/games/:year/:nfl_season/:nfl_season_week/schedule:format
Obtain schedules for the NFL for a given week. Pre-Season (PRE) valid weeks 1-4, Regular Season (REG) weeks 1-17, Post-Season (PST) weeks 1-4.
--------------------
{'year': '2017', 'nfl_season': 'PST', 'nfl_season_week': '13'}
Weekly Injuries: nfl-ot2/seasontd/:year/:nfl_season/:nfl_season_week/injuries:format
Obtain injuries for the NFL for a given week. Pre-Season (PRE) valid weeks 1-4, Regular Season (REG) weeks 1-17, Post-Season (PST) weeks 1-4.
--------------------
{'year': '2017', 'nfl_season': 'PST', 'nfl_season_week': '13'}
Weekly Depth Charts: nfl-ot2/seasontd/:year/:nfl_season/:nfl_season_week/depth_charts:format
Obtain depth charts for the NFL for a given week. Pre-Season (PRE) valid weeks 1-4, Regular Season (REG) weeks 1-17, Post-Season (PST) weeks 1-4.
-----------
NHL Official Trial: Sportradar's NHL Official API
NHL Official v5
49
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Change Log: nhl/trial/v5/en/league/:year/:month/:day/changes:format
provides information on any changes made to teams, players, game statistics, and standings
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: nhl/trial/v5/en/games/:year/:month/:day/schedule:format
provides the schedule for a given day
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Transfers: nhl/trial/v5/en/league/:year/:month/:day/transfers:format
provides information on player transfers for a given day
--------------------
{'game_id': 'af285aa3-3d80-4051-9449-5b58e5985a4e'}
Game Boxscore: nhl/trial/v5/en/games/:game_id/boxscore:format
Get boxscore data for NHL Games
--------------------
{'game_id': 'af285aa3-3d80-4051-9449-5b58e5985a4e'}
Game Faceoffs: nhl/trial/v5/en/games/:game_id/faceoffs:format
Get faceoff data for an NHL Game
--------------------
{'game_id': 'af285aa3-3d80-4051-9449-5b58e5985a4e'}
Game Play By Play: nhl/trial/v5/en/games/:game_id/pbp:format
Get the Play-by-Play data for an NHL Game
--------------------
{'game_id': 'af285aa3-3d80-4051-9449-5b58e5985a4e'}
Game Summary: nhl/trial/v5/en/games/:game_id/summary:format
Get the Summary data for an NHL Game
--------------------
{'game_id': 'af285aa3-3d80-4051-9449-5b58e5985a4e'}
Game Time on Ice: nhl/trial/v5/en/games/:game_id/time_on_ice:format
Get the time on ice data for an NHL Game
--------------------
{}
Injuries: nhl/trial/v5/en/league/injuries:format
Provides updated injuries for the NHL
--------------------
{}
League Hierarchy: nhl/trial/v5/en/league/hierarchy:format
Provides list of all NHL teams
--------------------
{'season': '2016', 'nhl_season': 'PST'}
League Leaders - Goaltending: nhl/trial/v5/en/seasons/:season/:nhl_season/leaders/goaltending:format
Provides the leaders for Goaltending
--------------------
{'season': '2016', 'nhl_season': 'PST'}
League Leaders - Skaters: nhl/trial/v5/en/seasons/:season/:nhl_season/leaders/offense:format
Provides the leaders for Defense and Offense skaters
--------------------
{'year1': '2017', 'nhl_season': 'PST', 'year2': '2018', 'month': '06', 'day': '01'}
League Leaders - Daily: nhl/trial/v5/en/seasons/:year1/:nhl_season/:year2/:month/:day/leaders:format
Provides the leaders for a given day. Please note that this feed will not return data until the regular season begins
--------------------
{'season': '2018', 'nhl_season': 'PST'}
League Leaders - Seasonal: nhl/trial/v5/en/seasons/:season/:nhl_season/leaders:format
Provides the seasonal leaders. Please note that this feed will not return data until the regular season begins
--------------------
{'player_id': '42b7b605-0f24-11e2-8525-18a905767e44'}
Player Profile: nhl/trial/v5/en/players/:player_id/profile:format
Player information for the NHL
--------------------
{'season': '2016', 'nhl_season': 'PST'}
Rankings: nhl/trial/v5/en/seasons/:season/:nhl_season/rankings:format
Get ranking information for the NHL
--------------------
{'season': '2016', 'nhl_season': 'PRE'}
Schedule: nhl/trial/v5/en/games/:season/:nhl_season/schedule:format
Get the schedule for a given NHL Season
--------------------
{'season': '2016', 'nhl_season': 'PST', 'team_id': '4416091c-0f24-11e2-8525-18a905767e44'}
Seasonal Faceoffs: nhl/trial/v5/en/seasons/:season/:nhl_season/teams/:team_id/faceoffs:format
Get faceoff information on a team level
--------------------
{'season': '2016', 'nhl_season': 'PST', 'team_id': '4416091c-0f24-11e2-8525-18a905767e44'}
Seasonal Statistics - Season to Date: nhl/trial/v5/en/seasons/:season/:nhl_season/teams/:team_id/statistics:format
Get statistics on a team level
--------------------
{'series_id': '6fdf1873-a327-4926-a411-ff55ef95a78a', 'team_id': '4416091c-0f24-11e2-8525-18a905767e44'}
Series Faceoffs: nhl/trial/v5/en/series/:series_id/teams/:team_id/faceoffs:format
Get faceoff information for a playoff series
--------------------
{'season': '2016', 'nhl_season': 'PST'}
Series Schedule: nhl/trial/v5/en/series/:season/:nhl_season/schedule:format
Get faceoff information for a playoff series
--------------------
{'series_id': '6fdf1873-a327-4926-a411-ff55ef95a78a', 'team_id': '4416091c-0f24-11e2-8525-18a905767e44'}
Series Statistics: nhl/trial/v5/en/series/:series_id/teams/:team_id/statistics:format
Get the statistics for a playoff series
--------------------
{'season': '2016', 'nhl_season': 'PST'}
Standings: nhl/trial/v5/en/seasons/:season/:nhl_season/standings:format
Get the standings for the NHL
--------------------
{'year1': '2018', 'nhl_season': 'PRE', 'year2': '2018', 'month': '06', 'day': '01', 'format': '.json'}
Team Leaders - Daily: nhl/trial/v5/en/seasons/:year1/:nhl_season/:year2/:month/:day/teams/:team_id/leaders:format
Provides the leaders for a given day. Please note that this feed will not return data until the regular season begins
--------------------
{'season': '2016', 'nhl_season': 'PST', 'team_id': '4416091c-0f24-11e2-8525-18a905767e44'}
Team Leaders - Seasonal: nhl/trial/v5/en/seasons/:season/:nhl_season/teams/:team_id/leaders:format
Get leaders on a team level. Please note that this feed will not return data until the regular season begins
--------------------
{'team_id': '4416091c-0f24-11e2-8525-18a905767e44'}
Team Profile - Roster: nhl/trial/v5/en/teams/:team_id/profile:format
Get the roster information for a NHL team
-----------
Rugby v2 API: Sportradar's Rugby API
Rugby Trial
54
--------------------
{'plan': 'union', 'language_code': 'en'}
Seasons: rugby/trial/v2/:plan/:language_code/seasons:format
Lists all seasons/tournaments covered by the API
--------------------
{'plan': 'union', 'language_code': 'en', 'season_id': 'sr:season:40443'}
Season Schedule: rugby/trial/v2/:plan/:language_code/seasons/:season_id/schedule:format
Returns a list of the scheduled matches given a tournament ID
--------------------
{'plan': 'union', 'language_code': 'en', 'season_id': 'sr:season:40443'}
Season Results: rugby/trial/v2/:plan/:language_code/seasons/:season_id/results:format
Returns a list of results for a tournament
--------------------
{'plan': 'union', 'language_code': 'en', 'season_id': 'sr:season:40443'}
Season Info: rugby/trial/v2/:plan/:language_code/seasons/:season_id/info:format
Returns information pertaining to a specific (given) tournament
--------------------
{'plan': 'union', 'language_code': 'en', 'season_id': 'sr:season:40443'}
Season Standings: rugby/trial/v2/:plan/:language_code/seasons/:season_id/standings:format
Returns the team list for a given tournament in order of points.
--------------------
{'plan': 'union', 'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: rugby/trial/v2/:plan/:language_code/schedules/:year-:month-:day/schedule:format
Returns all matches scheduled for a given date
--------------------
{'plan': 'union', 'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Results: rugby/trial/v2/:plan/:language_code/schedules/:year-:month-:day/results:format
Returns result of all completed matches for a given date
--------------------
{'plan': 'union', 'language_code': 'en'}
Live Results: rugby/trial/v2/:plan/:language_code/schedules/live/results:format
Returns live results for matches
--------------------
{'plan': 'union', 'language_code': 'en'}
Live Summaries: rugby/trial/v2/:plan/:language_code/schedules/live/summaries:format
Returns live summaries for matches
--------------------
{'plan': 'union', 'language_code': 'en', 'match_id': 'sr:match:11647289'}
Probabilities: rugby/trial/v2/:plan/:language_code/matches/:match_id/probabilities:format
Displays probabilities of outcomes between two teams given a match id
--------------------
{'plan': 'union', 'language_code': 'en', 'competitor_id': 'sr:competitor:42725', 'competitor_id2': 'sr:competitor:42719'}
Team vs. Team: rugby/trial/v2/:plan/:language_code/teams/:competitor_id/versus/:competitor_id2/matches:format
Displays past results between two given teams
--------------------
{'plan': 'union', 'language_code': 'en', 'competitor_id': 'sr:competitor:4225'}
Team Profile: rugby/trial/v2/:plan/:language_code/teams/:competitor_id/profile:format
Displays information of a team and its' players
--------------------
{'plan': 'union', 'language_code': 'en', 'competitor_id': 'sr:competitor:206689'}
Team Results: rugby/trial/v2/:plan/:language_code/teams/:competitor_id/results:format
Returns a list of results for a given team
--------------------
{'plan': 'union', 'language_code': 'en', 'competitor_id': 'sr:competitor:4225'}
Team Schedule: rugby/trial/v2/:plan/:language_code/teams/:competitor_id/schedule:format
Returns a list of fixtures for a given team
--------------------
{'plan': 'union', 'language_code': 'en', 'match_id': 'sr:match:12269280'}
Match Timeline: rugby/trial/v2/:plan/:language_code/matches/:match_id/timeline:format
Returns a match, with a timeline of selected events
--------------------
{'plan': 'union', 'language_code': 'en', 'match_id': 'sr:match:12269280'}
Match Summary: rugby/trial/v2/:plan/:language_code/matches/:match_id/summary:format
Provides information about a match in real time
--------------------
{'plan': 'union', 'language_code': 'en', 'season_id': 'sr:season:40443'}
Previous Seasons: rugby/trial/v2/:plan/:language_code/seasons/:season_id/previous_seasons:format
Provides information for previous seasons
-----------
Soccer EU Trial v3: Sportradar's Soccer EU API
Soccer Europe Version 3
64
--------------------
{'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Results: soccer-t3/eu/:language_code/schedules/:year-:month-:day/results:format
Provides match information and scoring, for all matches played on a given day
--------------------
{'language_code': 'en', 'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: soccer-t3/eu/:language_code/schedules/:year-:month-:day/schedule:format
provides match played on a certain day
--------------------
{'language_code': 'en'}
Live Results: soccer-t3/eu/:language_code/schedules/live/results:format
Provides results for live matches
--------------------
{'language_code': 'en', 'match_id': 'sr:match:11660367'}
Match Summary: soccer-t3/eu/:language_code/matches/:match_id/summary:format
Provides match summary, including team statistics and lineups
--------------------
{'language_code': 'en', 'match_id': 'sr:match:11660367'}
Match Timeline: soccer-t3/eu/:language_code/matches/:match_id/timeline:format
Provides match information and scoring, including team statistics and a play-by-play
--------------------
{'language_code': 'en', 'match_id': 'sr:match:11660367'}
Match Lineups: soccer-t3/eu/:language_code/matches/:match_id/lineups:format
Provides lineups for a given match
--------------------
{'language_code': 'en', 'match_id': 'sr:match:11660367'}
Match Probabilities: soccer-t3/eu/:language_code/matches/:match_id/probabilities:format
Provides match probabilities
--------------------
{'language_code': 'en', 'match_id': 'sr:match:11660367'}
Match Fun Facts: soccer-t3/eu/:language_code/matches/:match_id/funfacts:format
Provides Fun Facts for a match
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Missing Players: soccer-t3/eu/:language_code/tournaments/:tournament_id/missing_players:format
Provides a listing of players by team who are missing from play
--------------------
{'language_code': 'en', 'mapping': 'players'}
Player Mapping: soccer-t3/eu/:language_code/:mapping/v2_v3_id_mappings:format
Displays Player and Team IDs from the Soccer v2 API and the converted IDs that are used in the Soccer v3 API.
--------------------
{'language_code': 'en', 'player_id': 'sr:player:76632'}
Player Profile: soccer-t3/eu/:language_code/players/:player_id/profile:format
Provides player information
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Player Rankings: soccer-t3/eu/:language_code/tournaments/:tournament_id/leaders:format
Provides player rankings for goals, assists, points, cards, and own goals in a tournament
--------------------
{'language_code': 'en', 'team_id': 'sr:competitor:48'}
Team Profile: soccer-t3/eu/:language_code/teams/:team_id/profile:format
Team information, including player roster information
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17', 'team_id': 'sr:competitor:48'}
Team Statistics: soccer-t3/eu/:language_code/tournaments/:tournament_id/teams/:team_id/statistics:format
Provides team's statistics
--------------------
{'language_code': 'en', 'team_id': 'sr:competitor:48', 'team_id_2': 'sr:competitor:45'}
Team vs Team: soccer-t3/eu/:language_code/teams/:team_id/versus/:team_id_2/matches:format
Provides information on team versus team results
--------------------
{'language_code': 'en'}
Tournaments: soccer-t3/eu/:language_code/tournaments:format
Provides the list of Europe Soccer tournaments
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Tournament Info: soccer-t3/eu/:language_code/tournaments/:tournament_id/info:format
Provides information for Soccer tournaments
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Tournament Standings: soccer-t3/eu/:language_code/tournaments/:tournament_id/standings:format
Provides the standings for Soccer tournaments
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Tournament Live Standings: soccer-t3/eu/:language_code/tournaments/:tournament_id/live_standings:format
Provides the live standings for Soccer tournaments
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Tournament Results: soccer-t3/eu/:language_code/tournaments/:tournament_id/results:format
Provides the results for Soccer tournaments
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Tournament Schedule: soccer-t3/eu/:language_code/tournaments/:tournament_id/schedule:format
Provides the schedule for Soccer tournaments
--------------------
{'language_code': 'en', 'tournament_id': 'sr:tournament:17'}
Tournament Seasons: soccer-t3/eu/:language_code/tournaments/:tournament_id/seasons:format
Provides info for previous seasons for a given tournament
-----------
Tennis v2 Trial: Sportradar's Tennis API
Tennis v2
72
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Results: tennis-t2/en/schedules/:year-:month-:day/results:format
Provides match information and scoring, for all matches played on a given day
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: tennis-t2/en/schedules/:year-:month-:day/schedule:format
Provides the schedule for a given day
--------------------
{}
Deleted Matches: tennis-t2/en/schedules/deleted_matches:format
Provides deleted matches
--------------------
{'match_id': 'sr:match:10134403'}
Match Probabilities: tennis-t2/en/matches/:match_id/probabilities:format
Provides match probabilities
--------------------
{'match_id': 'sr:match:10134403'}
Match Summary: tennis-t2/en/matches/:match_id/summary:format
Provides match summary, including scores and statistics
--------------------
{'match_id': 'sr:match:10134403'}
Match Timeline: tennis-t2/en/matches/:match_id/timeline:format
Provides match information and scoring
--------------------
{'player_id': 'sr:competitor:19578'}
Player Profile: tennis-t2/en/players/:player_id/profile:format
Provides player information
--------------------
{'player_id_1': 'sr:competitor:19578', 'player_id_2': 'sr:competitor:18254'}
Player Versus Player: tennis-t2/en/players/:player_id_1/versus/:player_id_2/matches:format
Provides information on team versus team results
--------------------
{'player_id': 'sr:competitor:19578'}
Player Results: tennis-t2/en/players/:player_id/results:format
Provides the results for a given player
--------------------
{'player_id': 'sr:competitor:19578'}
Player Schedule: tennis-t2/en/players/:player_id/schedule:format
Provides the schedule for a player
--------------------
{}
Player Rankings: tennis-t2/en/players/rankings:format
Provides player rankings for a given tournaments
--------------------
{'tournament_id': 'sr:competitor:15126'}
Player Race Rankings: tennis-t2/en/players/race_rankings:format
Provides player rankings for a given tournaments
--------------------
{'team_id': 'sr:competitor:298214'}
Double-Team Profile: tennis-t2/en/double_teams/:team_id/profile:format
Team information, including player roster information
--------------------
{'team_id': 'sr:competitor:298214'}
Double-Team Results: tennis-t2/en/double_teams/:team_id/results:format
Provides a Team's Results
--------------------
{'team_id': 'sr:competitor:298214'}
Double-Team Schedule: tennis-t2/en/double_teams/:team_id/schedule:format
Provides a Team's Schedule
--------------------
{'team_id_1': 'sr:competitor:257813', 'team_id_2': 'sr:competitor:187839'}
Double Team Versus Team: tennis-t2/en/double_teams/:team_id_1/versus/:team_id_2/matches:format
Provides information on team versus team results
--------------------
{}
Doubles Rankings: tennis-t2/en/double_teams/rankings:format
Provides rankings for a Doubles
--------------------
{}
Doubles Race Rankings: tennis-t2/en/double_teams/race_rankings:format
Provides double rankings for a Doubles
--------------------
{'tournament_id': 'sr:tournament:2591'}
Tournament Info: tennis-t2/en/tournaments/:tournament_id/info:format
Provide information for a given Tournament found in the Tournament List endpoint
--------------------
{}
Tournament List: tennis-t2/en/tournaments:format
Provides a list of all covered Tournaments
--------------------
{}
Tournament Ongoing: tennis-t2/en/tournaments/ongoing:format
Provides updated information for a given Tournament found in the Tournament List endpoint
--------------------
{'tournament_id': 'sr:tournament:2591'}
Tournament Results: tennis-t2/en/tournaments/:tournament_id/results:format
Provides results for a given Tournament found in the Tournament List endpoint
--------------------
{'tournament_id': 'sr:tournament:2591'}
Tournament Schedule: tennis-t2/en/tournaments/:tournament_id/schedule:format
Provides the schedule for a given Tournament found in the Tournament List endpoint
-----------
WNBA Trial: Sportradar's WNBA API
WNBA
81
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Change Log: wnba/trial/v4/en/league/:year/:month/:day/changes:format
information on any changes made to teams, players, game statistics, and standings
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Schedule: wnba/trial/v4/en/games/:year/:month/:day/schedule:format
Get single day schedules for the WNBA.
--------------------
{'year': '2018', 'month': '06', 'day': '01'}
Daily Transfers: wnba/trial/v4/en/league/:year/:month/:day/transfers:format
information for all transfers added or edited during the league defined day
--------------------
{'game_id': '0144c46e-e830-4082-8558-933a21923e60'}
Game Boxscore: wnba/trial/v4/en/games/:game_id/boxscore:format
Get boxscore data for WNBA games.
--------------------
{'game_id': '0144c46e-e830-4082-8558-933a21923e60'}
Game Summary: wnba/trial/v4/en/games/:game_id/summary:format
Obtain game summaries for the WNBA.
--------------------
{}
Injuries: wnba/trial/v4/en/league/injuries:format
Get injury feeds for the WNBA.
--------------------
{}
League Hierarchy: wnba/trial/v4/en/league/hierarchy:format
Get the league hierarchy information for the WNBA.
--------------------
{'season_id': '2018', 'wnba_season': 'REG'}
League Leaders: wnba/trial/v4/en/seasons/:season_id/:wnba_season/leaders:format
Get the league leaders for the WNBA.
--------------------
{'game_id': '0144c46e-e830-4082-8558-933a21923e60'}
Play-By-Play: wnba/trial/v4/en/games/:game_id/pbp:format
Get play-by-play detail for WNBA games.
--------------------
{'player_id': '3f53a238-b4df-4861-b260-73fc309d6e94'}
Player Profile: wnba/trial/v4/en/players/:player_id/profile:format
Get player profiles for the WNBA.
--------------------
{'season_id': '2018', 'wnba_season': 'REG'}
Rankings: wnba/trial/v4/en/seasons/:season_id/:wnba_season/rankings:format
Get rankings information for the WNBA.
--------------------
{'season_id': '2018', 'wnba_season': 'PST'}
Schedule: wnba/trial/v4/en/games/:season_id/:wnba_season/schedule:format
Get full season schedules for the WNBA.
--------------------
{'season_id': '2018', 'wnba_season': 'PST', 'team_id': '6f017f37-be96-4bdc-b6d3-0a0429c72e89'}
Seasonal Statistics: wnba/trial/v4/en/seasons/:season_id/:wnba_season/teams/:team_id/statistics:format
Get seasonal statistics information for the WNBA.
--------------------
{'season_id': '2018', 'wnba_season': 'PST'}
Series Schedules: wnba/trial/v4/en/series/:season_id/:wnba_season/schedule:format
Get post season series information for the WNBA.
--------------------
{'season_id': '2018', 'wnba_season': 'PST'}
Standings: wnba/trial/v4/en/seasons/:season_id/:wnba_season/standings:format
Get standings information for the WNBA.
--------------------
{'team_id': '6f017f37-be96-4bdc-b6d3-0a0429c72e89'}
Team Profile (Rosters): wnba/trial/v4/en/teams/:team_id/profile:format
Get team rosters for the WNBA.

Load the saved API data


In [2]:
apis = json.load(open('api_names_and_endpoints.json', 'rb'))

Generate new Python classes and files from API info


In [4]:
apis[0].keys()


Out[4]:
dict_keys(['name', 'description', 'endpoints'])

In [6]:
[a['name'] for a in apis]


Out[6]:
['Beach Volleyball Trial',
 'Darts Trial',
 'eSports Dota 2 Trial',
 'Global Basketball Trial',
 'Global Ice Hockey Trial',
 'Golf Trial',
 'eSports LoL Trial',
 'MLB v6.5 Trial',
 'NASCAR Official Trial',
 'NBA Official Trial',
 'NFL Official Trial v2',
 'NHL Official Trial',
 'Rugby v2 API',
 'Soccer EU Trial v3',
 'Tennis v2 Trial',
 'WNBA Trial']

In [5]:
endpoints = apis[10]['endpoints']

In [6]:
endpoints[2]
uri = endpoints[2]['uri']
uri


Out[6]:
'nfl-ot2/games/:game_id/roster:format'

In [11]:
max_width = 79
def formatArgListAndPathFromURI(uri, format_for_tests=False):
    uri = uri.replace('//','/') # Deal with a typo on Sportradar
    regex = re.compile('(?!:format)(:[\w_]+)', re.VERBOSE)    
    
    # Identify the arguments to the URI, excluding :format
    parameters = [s.strip(':') for s in regex.findall(uri) if s != '']
    if format_for_tests:
        arg_list = ''
        for p in parameters:
            arg_list += "self.{p}, ".format(p=p)
        if parameters:
            arg_list = arg_list.strip(', ')
    else:
        arg_list = ", ".join(parameters)
    
    # Create the path string, allowing user to substitute in arguments
    path = (regex.sub('{\g<1>}', uri).split(':format')[0] + '"').replace('{:','{')
    print(path)
    
    # Make sure dates are formatted properly
    if 'year' in parameters:
        path = path.replace('{year}', '{year:4d}')
    if 'month' in parameters:
        path = path.replace('{month}', '{month:02d}')
    if 'day' in parameters:
        path = path.replace('{day}', '{day:02d}')        
    
    # Append .format() to the end of the path string
    format_suffix = ""
    for p in parameters:
        format_suffix += "{arg}={val}, ".format(arg=p, val=p)
    format_suffix = ".format({})".format(format_suffix.strip(', '))    
    path += format_suffix
#     path = path.split('/',3)[-1]
    
    # Comply to max width of lines
    if len(path) > max_width-8:
        regex = re.compile(r'\.format\(', re.VERBOSE)
        path = regex.sub(r'.format(\n\t\t\t', path)        
    path = '"' + path
    
    return arg_list, path

def formatPathFromURI(uri):
    parameters = [s.strip(':') for s in re.findall(r'(:[\w_]+)*', uri) if s != ''][:-1]

def formatDocString(doc, mw=79):
    if len(doc) > mw-7:
        idx_cut = (mw-len(doc[mw::-1].split(' ')[0])) # kludge        
        doc = doc[:idx_cut] + '\n\t\t\t' + formatDocString(doc[idx_cut:].strip(' '), mw)
    return doc

def paramValsAreComplete(endpoint):
    for val in endpoint['defaults'].values():
        if val == '':
            return False
    return True

def formatDefaultParamVals(endpoints):
    assert type(endpoints)==list, 'Must provide a list of endpoints'
    varlist = ''
    used_vars = []
    
    for ep in endpoints:
        defaults = ep['defaults']
        for var,val in defaults.items():
            if var not in used_vars and val != '':
                if var in ['year', 'month', 'day']:                    
                    varlist += '\t\tcls.{var} = {val}\n'.format(var=var, val=int(val))
                else:
                    varlist += '\t\tcls.{var} = "{val}"\n'.format(var=var, val=val)
                used_vars.append(var)
    return varlist

def formatClassName(name):
    name = name.replace(' Trial','').replace('Official','')
    name = name.replace(' ','').replace('.','_').replace('(','')
    name = name.replace(')','').replace('-','_').replace(',','_')
    return name
    
def writeToPythonFile(api_info):
    """Write methods based on the endpoint attributes
    :param api_info: (dict) Contains API name, description and list of endpoints
    """

    # --------------------------------------------------------
    #    Write the methods
    # --------------------------------------------------------
                
    # Class name    
    class_name = formatClassName(api_info['name'])
    regex = re.compile(r'v[\d_]+', re.IGNORECASE)
    class_name = regex.sub('', class_name)
        
    # Add comment heading and import statement
    txt = "# Sportradar APIs\n# Copyright 2018 John W. Miller\n# See LICENSE for details.\n\n"
    txt += "from sportradar.api import API\n\n\n"
           
    # Add class name to file   
    txt += "class {}(API):\n\n".format(class_name)
    
    # Add __init__ function to class
    txt += "\tdef __init__(self, api_key, format_='json', timeout=5, sleep_time=1.5):\n"
    txt += "\t\tsuper().__init__(api_key, format_, timeout, sleep_time)\n\n"
    txt = txt.replace('\t', 4*' ')
            
    # Write the method, including arguments, doc string, and URI path    
    endpoints = api_info['endpoints']    
    for n,ep in enumerate(endpoints):
        mn = 'get_' + formatClassName(ep['name']).lower()
        doc = formatDocString(ep['description'], max_width)
        doc = doc + '"""' if len(doc) < max_width-8 else doc + '\n\t\t"""'
        args, path = formatArgListAndPathFromURI(ep['uri'])                
        arglist = 'self, {a}'.format(a=args) if args != '' else 'self'                
        
        # Assemble the method string
        txt += '\tdef {method_name}({args}):\n'.format(method_name=mn, args=arglist)
        txt += '\t\t"""{doc}\n\t\tpath = {path}\n'.format(doc=doc, path=path)
        txt += '\t\treturn self._make_request(path)\n\n'
        txt = txt.replace('\t', 4*' ')
                        
    print('-'*20)
    print(api_info['name'])
#     print(path)
#     print(txt)
    
    # Save to Python file
    filename = class_name + '.py'
    with open(filename, 'w+') as pyfile:
        pyfile.write(txt)
        
        
    # --------------------------------------------------------
    #    Write the tests
    # --------------------------------------------------------
    
    # Write the test front matter
    txt = "import os\nimport unittest\nfrom sportradar import {}\n\n".format(class_name)
    txt += '# Import API keys from environment variables\n'
    txt += 'api_key_name = "SPORTRADAR_API_KEY_{}"\n'.format(class_name.upper())
    txt += 'api_key = os.environ.get(api_key_name, None)\n'
    txt += 'assert api_key is not None, "Must declare environment variable: {key_name}".format(\n'
    txt += '\tkey_name=api_key_name)\n'
    txt += 'api = {}.{}(api_key, format_="json", timeout=5, sleep_time=1.5)\n\n\n'.format(
        class_name, class_name)
    txt += 'class TestAPI(unittest.TestCase):\n\n'
    txt += '    @classmethod\n    def setUpClass(cls):\n'
    txt += '\t\tprint("\\n---------------------\\nSetting up {} tests...\\n".format("{}"))\n'.format("{}", class_name)
    txt += '\t\tcls.auth = api_key\n\t\tcls.api = api\n'
    txt += '{defaults}\n'.format(defaults=formatDefaultParamVals(endpoints))
       
    # Write the test methods
    # Write the method, including arguments, doc string, and URI path    
    for n,ep in enumerate(endpoints):        
        if paramValsAreComplete(ep):        
            mn = 'test_get_' + formatClassName(ep['name']).lower()
            doc = '"""Test the {} GET query"""'.format(ep['name'].lower())    
            args, path = formatArgListAndPathFromURI(ep['uri'], format_for_tests=True)
            arglist = '{a}'.format(a=args) if args != '' else ''
            print(arglist)

            # Assemble the method string    
            txt += '\tdef {method_name}(self):\n\t\t{doc}\n\t\tmsg = "Response status is not 200"\n'.format(
                    method_name=mn, doc=doc)
            txt += '\t\tresponse = self.api.{}({})\n'.format(
                mn.split('test_')[1], arglist.split('self, ', 1)[-1])
            
            if n == len(endpoints)-1:            
                txt += '\t\tself.assertEqual(response.status_code, 200, msg)\n'
            else:
                txt += '\t\tself.assertEqual(response.status_code, 200, msg)\n\n'
            txt = txt.replace('\t', 4*' ')
        
    # Save to Python file
    filename = 'test_' + class_name + '.py'
    with open(filename, 'w+') as pyfile:
        pyfile.write(txt)

In [13]:
# api_names_to_scrape = ['Beach Volleyball Trial', 'Darts Trial', 'Golf Trial', 'MLB v6.5 Trial', 'NASCAR Official Trial', 'NBA Official Trial', 'NFL Official Trial v2', 'NHL Official Trial', 'Tennis v2 Trial', 'WNBA Trial']
api_names_to_scrape = ['eSports Dota 2 Trial']
for api in apis:
    if api['name'] in api_names_to_scrape:
        writeToPythonFile(api)


{sport}-t1/{language_code}/schedules/{year}-{month}-{day}/results"
{sport}-t1/{language_code}/schedules/{year}-{month}-{day}/schedule"
{sport}-t1/{language_code}/schedules/deleted_matches"
{sport}-t1/{language_code}/teams/{team_id_1}/versus/{team_id_2}/matches"
{sport}-t1/{language_code}/matches/{match_id}/lineups"
{sport}-t1/{language_code}/matches/{match_id}/probabilities"
{sport}-t1/{language_code}/matches/{match_id}/summary"
{sport}-t1/{language_code}/players/{player_id}/profile"
{sport}-t1/{language_code}/teams/{team_id}/profile"
{sport}-t1/{language_code}/teams/{team_id}/results"
{sport}-t1/{language_code}/teams/{team_id}/schedule"
{sport}-t1/{language_code}/tournaments/{tournament_id}/info"
{sport}-t1/{language_code}/schedules/live/summaries"
{sport}-t1/{language_code}/tournaments/{tournament_id}/results"
{sport}-t1/{language_code}/tournaments/{tournament_id}/schedule"
{sport}-t1/{language_code}/tournaments/{tournament_id}/seasons"
{sport}-t1/{language_code}/tournaments/{tournament_id}/standings"
{sport}-t1/{language_code}/tournaments/{tournament_id}/summaries"
{sport}-t1/{language_code}/tournaments"
--------------------
eSports Dota 2 Trial
{sport}-t1/{language_code}/schedules/{year}-{month}-{day}/results"
self.sport, self.language_code, self.year, self.month, self.day
{sport}-t1/{language_code}/schedules/{year}-{month}-{day}/schedule"
self.sport, self.language_code, self.year, self.month, self.day
{sport}-t1/{language_code}/schedules/deleted_matches"
self.sport, self.language_code
{sport}-t1/{language_code}/teams/{team_id_1}/versus/{team_id_2}/matches"
self.sport, self.language_code, self.team_id_1, self.team_id_2
{sport}-t1/{language_code}/matches/{match_id}/lineups"
self.sport, self.language_code, self.match_id
{sport}-t1/{language_code}/matches/{match_id}/probabilities"
self.sport, self.language_code, self.match_id
{sport}-t1/{language_code}/matches/{match_id}/summary"
self.sport, self.language_code, self.match_id
{sport}-t1/{language_code}/players/{player_id}/profile"
self.sport, self.language_code, self.player_id
{sport}-t1/{language_code}/teams/{team_id}/profile"
self.sport, self.language_code, self.team_id
{sport}-t1/{language_code}/teams/{team_id}/results"
self.sport, self.language_code, self.team_id
{sport}-t1/{language_code}/teams/{team_id}/schedule"
self.sport, self.language_code, self.team_id
{sport}-t1/{language_code}/tournaments/{tournament_id}/info"
self.sport, self.language_code, self.tournament_id
{sport}-t1/{language_code}/schedules/live/summaries"
self.sport, self.language_code
{sport}-t1/{language_code}/tournaments/{tournament_id}/results"
self.sport, self.language_code, self.tournament_id
{sport}-t1/{language_code}/tournaments/{tournament_id}/schedule"
self.sport, self.language_code, self.tournament_id
{sport}-t1/{language_code}/tournaments/{tournament_id}/seasons"
self.sport, self.language_code, self.tournament_id
{sport}-t1/{language_code}/tournaments/{tournament_id}/standings"
self.sport, self.language_code, self.tournament_id
{sport}-t1/{language_code}/tournaments/{tournament_id}/summaries"
self.sport, self.language_code, self.tournament_id
{sport}-t1/{language_code}/tournaments"
self.sport, self.language_code

In [ ]: