-
-
Notifications
You must be signed in to change notification settings - Fork 104
Function: lookup_player
statsapi.lookup_player(lookup_value, gameType="R", season=None, sportId=1)
Look up player id for Aaron Nola
Note: if using a full last name as the lookup_value and that last name could be part of another player's lastname, e.g.
Nola
is part ofNolan
, include a comma on the end of the last name in order to match on theinitLastName
field which looks likeNola, A
player = statsapi.lookup_player('nola,')
print(player[0]['id']) #assume only 1 record returned for demo purposes
605400
Print full name and position for all players named Harper
for player in statsapi.lookup_player('Harper'):
print('Full name: {}, Position: {}'.format(player['fullName'], player['primaryPosition']['abbreviation']))
Full name: Bryce Harper, Position: RF
Full name: Ryne Harper, Position: P
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.