Skip to main content

MLB — MLB Stats API — All

mlb_all_star_ballot​

View All-Star Ballots per league.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/league/{league_id}/allStarBallot

Valid URL: https://statsapi.mlb.com/api/v1/league/103/allStarBallot?season=2023

API ParameterPythonPatternRequiredNullableDescription
league_idleague_idYleague_id path parameter.
seasonseasonYSeason year (e.g. 2024).
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
idInt64Id.
full_nameStringPlayer's full name.
linkStringAPI link to the game feed.
first_nameStringPlayer first name.
last_nameStringPlayer last name.
primary_numberStringPlayer uniform number.
birth_dateStringDate of birth (YYYY-MM-DD).
current_ageInt64Current age in years.
birth_cityStringCity of birth.
birth_countryStringCountry of birth.
heightStringHeight (feet and inches).
weightInt64Weight in pounds.
activeBooleanWhether the player is currently active.
use_nameStringPreferred first name.
use_last_nameStringPreferred last name.
middle_nameStringPlayer middle name.
boxscore_nameStringName as shown in box scores.
nick_nameStringPlayer nickname.
genderStringPlayer gender.
name_matrilinealStringMaternal family name.
is_playerBooleanWhether the person is a player.
is_verifiedBooleanWhether the player profile is verified.
pronunciationStringPhonetic name pronunciation.
last_played_dateStringDate of last MLB game played.
mlb_debut_dateStringMLB debut date (YYYY-MM-DD).
name_first_lastStringName in first-last order.
name_slugStringURL-friendly name slug.
first_last_nameStringFirst and last name.
last_first_nameStringName in last, first order.
last_init_nameStringLast name with first initial.
init_last_nameStringFirst initial with last name.
full_fml_nameStringFull name (first-middle-last).
full_lfm_nameStringFull name (last-first-middle).
strike_zone_topFloat64Top of the player's strike zone (feet).
strike_zone_bottomFloat64Bottom of the player's strike zone (feet).
primary_position_codeStringPrimary position code.
primary_position_nameStringPrimary fielding position name.
primary_position_typeStringPrimary position type (e.g. Infielder).
primary_position_abbreviationStringPrimary position abbreviation.
bat_side_codeStringBatting side code (L/R/S).
bat_side_descriptionStringBatting side description.
pitch_hand_codeStringThrowing hand code (L/R).
pitch_hand_descriptionStringThrowing hand description.
birth_state_provinceStringState or province of birth.
draft_yearFloat64Year the player was drafted.
name_titleStringName title.
name_suffixStringName suffix (e.g. Jr., Sr., III).

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

mlb_all_star_ballot(league_id='103', season='2023')

mlb_all_star_write_ins​

View All-Star Write-ins per league.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/league/{league_id}/allStarWriteIns

Valid URL: https://statsapi.mlb.com/api/v1/league/103/allStarWriteIns?season=2023

API ParameterPythonPatternRequiredNullableDescription
league_idleague_idYleague_id path parameter.
seasonseasonYSeason year (e.g. 2024).
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
idInt64Id.
full_nameStringPlayer's full name.
linkStringAPI link to the game feed.
first_nameStringPlayer first name.
last_nameStringPlayer last name.
birth_dateStringDate of birth (YYYY-MM-DD).
current_ageInt64Current age in years.
birth_cityStringCity of birth.
birth_state_provinceStringState or province of birth.
birth_countryStringCountry of birth.
heightStringHeight (feet and inches).
weightInt64Weight in pounds.
activeBooleanWhether the player is currently active.
use_nameStringPreferred first name.
use_last_nameStringPreferred last name.
boxscore_nameStringName as shown in box scores.
genderStringPlayer gender.
is_playerBooleanWhether the person is a player.
is_verifiedBooleanWhether the player profile is verified.
pronunciationStringPhonetic name pronunciation.
mlb_debut_dateStringMLB debut date (YYYY-MM-DD).
name_first_lastStringName in first-last order.
name_slugStringURL-friendly name slug.
first_last_nameStringFirst and last name.
last_first_nameStringName in last, first order.
last_init_nameStringLast name with first initial.
init_last_nameStringFirst initial with last name.
full_fml_nameStringFull name (first-middle-last).
full_lfm_nameStringFull name (last-first-middle).
strike_zone_topFloat64Top of the player's strike zone (feet).
strike_zone_bottomFloat64Bottom of the player's strike zone (feet).
bat_side_codeStringBatting side code (L/R/S).
bat_side_descriptionStringBatting side description.
pitch_hand_codeStringThrowing hand code (L/R).
pitch_hand_descriptionStringThrowing hand description.
primary_numberStringPlayer uniform number.
draft_yearFloat64Year the player was drafted.
middle_nameStringPlayer middle name.
name_matrilinealStringMaternal family name.
last_played_dateStringDate of last MLB game played.
nick_nameStringPlayer nickname.
name_titleStringName title.
name_suffixStringName suffix (e.g. Jr., Sr., III).

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

mlb_all_star_write_ins(league_id='103', season='2023')

mlb_all_star_final_vote​

View All-Star Final Vote per league.

Endpoint URL: GET https://statsapi.mlb.com/api/v1/league/{league_id}/allStarFinalVote

Valid URL: https://statsapi.mlb.com/api/v1/league/103/allStarFinalVote?season=2023

API ParameterPythonPatternRequiredNullableDescription
league_idleague_idYleague_id path parameter.
seasonseasonYSeason year (e.g. 2024).
fieldsfieldsYfields query parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
idInt64Id.
full_nameStringPlayer's full name.
linkStringAPI link to the game feed.
first_nameStringPlayer first name.
last_nameStringPlayer last name.
primary_numberStringPlayer uniform number.
birth_dateStringDate of birth (YYYY-MM-DD).
current_ageInt64Current age in years.
birth_cityStringCity of birth.
birth_countryStringCountry of birth.
heightStringHeight (feet and inches).
weightInt64Weight in pounds.
activeBooleanWhether the player is currently active.
use_nameStringPreferred first name.
use_last_nameStringPreferred last name.
boxscore_nameStringName as shown in box scores.
nick_nameStringPlayer nickname.
genderStringPlayer gender.
is_playerBooleanWhether the person is a player.
is_verifiedBooleanWhether the player profile is verified.
pronunciationStringPhonetic name pronunciation.
mlb_debut_dateStringMLB debut date (YYYY-MM-DD).
name_first_lastStringName in first-last order.
name_slugStringURL-friendly name slug.
first_last_nameStringFirst and last name.
last_first_nameStringName in last, first order.
last_init_nameStringLast name with first initial.
init_last_nameStringFirst initial with last name.
full_fml_nameStringFull name (first-middle-last).
full_lfm_nameStringFull name (last-first-middle).
strike_zone_topFloat64Top of the player's strike zone (feet).
strike_zone_bottomFloat64Bottom of the player's strike zone (feet).
primary_position_codeStringPrimary position code.
primary_position_nameStringPrimary fielding position name.
primary_position_typeStringPrimary position type (e.g. Infielder).
primary_position_abbreviationStringPrimary position abbreviation.
bat_side_codeStringBatting side code (L/R/S).
bat_side_descriptionStringBatting side description.
pitch_hand_codeStringThrowing hand code (L/R).
pitch_hand_descriptionStringThrowing hand description.
name_matrilinealStringMaternal family name.
birth_state_provinceStringState or province of birth.
name_titleStringName title.
name_suffixStringName suffix (e.g. Jr., Sr., III).
middle_nameStringPlayer middle name.
draft_yearFloat64Year the player was drafted.
last_played_dateStringDate of last MLB game played.

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

mlb_all_star_final_vote(league_id='103', season='2023')