Team Endpoint
The team endpoint provides access to team-related data from the MLB Stats API.
Overview
This endpoint has 8 functional methods and 2 non-functional methods.
Functional Methods
The following methods are fully functional and tested:
__leaders_base()
Summary: View leaders for team stats
Path: /v1/teams/stats/leaders
Query Parameters:
leaderCategories(array, optional): TBDgameTypes(array, optional): Type of Game. Available types in /api/v1/gameTypesstats(array, optional): Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypesstatType(string, optional): statTypesportId(integer, optional): Top level organization of a sport… and 14 more parameters
Example:
from pymlb_statsapi import api
# View leaders for team stats
response = api.Team.__leaders_base(leaderCategories="value", gameTypes="value", stats="value")
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
__leaders_teamId()
Summary: View in
Path: /v1/teams/{teamId}/leaders
Path Parameters:
teamId(integer, required): teamId
Query Parameters:
leaderCategories(array, optional): leaderCategoriesseason(string, optional): seasonleaderGameTypes(array, optional): leaderGameTypesexpand(array, optional): expandslimit(integer, optional): limit… and 3 more parameters
Example:
from pymlb_statsapi import api
# View in
response = api.Team.__leaders_teamId(leaderCategories="value", season="2024", leaderGameTypes="value")
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
alumni()
Summary: View all team alumni
Path: /v1/teams/{teamId}/alumni
Path Parameters:
teamId(integer, required): Unique Team Identifier. Format: 141, 147, etc
Query Parameters:
season(string, required): Season of playgroup(string, optional): Category of statistic to return. Available types in /api/v1/statGroupsfields(array, optional): fields
Example:
from pymlb_statsapi import api
# View all team alumni
response = api.Team.alumni(season="2024", group="value", fields="value")
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
coaches()
Summary: View all coaches for a team
Path: /v1/teams/{teamId}/coaches
Path Parameters:
teamId(integer, required): Unique Team Identifier. Format: 141, 147, etc
Query Parameters:
season(string, optional): Season of playdate(LocalDate, optional): Date of Game. Format: YYYY-MM-DDfields(array, optional): fields
Example:
from pymlb_statsapi import api
# View all coaches for a team
response = api.Team.coaches(season="2024", date="2024-07-04", fields="value")
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
leaders()
Summary: View leaders for team stats
Path: /v1/teams/stats/leaders
Query Parameters:
leaderCategories(array, optional): TBDgameTypes(array, optional): Type of Game. Available types in /api/v1/gameTypesstats(array, optional): Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypesstatType(string, optional): statTypesportId(integer, optional): Top level organization of a sport… and 14 more parameters
Example:
from pymlb_statsapi import api
# View leaders for team stats
response = api.Team.leaders(leaderCategories="value", gameTypes="value", stats="value")
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
roster()
Summary: View a teams info
Path: /v1/teams/{teamId}/roster/{rosterType}
Path Parameters:
teamId(integer, required): Unique Team Identifier. Format: 141, 147, etcrosterType(Optional«string», required): Type of roster. Available types in /api/v1/rosterTypes
Query Parameters:
season(string, optional): Season of playdate(LocalDate, optional): Date of Game. Format: YYYY-MM-DDgameType(string, optional): Type of Game. Available types in /api/v1/gameTypesfields(array, optional): Comma delimited list of specific fields to be returned. Format: topLevelNode, childNode, attribute
Example:
from pymlb_statsapi import api
# View a teams info
response = api.Team.roster(season="2024", date="2024-07-04", gameType="value")
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
stats()
Summary: View a teams stats
Path: /v1/teams/stats
Query Parameters:
gameType(string, optional): Type of Game. Available types in /api/v1/gameTypesstats(array, optional): Type of statistics. Format: Individual, Team, Career, etc. Available types in /api/v1/statTypessportId(integer, optional): Top level organization of a sportsportIds(array, optional): Comma delimited list of top level organizations of a sportleagueIds(array, optional): Comma delimited list of Unique league identifiers… and 13 more parameters
Example:
from pymlb_statsapi import api
# View a teams stats
response = api.Team.stats(gameType="value", stats="value", sportId=1)
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
teams()
Summary: View info for all teams
Path: /v1/teams
Query Parameters:
teamId(Optional«int», optional): Unique Team Identifier. Format: 141, 147, etcseason(string, optional): Season of playsportId(integer, optional): Top level organization of a sportdivisionId(integer, optional): Unique Division IdentifiergameType(string, optional): Type of Game. Available types in /api/v1/gameTypes… and 6 more parameters
Example:
from pymlb_statsapi import api
# View info for all teams
response = api.Team.teams(teamId=147, season="2024", sportId=1)
data = response.json()
# Save to file
result = response.gzip(prefix="mlb-data")
print(f"Saved to: {result['path']}")
Non-Functional Methods
Warning
The following methods are not functional due to issues in the MLB Stats API or schema mismatches:
affiliates()allTeams()
These methods are excluded from the API and will not be available.
Schema Introspection
You can explore the full schema for the team endpoint programmatically:
from pymlb_statsapi import api
# List all methods
methods = api.Team.get_method_names()
print(methods)
# Get method details
method = api.Team.get_method('teams')
schema = method.get_schema()
print(json.dumps(schema, indent=2))
# Get detailed description
description = api.Team.describe_method('teams')
print(description)