mlbstats/api/docs/GameApi.md

22 KiB

{{classname}}

All URIs are relative to https://statsapi.mlb.com

Method HTTP request Description
Boxscore Get /api/v1/game/{game_pk}/boxscore Get game boxscore.
ColorFeed Get /api/v1/game/{game_pk}/feed/color Get game color feed.
ColorTimestamps Get /api/v1/game/{game_pk}/feed/color/timestamps Retrieve all of the color timestamps for a game.
Content Get /api/v1/game/{game_pk}/content Retrieve all content for a game.
CurrentGameStats1 Get /api/v1/game/changes View a game change log
GetGameContextMetrics Get /api/v1/game/{gamePk}/contextMetrics Get the context metrics for this game based on its current state
GetGameWithMetrics Get /api/v1/game/{gamePk}/withMetrics Get game info with metrics
GetWinProbability Get /api/v1/game/{gamePk}/winProbability Get the win probability for this game
Linescore Get /api/v1/game/{game_pk}/linescore Get game linescore
LiveGameDiffPatchV1 Get /api/v1.1/game/{game_pk}/feed/live/diffPatch Get live game status diffPatch.
LiveGameV1 Get /api/v1.1/game/{game_pk}/feed/live Get live game status.
LiveTimestampv11 Get /api/v1.1/game/{game_pk}/feed/live/timestamps Retrieve all of the play timestamps for a game.
PlayByPlay Get /api/v1/game/{game_pk}/playByPlay Get game play By Play

Boxscore

BaseballBoxscoreRestObject Boxscore(ctx, gamePk, optional) Get game boxscore.

This endpoint allows you to pull a boxscore

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiBoxscoreOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiBoxscoreOpts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute | inclusiveTimecode | optional.Bool| True to include plays that happen before or at the specified timecode | numPlayers | optional.Int32| Number of top player game scores to show. Default is 3. | [default to 3] noTies | optional.Bool| If set to false, will show all players tied for the last spot in the game scores list. | accent | optional.Bool| Boolean value to specify wanting a person's name with accents or without |

Return type

BaseballBoxscoreRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ColorFeed

string ColorFeed(ctx, gamePk, optional) Get game color feed.

This API can return very large payloads. It is STRONGLY recommended that clients ask for diffs and use "Accept-Encoding: gzip" header.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiColorFeedOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiColorFeedOpts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute |

Return type

string

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ColorTimestamps

[]string ColorTimestamps(ctx, gamePk) Retrieve all of the color timestamps for a game.

This can be used for replaying games. Endpoint returns all of the timecodes that can be used with diffs for /v1/game/{game_pk}/feed/color

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game

Return type

[]string

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Content

GameContentRestObject Content(ctx, gamePk, optional) Retrieve all content for a game.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32
optional *GameApiContentOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiContentOpts struct

Name Type Description Notes

highlightLimit | optional.Int32| Number of results to return |

Return type

GameContentRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CurrentGameStats1

ScheduleRestObject CurrentGameStats1(ctx, optional) View a game change log

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optional *GameApiCurrentGameStats1Opts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiCurrentGameStats1Opts struct

Name Type Description Notes
updatedSince optional.Time Format: YYYY-MM-DDTHH:MM:SSZ
sportId optional.Int32 Top level organization of a sport
sportIds **optional.Interface of []int32** Comma delimited list of top level organizations of a sport
gameType optional.Interface of GameTypeEnum Type of Game. Available types in /api/v1/gameTypes
gameTypes **optional.Interface of []GameTypeEnum** Comma delimited list of type of Game. Available types in /api/v1/gameTypes
season optional.String Season of play
gamePks **optional.Interface of []int32** Comma delimited list of unique primary keys
limit optional.Int32 Number of results to return
offset optional.Int32 The pointer to start for a return set; used for pagination
fields **optional.Interface of []string** Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute

Return type

ScheduleRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetGameContextMetrics

BaseballGameContextRestObject GetGameContextMetrics(ctx, gamePk, optional) Get the context metrics for this game based on its current state

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiGetGameContextMetricsOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiGetGameContextMetricsOpts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute |

Return type

BaseballGameContextRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetGameWithMetrics

BaseballGameRestObject GetGameWithMetrics(ctx, gamePk, optional) Get game info with metrics

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiGetGameWithMetricsOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiGetGameWithMetricsOpts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | inclusiveTimecode | optional.Bool| True to include plays that happen before or at the specified timecode | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute | accent | optional.Bool| Boolean value to specify wanting a person's name with accents or without |

Return type

BaseballGameRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetWinProbability

[]BaseballPlayRestObject GetWinProbability(ctx, gamePk, optional) Get the win probability for this game

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiGetWinProbabilityOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiGetWinProbabilityOpts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute | inclusiveTimecode | optional.Bool| True to include plays that happen before or at the specified timecode | accent | optional.Bool| Boolean value to specify wanting a person's name with accents or without |

Return type

**[]BaseballPlayRestObject**

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: /

[Back to top] [Back to API list] [Back to Model list] [Back to README]

Linescore

BaseballLinescoreRestObject Linescore(ctx, gamePk, optional) Get game linescore

This endpoint allows you to pull the linescore for a game

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiLinescoreOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiLinescoreOpts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute | inclusiveTimecode | optional.Bool| True to include plays that happen before or at the specified timecode |

Return type

BaseballLinescoreRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

LiveGameDiffPatchV1

string LiveGameDiffPatchV1(ctx, gamePk, optional) Get live game status diffPatch.

This endpoint allows comparison of game files and shows any differences/discrepancies between the two

Diff/Patch System: startTimecode and endTimecode can be used for getting diffs.
Expected usage:
1) Request full payload by not passing startTimecode or endTimecode. This will return the most recent game state.
2) Find the latest timecode in this response.
3) Wait X seconds
4) Use the timecode from 2 as the startTimecode. This will give you a diff of everything that has happened since startTimecode.
5) If no data is returned, wait X seconds and do the same request.
6) If data is returned, get a new timeStamp from the response, and use that for the next call as startTimecode.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiLiveGameDiffPatchV1Opts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiLiveGameDiffPatchV1Opts struct

Name Type Description Notes

startTimecode | optional.String| Start time code will give you everything since that time. Format: MMDDYYYY_HHMMSS | endTimecode | optional.String| End time code will give you a snapshot at that specific time. Format: MMDDYYYY_HHMMSS | accent | optional.Bool| Boolean value to specify wanting a person's name with accents or without |

Return type

string

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

LiveGameV1

BaseballGameRestObject LiveGameV1(ctx, gamePk, optional) Get live game status.

This API can return very large payloads. It is STRONGLY recommended that clients ask for diffs and use "Accept-Encoding: gzip" header.

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiLiveGameV1Opts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiLiveGameV1Opts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute | inclusiveTimecode | optional.Bool| True to include plays that happen before or at the specified timecode | accent | optional.Bool| Boolean value to specify wanting a person's name with accents or without |

Return type

BaseballGameRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

LiveTimestampv11

string LiveTimestampv11(ctx, gamePk) Retrieve all of the play timestamps for a game.

This can be used for replaying games. Endpoint returns all of the timecodes that can be used with diffs for /v1/game/{game_pk}/feed/live

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game

Return type

string

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]

PlayByPlay

BaseballPlayByPlayRestObject PlayByPlay(ctx, gamePk, optional) Get game play By Play

This endpoint allows you to pull the play by play of a game

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
gamePk int32 Unique Primary Key Representing a Game
optional *GameApiPlayByPlayOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a GameApiPlayByPlayOpts struct

Name Type Description Notes

timecode | optional.String| Use this parameter to return a snapshot of the data at the specified time. Format: YYYYMMDD_HHMMSS | fields | **optional.Interface of []string**| Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute | inclusiveTimecode | optional.Bool| True to include plays that happen before or at the specified timecode | accent | optional.Bool| Boolean value to specify wanting a person's name with accents or without |

Return type

BaseballPlayByPlayRestObject

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=UTF-8

[Back to top] [Back to API list] [Back to Model list] [Back to README]