Skip to content

Data Types: Season

MattsFace edited this page Dec 30, 2022 · 4 revisions

Season Structure

Attributes are expandable and collapsable - Link to Season dataclass

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

Usage that returns Season objects

get_season

Description: Returns a Season

Parameters:

Name Type Required Description Default
season_id string/int Yes Insert year to return season information for a particular season.
sport_id string/int No Insert a sportId to return a directory of seasons for a specific sport. 1

Other Parameters:

Name Type Required Description Default
withGameTypeDates bool No Insert a withGameTypeDates to return season information for all gameTypes.
fields string/int No Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute

get_seasons

Description: Return a list of Seasons

Parameters:

Name Type Required Description Default
sport_id string/int Yes Insert a sportId to return a directory of seasons for a specific sport. 1

Other Parameters:

Name Type Required Description Default
divisionId string/int No Insert divisionId to return a directory of seasons for a specific division.
leagueId string/int No Insert leagueId to return a directory of seasons in a specific league.
withGameTypeDates bool No Insert a withGameTypeDates to return season information for all gameTypes.
fields string/int 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/seasons?sportId=1

Equivelant with python-mlb-statsapi:

>>> import mlbstatsapi
>>>
>>> mlb = mlbstatsapi.Mlb()
>>>
>>> seasons = mlb.get_seasons(sport_id=1)
>>>
>>> print(seasons)
[Season(seasonid=1876), Season(seasonid=1877), Season(seasonid=1878), ..., Season(seasonid=2022)]
>>> 
>>> season = mlb.get_season(season_id=2022)
>>> 
>>> print(season)
Season(seasonid=2022, haswildcard=True, preseasonstartdate=2022-01-01, preseasonenddate=2022-03-16, seasonstartdate=2022-03-17, springstartdate=2022-03-17, springenddate=2022-04-06, regularseasonstartdate=2022-04-07, lastdate1sthalf=2022-07-17, allstardate=2022-07-19, firstdate2ndhalf=2022-07-21, regularseasonenddate=2022-10-05, postseasonstartdate=2022-10-07, postseasonenddate=2022-11-05, seasonenddate=2022-11-05, offseasonstartdate=2022-11-06, offseasonenddate=2022-12-31, seasonlevelgamedaytype=P, gamelevelgamedaytype=P, qualifierplateappearances=3.1, qualifieroutspitched=6000.0)