Skip to content

Data Types: League

MattsFace edited this page Dec 29, 2022 · 5 revisions

League Structure

Attributes are expandable and collapsable - Link to League dataclass

id : int
  • id number of the league
name : str
  • name of the league
link : str
  • link of the league
abbreviation : str
  • abbreviation the league
nameshort : str
  • Short name for the league
seasonstate : str
  • State of the leagues season
haswildcard : bool
  • Status of the leagues wildcard
hassplitseason : bool
  • Status of the leagues split season
numgames : int
  • Total number of league games
hasplayoffpoints : bool
  • Status of the leagues playoff points
numteams : int
  • Total number of team in league
numwildcardteams : int
  • Total number of wildcard teams in league
seasondateinfo : Season
  • LeagueSeasonDateInfo attribue. Dataclass: Season
seasonid : str
  • season id
haswildcard : bool
  • wild card status
preseasonstartdate : str
  • pre-season start date
preseasonenddate : str
  • pre-season end date
seasonstartdate : str
  • season start date
springstartdate : str
  • spring start date
springenddate : str
  • spring end date
regularseasonstartdate : str
  • regular season start date
lastdate1sthalf : str
  • last date 1st half
allstardate : str
  • all star date
firstdate2ndhalf : str
  • first date 2nd half
regularseasonenddate : str
  • regular season end date
postseasonstartdate : str
  • post season start date
postseasonenddate : str
  • post season end date
seasonenddate : str
  • season end date
offseasonstartdate : str
  • off season start date
offseasonenddate : str
  • off season end date
seasonlevelgamedaytype : str
  • season level game day type
gamelevelgamedaytype : str
  • game level game day type
qualifierplateappearances : float
  • qualifier plate appearances
qualifieroutspitched : int
  • qualifier outs pitched
season : str
  • League season
orgcode : str
  • Leagues orginization code
conferencesinuse : bool
  • Status of the in use conferences of the league
divisionsinuse : bool
  • Status of leagues divisions in use
sport : Sport
  • What 'sport' this league is a part of. Dataclass: Sport
id : int
  • id number of the sport
link : str
  • link of the sport
sortorder : int
  • League sort order
active : bool
  • Status on the activity of the league

Usage that returns League objects

get_league

Description: Returns

Parameters:

Name Type Required Description Default
league_id string Yes leagueId to return league information for a specific league

Other Parameters:

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

get_leagues

Description: Return all leagues

Other Parameters:

Name Type Required Description Default
leagueId string No leagueId(s) to return league information for specific leagues. Format '103,104'
sportId string No Insert sportId to return league information for a specific sport. For a list of all sportIds: http://statsapi.mlb.com/api/v1/sports
season string No Insert year(s) to return league information for a specific season.
fields string No Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute

get_league_id


Description: Return league id

Parameters:

Name Type Required Description Default
league_name string Yes League name

Example output from MLB stats api endpoint

Mlb stats api Query:

https://statsapi.mlb.com/api/v1/league?leagueIds=103&seasons=2018

Equivelant with python-mlb-statsapi:

>>> import mlbstatsapi
>>>
>>> mlb = mlbstatsapi.Mlb()
>>>
>>> league_id = mlb.get_league_id("American League")
>>>
>>> print(league_id)
[103]
>>>
>>> league = mlb.get_league(league_id = 103, season = 2018)
>>>
>>> print(league)
League(id=103, link=/api/v1/league/103, name=American League, abbreviation=AL, nameshort=American, seasonstate=offseason, haswildcard=True, hassplitseason=False, numgames=162, hasplayoffpoints=False, numteams=15, numwildcardteams=2, seasondateinfo=Season(seasonid=2018, preseasonstartdate=2018-02-21, preseasonenddate=2018-03-27, seasonstartdate=2018-02-23, springstartdate=2018-02-23, springenddate=2018-03-27, regularseasonstartdate=2018-03-29, lastdate1sthalf=2018-07-15, allstardate=2018-07-17, firstdate2ndhalf=2018-07-19, regularseasonenddate=2018-10-01, postseasonstartdate=2018-10-03, postseasonenddate=2018-10-28, seasonenddate=2018-10-28, offseasonstartdate=2018-10-29, offseasonenddate=2019-02-20, seasonlevelgamedaytype=P, gamelevelgamedaytype=P, qualifierplateappearances=3.1, qualifieroutspitched=6000.0), season=2018, orgcode=AL, conferencesinuse=False, divisionsinuse=True, sport=Sport(id=1, link=/api/v1/sports/1), sortorder=21, active=True)