Closed drewski3420 closed 2 years ago
Er, I suppose this can be closed. Passing in player ID instead of name is working fine.
The name should map to the same player id that you pass in. Does it look like the same call to the api as player id when you pass player name?
I tried 3 player_info calls. 1 works, 2 and 3 fail
When I look at the calls, the ones that fail show a different playerId in the header of the request. Working request has the correct ID 13983 vs 4038437 on the ones that fail
ESPN API Request: url: https://fantasy.espn.com/apis/v3/games/ffl/seasons/2020/segments/0/leagues/XXX params: {'view': 'kona_playercard'} headers: {'x-fantasy-filter': '{"players": {"filterIds": {"value": [13983]}, "filterStatsForTopScoringPeriodIds": {"value": 16, "additionalValue": ["002020", "102020"]}}}'}
ESPN API Request: url: https://fantasy.espn.com/apis/v3/games/ffl/seasons/2020/segments/0/leagues/XXX params: {'view': 'kona_playercard'} headers: {'x-fantasy-filter': '{"players": {"filterIds": {"value": [4038437]}, "filterStatsForTopScoringPeriodIds": {"value": 16, "additionalValue": ["002020", "102020"]}}}'}
Thanks for testing it out and looking at the calls! I will look into it. I wonder if there are multiple players with that same name. It's definitely best bet to use player id as it is unique for every player.
@cwendt94 is there a way to get multiple player infos at once? I tried playing with the value
field in
filters = {'players':{'filterIds':{'value':[playerId]}, 'filterStatsForTopScoringPeriodIds':{'value':17, "additionalValue":["00{}".format(self.year), "10{}".format(self.year)]}}}
by putting a list of multiple player IDs instead of a list of just one ID, but the API is just returning a single player. I presume this is an ESPN limitation.
My overall goal is to get the player info (stats, etc.) for every player. Right now it seems like I'll have to run individual requests for all players. Is this the case?
@kmcentush yes I will just need to update the player_info function to account for the playerId variable to be a list. The API call allows for multiple ids. If multiple ids are passed the response will be an array of players instead of just a singe player class.
Should have it done sometime tomorrow.
@cwendt94 Great! Thanks for your work on this awesome library.
@kmcentush feature now in package v0.20.0. You can now pass in a list of ids with playerId
field. The function will return a list of players
def player_info(name: str = None, playerId: Union[int, list] = None) -> -> Union[Player, List[Player]]:
Sport
Football
Summary
Trying to get the Pro Team and Position for previous year's draft picks. These properties aren't members of the Pick class, so I'm calling the League.player_info() method and passing in the player name.
This works for some players (works for Austin Ekeler, Amari Cooper) but fails for other players (fails on A.J. Green). No error message is displayed but the API returns an empty {} for these players.
Here is the debug response for AJ Green. I have attached the full debug dump as well: ESPN API Request: url: https://fantasy.espn.com/apis/v3/games/ffl/seasons/2020/segments/0/leagues/376 params: {'view': 'kona_playercard'} headers: {'x-fantasy-filter': '{"players": {"filterIds": {"value": [4038437]}, "filterStatsForTopScoringPeriodIds": {"value": 16, "additionalValue": ["002020", "102020"]}}}'} ESPN API Response: {'players': []}
Logs/Data
[Uploading 123.log…]()