-
Notifications
You must be signed in to change notification settings - Fork 10
Data Types: Sports
MattsFace edited this page Dec 29, 2022
·
4 revisions
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
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 |
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 |
Description: Return sport id
Parameters:
Name | Type | Required | Description | Default |
---|---|---|---|---|
sport_name |
string | Yes | Sport name | |
search_key |
string | No | Search key name | 'name' |
http://statsapi.mlb.com/api/v1/sports
>>> 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)
>>>
Note: This information is provided for reference only, without warranty or guarantee, and is not official documentation provided by MLB. This package and its author are not affiliated with MLB or any MLB team. This API wrapper interfaces with MLB's Stats API. Use of MLB data is subject to the notice posted at http://gdx.mlb.com/components/copyright.txt.