Skip to content

Data Types: League

KCNilssen edited this page Dec 16, 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
seasons 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

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()

mlb.get_league(league_id = 103, seasons = 2018)

Clone this wiki locally