Skip to content

Data Types: Attendance

KCNilssen edited this page Dec 16, 2022 · 15 revisions

Attendance Structure

Attributes are expandable and collapsable - Link to attendance dataclass

aggregatetotals : AttendanceTotals
openingstotalaway : int
  • Total amount of opening game attendance number
openingstotalhome : int
  • Total amount of opening home game attendance number
openingstotallost : int
  • Total amount of opening games lost
openingstotalytd : int
  • Total amount of opening games year to date
attendanceaverageaway : int
  • Average away game attendance
attendanceaveragehome : int
  • Average home game attendance
attendanceaverageytd : int
  • Average attendance year to date
attendancehigh : int
  • Attendance high
attendancehighdate : str
  • Attendance high date
attendancetotal : int
  • Attendance total
attendancetotalaway : int
  • Attendace total away
attendancetotalhome : int
  • Attendance total home
records : List[AttendanceRecords]
openingstotal : int
  • Total amount of openings
openingstotalaway : int
  • Total amount of opening away games
openingstotalhome : int
  • Total amount of opening home games
openingstotallost : int
  • Total amount of openings lost
gamestotal : int
  • Total amount of games
gamesawaytotal : int
  • Total amount of away games
gameshometotal : int
  • Total amount of home games
year : str
  • Year as a string
attendanceaverageaway : int
  • Average attendance for away games
attendanceaveragehome : int
  • Average attendance for home games
attendanceaverageytd : int
  • Average attendance year to date
attendancehigh : int
  • Attendance High number
attendancehighdate : str
  • Attendance high date
attendancehighgame : AttendanceHighLowGame
gamepk : int
  • Games Id number
link : str
  • games endpoint link
content : AttendanceHighLowGameContent
link : str
  • games content endpoint link
daynight : str
  • Type of time of day for game
attendancelow : int
  • Attendance low number
attendancelowdate : str
  • Attendance low date
attendancelowgame : AttendanceHighLowGame
gamepk : int
  • Games Id number
link : str
  • games endpoint link
content : AttendanceHighLowGameContent
link : str
  • games content endpoint link
daynight : str
  • Type of time of day for game
attendanceopeningaverage : int
  • Attendance opening average
attendancetotal : int
  • Attendance total
attendancetotalaway : int
  • Attendance total away
attendancetotalhome : int
  • Attendance total home
gametype : AttendenceGameType
id : str
  • Game type id
description : str
  • Game type description
team : Team
  • Team

Usage that returns Attendance objects

get_attendance

Description: Returns attendance data based on teamId, leagueId, or leagueListId. Required Parameters (at least one)

Parameters: At least one is required

Name Type Required Description Default
team_id Int Yes Insert a teamId to return directory of attendnace for a given team None
league_id Int/List[int] Yes Insert leagueId(s) to return a directory of attendanace for a specific league. Format '103,104' None
league_list_id Str Yes Insert a unique League List Identifier to return a directory of attendanace for a specific league listId. List of Options None

Other Parameters:

Name Type Required Description Default
season int No Insert year(s) to return a directory of attendance for a given season. Season year number format yyyy None
date string No Insert date to return information for attendance on a particular date. Format: MM/DD/YYYY None
gametype string No Insert gameType(s) a directory of attendance for a given gameType. For a list of all gameTypes: https://statsapi.mlb.com/api/v1/gameTypes None

Example output from MLB stats api endpoint

Mlb stats api Query:

https://statsapi.mlb.com/api/v1/attendance?teamId=110&leagueId=103&season=2014&leagueListId=mlb&gameType=D

Equivelant with python-mlb-statsapi:

import mlbstatsapi

mlb = mlbstatsapi.Mlb()

mlb.get_attendance(team_id = 110, league_id = 103, league_list_id = 'mlb', gameType = 'd', season = 2014)
Clone this wiki locally