-
-
Notifications
You must be signed in to change notification settings - Fork 101
Function: lookup_team
Todd Roberts edited this page Aug 10, 2022
·
2 revisions
statsapi.lookup_team(lookup_value, activeStatus="Y", season=None, sportIds=1)
Note: Values for activeStatus:
Y
,N
,B
(Both)
Note: Return value will be a list of teams matching the lookup_value. If no matches are found, an empty list will be returned.
Get teamId for team with code cwa
team = statsapi.lookup_team('chn')
print(team[0]['id']) #assume only 1 record returned for demo purposes
112
Get info about all teams from NY
for team in statsapi.lookup_team('ny'):
print(team)
{'id': 147, 'name': 'New York Yankees', 'teamCode': 'nya', 'fileCode': 'nyy', 'teamName': 'Yankees', 'locationName': 'Bronx', 'shortName': 'NY Yankees'}
{'id': 121, 'name': 'New York Mets', 'teamCode': 'nyn', 'fileCode': 'nym', 'teamName': 'Mets', 'locationName': 'New York', 'shortName': 'NY Mets'}
Note: This information is provided for reference only, without warranty or guarantee, and is not official documentation provided by MLB. This package and its author are not affiliated with MLB or any MLB team. This API wrapper interfaces with MLB's Stats API. Use of MLB data is subject to the notice posted at http://gdx.mlb.com/components/copyright.txt.