Skip to content

Data Types: Sports

MattsFace edited this page Dec 29, 2022 · 4 revisions

Sport Structure

Attributes are expandable and collapsable - Link to Sport dataclass

id : int
  • id number of the sport
link : str
  • link of the sport
name : str
  • name the sport
code : str
  • Sport code
abbreviation : str
  • Abbreviation for the sport
sortorder : int
  • Some sort of sorting order
activestatus : bool
  • Is the sport active

Usage that returns Sport objects

get_sport

Description: Returns sport object from sport_id

Parameters:

Name Type Required Description Default
sport_id string/int Yes description

Other Parameters:

Name Type Required Description Default
fields string No Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute

get_sports

Description: Return all sports

Other Parameters:

Name Type Required Description Default
fields string No Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute

get_sport_id


Description: Return sport id

Parameters:

Name Type Required Description Default
sport_name string Yes Sport name
search_key string No Search key name 'name'

Example output from MLB stats api endpoint

Mlb stats api Query:

http://statsapi.mlb.com/api/v1/sports

Equivelant with python-mlb-statsapi:

>>> import mlbstatsapi
>>>
>>> mlb = mlbstatsapi.Mlb()
>>>
>>> sport_id = mlb.get_sport_id("Major League Baseball")
>>>
>>> print(sport_id)
[1]
>>> sport = mlb.get_sport(sport_id[0])
>>>
>>> print(sport)
Sport(id=1, link=/api/v1/sports/1, name=Major League Baseball, code=mlb, abbreviation=MLB, sortorder=11, activestatus=True)
>>>