Major League Baseball Attendance API
The attendance endpoints handle game and season attendance and openings numbers by team.
The attendance endpoints handle game and season attendance and openings numbers by team.
openapi: 3.0.1
info:
title: Stats API Documentation Analytics Attendance API
description: Official API for Major League Baseball.
version: 2.0.0
servers:
- url: https://statsapi.mlb.com
description: Production
- url: https://beta-statsapi.mlb.com
description: Beta
- url: https://qa-statsapi.mlb.com
description: QA
- url: http://localhost:8080
description: Local
tags:
- name: Attendance
description: The attendance endpoints handle game and season attendance and openings numbers by team.
paths:
/api/v1/attendance:
get:
tags:
- Attendance
summary: Get team attendance
operationId: getTeamAttendance
parameters:
- name: teamId
in: query
description: 'Unique Team Identifier. Format: 141, 147, etc'
required: false
schema:
uniqueItems: true
type: array
items:
type: integer
format: int32
- name: leagueId
in: query
description: Comma delimited list of Unique league identifiers
required: false
schema:
uniqueItems: true
type: array
items:
type: integer
format: int32
- name: season
in: query
description: Comma delimited list of Seasons of play
required: false
schema:
type: array
items:
type: string
- name: leagueListId
in: query
description: Unique League List Identifier
required: false
schema:
$ref: '#/components/schemas/LeagueListsEnum'
- name: gameType
in: query
description: Type of Game. Available types in /api/v1/gameTypes
required: false
schema:
uniqueItems: true
type: array
items:
$ref: '#/components/schemas/GameTypeEnum'
- name: date
in: query
description: 'Date of Game. Format: YYYY-MM-DD'
required: false
schema:
type: string
format: date
- name: startDate
in: query
description: 'Start date for range of data (must be used with end date). Format: MM/DD/YYYY'
required: false
schema:
type: string
format: date
- name: endDate
in: query
description: 'End date for range of data (must be used with start date). Format: MM/DD/YYYY'
required: false
schema:
type: string
format: date
- name: fields
in: query
description: 'Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute'
required: false
schema:
uniqueItems: true
type: array
items:
type: string
responses:
'200':
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/AttendanceRestObject'
post:
tags:
- Attendance
summary: Get team attendance
operationId: getTeamAttendance_1
parameters:
- name: teamId
in: query
description: 'Unique Team Identifier. Format: 141, 147, etc'
required: false
schema:
uniqueItems: true
type: array
items:
type: integer
format: int32
- name: leagueId
in: query
description: Comma delimited list of Unique league identifiers
required: false
schema:
uniqueItems: true
type: array
items:
type: integer
format: int32
- name: season
in: query
description: Comma delimited list of Seasons of play
required: false
schema:
type: array
items:
type: string
- name: leagueListId
in: query
description: Unique League List Identifier
required: false
schema:
$ref: '#/components/schemas/LeagueListsEnum'
- name: gameType
in: query
description: Type of Game. Available types in /api/v1/gameTypes
required: false
schema:
uniqueItems: true
type: array
items:
$ref: '#/components/schemas/GameTypeEnum'
- name: date
in: query
description: 'Date of Game. Format: YYYY-MM-DD'
required: false
schema:
type: string
format: date
- name: startDate
in: query
description: 'Start date for range of data (must be used with end date). Format: MM/DD/YYYY'
required: false
schema:
type: string
format: date
- name: endDate
in: query
description: 'End date for range of data (must be used with start date). Format: MM/DD/YYYY'
required: false
schema:
type: string
format: date
- name: fields
in: query
description: 'Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute'
required: false
schema:
uniqueItems: true
type: array
items:
type: string
responses:
'200':
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/AttendanceRestObject'
components:
schemas:
TeamStatData:
type: object
properties:
requestingUserRole:
$ref: '#/components/schemas/Role'
note:
type: string
summary:
type: object
additionalProperties:
type: string
writeOnly: true
catchersInterference:
type: integer
format: int32
average:
type: string
onBasePercentage:
type: string
onBasePlusSlugging:
type: string
stolenBases:
type: integer
format: int32
caughtStealing:
type: integer
format: int32
slugging:
type: string
outs:
type: integer
format: int32
gidp:
type: integer
format: int32
gitp:
type: integer
format: int32
homeRuns:
type: integer
format: int32
numberOfPitches:
type: integer
format: int32
totalBases:
type: integer
format: int32
gidpOpportunites:
type: integer
format: int32
walks:
type: integer
format: int32
hitByPitch:
type: integer
format: int32
strikeouts:
type: integer
format: int32
airOuts:
type: integer
format: int32
goAo:
type: string
pitchesPerPlateAppearance:
type: number
format: double
intentionalWalks:
type: integer
format: int32
groundOuts:
type: integer
format: int32
flyOuts:
type: integer
format: int32
games:
type: integer
format: int32
gamesStarted:
type: integer
format: int32
doubles:
type: integer
format: int32
hits:
type: integer
format: int32
triples:
type: integer
format: int32
singles:
type: integer
format: int32
runs:
type: integer
format: int32
atBats:
type: integer
format: int32
pickoffs:
type: integer
format: int32
stolenBasePercentage:
type: string
wildPitches:
type: integer
format: int32
sacFlies:
type: integer
format: int32
sacBunts:
type: integer
format: int32
putouts:
type: integer
format: int32
assists:
type: integer
format: int32
chances:
type: integer
format: int32
streak:
type: integer
format: int32
battingOrder:
type: string
totalSwings:
type: integer
format: int32
swingsAndMisses:
type: integer
format: int32
ballsInPlay:
type: integer
format: int32
popOuts:
type: integer
format: int32
lineOuts:
type: integer
format: int32
flyHits:
type: integer
format: int32
popHits:
type: integer
format: int32
lineHits:
type: integer
format: int32
groundHits:
type: integer
format: int32
winStreak:
type: integer
format: int32
lossStreak:
type: integer
format: int32
plateAppearances:
type: integer
format: int32
stolenBasePercentageOrNull:
type: string
pitchesPerPlateAppearanceStr:
type: string
AdditionalBio:
type: object
properties:
id:
type: integer
format: int32
homeTown:
type: string
GameStatusRestObject:
type: object
properties:
copyright:
type: string
isCurrentBatter:
type: boolean
isCurrentPitcher:
type: boolean
isOnBench:
type: boolean
isSubstitute:
type: boolean
DraftTypeEnum:
type: string
enum:
- JR
- JS
- NS
- NR
- RV
- AL
- RA
- RT
- JD
- AD
DraftTypeEnumRestObject:
type: object
properties:
copyright:
type: string
code:
type: string
description:
type: string
WeatherRestObject:
type: object
properties:
copyright:
type: string
condition:
type: string
temp:
type: string
wind:
type: string
BaseballDefenseRestObject:
type: object
properties:
copyright:
type: string
pitcher:
$ref: '#/components/schemas/BaseballPersonRestObject'
catcher:
$ref: '#/components/schemas/BaseballPersonRestObject'
first:
$ref: '#/components/schemas/BaseballPersonRestObject'
second:
$ref: '#/components/schemas/BaseballPersonRestObject'
third:
$ref: '#/components/schemas/BaseballPersonRestObject'
shortstop:
$ref: '#/components/schemas/BaseballPersonRestObject'
left:
$ref: '#/components/schemas/BaseballPersonRestObject'
center:
$ref: '#/components/schemas/BaseballPersonRestObject'
right:
$ref: '#/components/schemas/BaseballPersonRestObject'
batter:
$ref: '#/components/schemas/BaseballPersonRestObject'
onDeck:
$ref: '#/components/schemas/BaseballPersonRestObject'
inHole:
$ref: '#/components/schemas/BaseballPersonRestObject'
battingOrder:
type: integer
format: int32
team:
$ref: '#/components/schemas/BaseballTeamRestObject'
EducationRestObject:
type: object
properties:
copyright:
type: string
highschools:
type: array
items:
$ref: '#/components/schemas/SchoolRestObject'
colleges:
type: array
items:
$ref: '#/components/schemas/SchoolRestObject'
StatContainer:
type: object
properties:
type:
$ref: '#/components/schemas/StatType'
group:
$ref: '#/components/schemas/StatGroup'
splits:
type: array
items:
$ref: '#/components/schemas/StatSplits'
splitsTiedWithOffset:
type: array
items:
$ref: '#/components/schemas/StatSplits'
splitsTiedWithLimit:
type: array
items:
$ref: '#/components/schemas/StatSplits'
stats:
$ref: '#/components/schemas/StatData'
totalSplits:
type: integer
format: int32
player:
$ref: '#/components/schemas/BaseballPerson'
team:
$ref: '#/components/schemas/BaseballTeam'
sport:
$ref: '#/components/schemas/Sport'
season:
type: string
gameType:
$ref: '#/components/schemas/GameTypeEnum'
playerPool:
$ref: '#/components/schemas/PlayerPoolEnum'
exemptions:
type: array
items:
$ref: '#/components/schemas/PlayerListPerson'
parameters:
type: object
additionalProperties:
type: object
disclaimers:
uniqueItems: true
type: array
items:
type: string
totalSplitsIfNotSet:
type: integer
format: int32
writeOnly: true
FieldInfoRestObject:
type: object
properties:
copyright:
type: string
capacity:
type: integer
format: int32
turfType:
type: string
roofType:
type: string
leftLine:
type: integer
format: int32
left:
type: integer
format: int32
leftCenter:
type: integer
format: int32
center:
type: integer
format: int32
rightCenter:
type: integer
format: int32
right:
type: integer
format: int32
rightLine:
type: integer
format: int32
BaseballTeamStandingsRecord:
type: object
properties:
team:
$ref: '#/components/schemas/BaseballTeam'
wins:
type: integer
format: int32
losses:
type: integer
format: int32
ties:
type: integer
format: int32
gamesBack:
type: string
wildCardGamesBack:
type: string
leagueGamesBack:
type: string
springLeagueGamesBack:
type: string
sportGamesBack:
type: string
divisionGamesBack:
type: string
conferenceGamesBack:
type: string
divisionChamp:
type: boolean
season:
type: string
streak:
type: string
lastUpdated:
type: string
format: date-time
home:
type: string
away:
type: string
lastTen:
type: string
points:
type: integer
format: int32
clinchIndicator:
type: string
divisionRank:
type: string
conferenceRank:
type: string
springLeagueRank:
type: string
leagueRank:
type: string
sportRank:
type: string
wildCardRank:
type: string
gamesPlayed:
type: integer
format: int32
place:
type: integer
format: int32
wildcardPlace:
type: integer
format: int32
wildcardOdds:
type: number
format: double
divisionOdds:
type: number
format: double
playoffOdds:
type: number
format: double
runsAllowed:
type: integer
format: int32
runsScored:
type: integer
format: int32
hasWildcard:
type: boolean
clinched:
type: boolean
eliminationNumber:
type: string
eliminationNumberWildcard:
type: string
magicNumber:
type: string
hasPlayoffPoints:
type: boolean
vsWest:
type: string
vsCentral:
type: string
vsEast:
type: string
vsInterleague:
type: string
vsRight:
type: string
vsRightHomeWin:
type: string
vsRightHomeLoss:
type: string
vsRightAwayWin:
type: string
vsRightAwayLoss:
type: string
vsLeft:
type: string
vsLeftHomeWin:
type: string
vsLeftHomeLoss:
type: string
vsLeftAwayWin:
type: string
vsLeftAwayLoss:
type: string
vsWinners:
type: string
extraInnings:
type: string
expectedWinLoss:
type: string
expectedWinLossSeason:
type: string
oneRunGames:
type: string
turf:
type: string
grass:
type: string
night:
type: string
day:
type: string
isWildCardTeam:
type: boolean
writeOnly: true
isDivisionLeader:
type: boolean
writeOnly: true
divisionRecords:
type: array
items:
$ref: '#/components/schemas/WinLossRecord'
conferenceRecords:
type: array
items:
$ref: '#/components/schemas/WinLossRecord'
leagueRecords:
type: array
items:
$ref: '#/components/schemas/WinLossRecord'
splitRecords:
type: array
items:
$ref: '#/components/schemas/WinLossRecord'
expectedRecords:
type: array
items:
$ref: '#/components/schemas/WinLossRecord'
overallRecords:
type: array
items:
$ref: '#/components/schemas/WinLossRecord'
conference:
$ref: '#/components/schemas/Conference'
wildCardLeader:
type: boolean
runDifferental:
type: integer
format: int32
winningPercentage:
type: number
format: double
RunnerDetailType:
type: string
enum:
- START_BASE
- SEQUENCE
- RUNNER_GOING
- END_BASE
- RUNNER_OUT
- FORCED_OUT
- ADVANCED_ON_FORCE
- ADVANCED_ON_THROW
- ADVANCED_ON_PLAY
- DOUBLED_OFF
- THROWN_OUT
- TAGGED_OUT
- OUT_STRETCHING
- LEFT_EARLY
- FIELDERS_CHOICE
- OUT_ON_APPEAL
- OUT_ADVANCING
- DEFENSIVE_INDIFFERENCE
- INTERFERENCE
- HIT_BY_BATTED_BALL
- OUT_OVER_RUNNING
- OUT_RETURNING
- RUNDOWN
- CAUGHT_STEALING_2B
- CAUGHT_STEALING_3B
- CAUGHT_STEALING_HOME
- PICKOFF_CAUGHT_STEALING_2B
- PICKOFF_CAUGHT_STEALING_3B
- PICKOFF_CAUGHT_STEALING_HOME
- STOLEN_BASE_2B
- STOLEN_BASE_3B
- STOLEN_BASE_HOME
- PICKOFF_1B
- PICKOFF_2B
- PICKOFF_3B
- PICKOFF_ERROR_1B
- PICKOFF_ERROR_2B
- PICKOFF_ERROR_3B
- UNKNOWN
VenueMetadata:
type: object
properties:
active:
type: boolean
capacity:
type: integer
format: int32
startYear:
type: integer
format: int32
endYear:
type: integer
format: int32
types:
type: array
items:
$ref: '#/components/schemas/VenueTypeEnum'
Image:
type: object
properties:
images:
type: object
additionalProperties:
type: string
caption:
type: string
imageType:
$ref: '#/components/schemas/ImageTypeEnum'
url:
type: string
imageTypeAsString:
type: string
SportTypeEnum:
type: string
enum:
- ALL
- BASEBALL
- HOCKEY
- GOLF
- UNKNOWN
- BASKETBALL
IFeed:
type: object
properties:
date:
type: string
format: date-time
ScheduleDateRestObject:
type: object
properties:
copyright:
type: string
date:
type: string
format: date
totalItems:
type: integer
format: int32
totalEvents:
type: integer
format: int32
totalGames:
type: integer
format: int32
totalGamesInProgress:
type: integer
format: int32
games:
type: array
items:
$ref: '#/components/schemas/BaseballScheduleItemRestObject'
events:
type: array
items:
$ref: '#/components/schemas/ScheduleEventRestObject'
Venue:
type: object
properties:
requestingUserRole:
$ref: '#/components/schemas/Role'
id:
type: integer
format: int32
name:
type: string
city:
type: string
location:
$ref: '#/components/schemas/Location'
timeZone:
$ref: '#/components/schemas/TimeZone'
fieldInfo:
$ref: '#/components/schemas/FieldInfo'
sportType:
$ref: '#/components/schemas/SportTypeEnum'
relatedVenues:
type: array
items:
$ref: '#/components/schemas/Venue'
parentVenues:
type: array
items:
$ref: '#/components/schemas/Venue'
residentVenues:
type: array
items:
$ref: '#/components/schemas/Venue'
relatedApplications:
type: array
items:
$ref: '#/components/schemas/RelatedApplication'
relatedImages:
type: array
items:
$ref: '#/components/schemas/Image'
socialMediaInfo:
$ref: '#/components/schemas/SocialMediaInfo'
menu:
$ref: '#/components/schemas/VenueCms'
metadata:
$ref: '#/components/schemas/VenueMetadata'
schedule:
$ref: '#/components/schemas/BaseballSchedule'
nextSchedule:
$ref: '#/components/schemas/BaseballSchedule'
previousSchedule:
$ref: '#/components/schemas/BaseballSchedule'
xrefIds:
type: array
items:
$ref: '#/components/schemas/XrefId'
season:
type: string
trackingVersion:
$ref: '#/components/schemas/TrackingVersion'
coachingVideo:
uniqueItems: true
type: array
items:
$ref: '#/components/schemas/MediaSourceType'
appEnabled:
type: boolean
active:
type: boolean
timeZoneId:
type: string
writeOnly: true
GameInfoRestObject:
type: object
properties:
copyright:
type: string
attendance:
type: integer
format: int32
firstPitch:
type: string
format: date-time
gameDurationMinutes:
type: integer
format: int32
delayDurationMinutes:
type: integer
format: int32
LaunchDataRestObject:
type: object
properties:
copyright:
type: string
speed:
type: number
format: double
angle:
type: number
format: double
spinAxis:
type: number
format: double
direction:
type: number
format: double
spinRate:
type: number
format: double
BaseballDecisionRestObject:
type: object
properties:
copyright:
type: string
hydrations:
type: array
items:
type: string
winner:
$ref: '#/components/schemas/BaseballPersonRestObject'
loser:
$ref: '#/components/schemas/BaseballPersonRestObject'
save:
$ref: '#/components/schemas/BaseballPersonRestObject'
LiveLookin:
type: object
properties:
gamePk:
type: integer
format: int32
mediaPlaybackId:
type: integer
format: int64
kicker:
type: string
headline:
type: string
playbacks:
type: array
items:
$ref: '#/components/schemas/LiveLookinPlayback'
TransactionRestObject:
type: object
properties:
copyright:
type: string
id:
type: integer
format: int32
person:
$ref: '#/components/schemas/BaseballPersonRestObject'
fromTeam:
$ref: '#/components/schemas/BaseballTeamRestObject'
toTeam:
$ref: '#/components/schemas/BaseballTeamRestObject'
date:
type: string
format: date
effectiveDate:
type: string
format: date
resolutionDate:
type: string
format: date
type:
type: string
typeCode:
type: string
typeDesc:
type: string
isConditional:
type: boolean
description:
type: string
DraftStatusEnum:
type: string
enum:
- DRAFTED
- NOT_DRAFTED
- SKIPPED
- SELECTED
- NOT_SELECTED
Split:
type: object
properties:
copyright:
type: string
batter:
type: string
pitcher:
type: string
menOnBase:
type: string
Matchup:
type: object
properties:
copyright:
type: string
batter:
$ref: '#/components/schemas/BaseballPersonRestObject'
batSide:
$ref: '#/components/schemas/DynamicEnumRestObject'
pitcher:
$ref: '#/components/schemas/BaseballPersonRestObject'
pitchHand:
$ref: '#/components/schemas/DynamicEnumRestObject'
postOnFirst:
$ref: '#/components/schemas/BaseballPersonRestObject'
postOnSecond:
$ref: '#/components/schemas/BaseballPersonRestObject'
postOnThird:
$ref: '#/components/schemas/BaseballPersonRestObject'
batterHotColdZoneStats:
$ref: '#/components/schemas/StatsRestObject'
pitcherHotColdZoneStats:
$ref: '#/components/schemas/StatsRestObject'
batterHotColdZones:
type: array
items:
$ref: '#/components/schemas/BaseballHotColdZoneRestObject'
pitcherHotColdZones:
type: array
items:
$ref: '#/components/schemas/BaseballHotColdZoneRestObject'
splits:
$ref: '#/components/schemas/Split'
StatSplits:
type: object
properties:
requestingUserRole:
$ref: '#/components/schemas/Role'
season:
type: string
stat:
$ref: '#/components/schemas/StatData'
stats:
$ref: '#/components/schemas/GroupedStatData'
gameType:
$ref: '#/components/schemas/GameTypeEnum'
team:
$ref: '#/components/schemas/BaseballTeam'
player:
$ref: '#/components/schemas/BaseballPerson'
homeTeam:
$ref: '#/components/schemas/BaseballTeam'
awayTeam:
$ref: '#/components/schemas/BaseballTeam'
numTeams:
type: integer
format: int32
numOccurrences:
type: integer
format: int32
rank:
type: integer
format: int32
league:
$ref: '#/components/schemas/League'
sport:
$ref: '#/components/schemas/Sport'
opponent:
$ref: '#/components/schemas/BaseballTeam'
venue:
$ref: '#/components/schemas/Venue'
game:
$ref: '#/components/schemas/BaseballScheduleItem'
date:
type: string
format: date
lastDatePlayed:
type: string
format: date
gameNumber:
type: integer
format: int32
split:
$ref: '#/components/schemas/DynamicLookupEnum'
gamePk:
type: integer
format: int32
dayOfTheWeek:
type: integer
format: int32
month:
type: integer
format: int32
opposingDivision:
$ref: '#/components/schemas/Division'
opposingConference:
$ref: '#/components/schemas/Conference'
isHome:
type: boolean
isWin:
type: boolean
type:
$ref: '#/components/schemas/StatType'
group:
$ref: '#/components/schemas/StatGroup'
position:
$ref: '#/components/schemas/BaseballPosition'
gameInnings:
type: integer
format: int32
exemption:
$ref: '#/components/schemas/PlayerListPerson'
TrackingVersion:
type: string
enum:
- PITCH_FX
- STATCAST_2015_COMBINED
- STATCAST_2015_RADAR_ONLY_20
- STATCAST_2017_RADAR_ONLY_20
- STATCAST_2017_COMBINED_RADAR_20
- STATCAST_2018_COMBINED_RADAR_25
- STATCAST_2018_RADAR_ONLY_25
- STATCAST_2020_12_CAM
- STATCAST_2020_8_CAM
- TRACKMAN_V3
- STATCAST_2023_12_CAM
BaseballChallenge:
type: object
properties:
hasChallenges:
type: boolean
awayChallengesUsed:
type: integer
format: int32
awayChallengesRemaining:
type: integer
format: int32
homeChallengesUsed:
type: integer
format: int32
homeChallengesRemaining:
type: integer
format: int32
challengingTeam:
$ref: '#/components/schemas/BaseballTeam'
reviewReason:
type: string
limit9thInning:
type: integer
format: int32
PlayerPoolEnum:
type: string
enum:
- ALL
- QUALIFIED
- ROOKIES
- QUALIFIED_ROOKIES
- ORGANIZATION
- ORGANIZATION_NO_MLB
- CURRENT
- ALL_CURRENT
- QUALIFIED_CURRENT
ScheduleEventTypes:
type: string
enum:
- ALL_STAR_WEEKEND_EVENT
- TEAM_EVENT
- EXHIBITION
- POSTSEASON_GAMES
- SPRING_TRAINING_GAMES
- PITCHERS_AND_CATCHERS_REPORT
- FULL_SQUAD_REPORTS
- STH_EVENTS
- BALLPARK_TOURS
- IMPORTANT_DATES
- OTHER
- CULTURAL_EVENTS
- TRACKING_DATA_EVENTS
- FESTIVAL
- KIDS_AND_FAMILY
- MUSIC
- PROMOTION_LOGO_BACKGROUND
- PROMOTION_LOGO_SINGE_DATE
- STUDIO_EVENT
Broadcast:
type: object
properties:
name:
type: string
type:
type: string
language:
$ref: '#/components/schemas/Language'
site:
$ref: '#/components/schemas/Site'
id:
type: integer
format: int32
homeAway:
type: string
sortOrder:
type: integer
format: int32
isNational:
type: boolean
sourceUrl:
type: string
callSign:
type: string
videoResolution:
$ref: '#/components/schemas/VideoResolutionEnum'
StatExemptionRestObject:
type: object
properties:
copyright:
type: string
exemptionId:
type: string
exemptionName:
type: string
player:
$ref: '#/components/schemas/BaseballPersonRestObject'
PlayerLeader:
type: object
properties:
rank:
type: integer
format: int32
value:
type: string
team:
$ref: '#/components/schemas/BaseballTeam'
league:
$ref: '#/components/schemas/League'
person:
$ref: '#/components/schemas/BaseballPerson'
sport:
$ref: '#/components/schemas/Sport'
season:
type: string
numTeams:
type: integer
format: int32
Coordinates:
type: object
properties:
x:
type: number
format: double
y:
type: number
format: double
z:
type: number
format: double
GroupedStatDataRestObject:
type: object
properties:
# --- truncated at 32 KB (229 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/major-league-baseball/refs/heads/main/openapi/major-league-baseball-attendance-api-openapi.yml