Skip to content

Data Types: Schedule

MattsFace edited this page Dec 29, 2022 · 4 revisions

Schedule Structure

Attributes are expandable and collapsable - Link to Schedule dataclass

totalitems : int
  • Total items in schedule
totalevents : int
  • Total events in schedule
totalgames : int
  • Total games in schedule
totalgamesinprogress : int
  • Total games in progress in schedule
dates : ScheduleDates
date : str
  • Date for the group of games
totalitems : int
  • Total amount of items for this date
totalevents : int
  • The number of events for this date
totalgames : int
  • The number of games for this date
totalgamesinprogress : int
  • The number of games that are currently in progress for this date
games : List[ScheduleGames]
gamepk : int
  • The games id number
link : str
  • The link for this game
gametype : str
  • This games game type
season : str
  • The season this game takes place in
gamedate : str
  • The date for this game
officialdate : str
  • The official date for this game
status : GameStatus
abstractgamestate : str
  • The abstract game state
codedgamestate : str
  • The coded game state
detailedstate : str
  • The detailed game state
statuscode : str
  • Status code for this game
starttimetbd : bool
  • If the start time is TBD
abstractgamecode : str
  • The abstract game code
reason : str
  • reason for a state. Usually used for delays or cancellations
teams : ScheduleHomeAndAway
home : ScheduleGameTeam
leaguerecord : LeagueRecord
wins : int
  • number of wins in leaguerecord
losses : int
  • number of losses in leaguerecord
ties : int
  • number of ties in leaguerecord
pct : str
  • winning pct of leaguerecord
score : int
  • Current score for this team in this game
team : Team
id : int
  • Team id
name : str
  • The teams name
link : str
  • The link for this team
iswinner : bool
  • If this team is the winner of this game
splitsquad : bool
  • Split squad
seriesnumber : int
  • Series number
away : ScheduleGameTeam
leaguerecord : LeagueRecord
wins : int
  • number of wins in leaguerecord
losses : int
  • number of losses in leaguerecord
ties : int
  • number of ties in leaguerecord
pct : str
  • winning pct of leaguerecord
score : int
  • Current score for this team in this game
team : Team
id : int
  • Team id
name : str
  • The teams name
link : str
  • The link for this team
iswinner : bool
  • If this team is the winner of this game
splitsquad : bool
  • Split squad
seriesnumber : int
  • Series number
venue : Venue
  • The venue this game takes place in. Dataclass: Venue
id : int
  • id for this venue
name : str = None
  • Name for this venue
link : str
  • Link to venues endpoint
content : dict
  • Content for this game. Havent found a populated reference yet. Stays as dict
istie : bool
  • If this game is a tie
gamenumber : int
  • Game number for this game
publicfacing : bool
  • Is this game public facing
doubleheader : str
  • The double header status for this game, "n','y'?
gamedaytype : str
  • The type of gameday for this game
tiebreaker : str
  • Tie breaker for this game, 'n','y'?
calendareventid : str
  • Calender event Id for this game
seasondisplay : str
  • Displayed season for this game
daynight : str
  • Day or night game as a string, 'am','pm'?
scheduledinnings : int
  • Number of scheduled inning for the game
reversehomeawaystatus : bool
  • If reverse home and away?
inningbreaklength : int
  • Length of break between innings
gamesinseries : int
  • Number of games in current series
seriesgamenumber : int
  • Game number in the current series
seriesdescription : str
  • Description of this current series
recordsource : str
  • Record source
ifnecessary : str
  • If necessary
ifnecessarydescription : str
  • If necessary description
rescheduledate : str
  • If game is rescheduled, this is the rescheduled date
reschedulegamedate : str
  • rescheduled game date
rescheduledfrom : str
  • rescheduled from
rescheduledfromdate : str
  • rescheduled from date
istie : bool
  • Is tie
events : list
  • A list of events for this date. Need to handle this but cant find a populated reference for this object. It stays as a list for now.

Usage that returns Schedule objects

get_schedule

Description: Returns a schedule object

Parameters:

Name Type Required Description Default
date string Yes Date
start_date string Yes Start date "yyyy-mm-dd"
end_date string Yes End date "yyyy-mm-dd"
sport_id string/int Yes Sport ID of schedule 1
team_id string/int No Team ID of schedule

Other Parameters:

Name Type Required Description Default
leagueId string Yes Insert leagueId to return all schedules based on a particular scheduleType for a specific league
gamePks string Yes Insert gamePks to return all schedules based on a particular scheduleType for specific games.
venueIds string Yes Insert venueId to return all schedules based on a particular scheduleType for a specific venueId.
gameTypes string Yes Insert gameTypes to return schedule information for all games in particular gameTypes. For a list of all gameTypes: https://statsapi.mlb.com/api/v1/gameTypes

Example output from MLB stats api endpoint

Mlb stats api Query:

https://statsapi.mlb.com/api/v1/schedule?sportId=1

Equivelant with python-mlb-statsapi:

>>> import mlbstatsapi
>>>
>>> mlb = mlbstatsapi.Mlb()
>>>
>>> schedule = mlb.get_schedule('2022-10-13')
>>>
>>> print(schedule)
Schedule(totalitems=2, totalevents=0, totalgames=2, totalgamesinprogress=0, dates=[ScheduleDates(date=2022-10-13, totalgames=2)])
>>>
>>> dates = schedule.dates
>>> for date in dates:
...     for game in date.games:
...             print(game.teams.home)
...             print(game.teams.away)
...
ScheduleGameTeam(gamepk=LeagueRecord(wins=2, losses=0, pct='1.000', ties=None), team=Team(id=117, link=/api/v1/teams/117, name=Houston Astros))
ScheduleGameTeam(gamepk=LeagueRecord(wins=0, losses=2, pct='.000', ties=None), team=Team(id=136, link=/api/v1/teams/136, name=Seattle Mariners))
ScheduleGameTeam(gamepk=LeagueRecord(wins=1, losses=1, pct='.500', ties=None), team=Team(id=147, link=/api/v1/teams/147, name=New York Yankees))
ScheduleGameTeam(gamepk=LeagueRecord(wins=1, losses=1, pct='.500', ties=None), team=Team(id=114, link=/api/v1/teams/114, name=Cleveland Guardians))