I'm using requests
to pull in NBA player stats from the ESPN Fantasy API. Downstream I'm building a pandas df. One thing I'm having trouble with is filtering the request for fields that are deeper in the JSON nesting. I'm able to filter status
and sort by PercOwned
in my header, but I can't seem to filter for items like statSplitTypeId
or auctionValue
. Any thoughts?
current headers:
headers = {
'X-Fantasy-Filter': '{"players":\
{"filterStatus":{"value":["FREEAGENT","WAIVERS","ONTEAM"]},\
"sortPercOwned":{"sortAsc":false,"sortPriority":1}}}'
}
Example JSON response
{
"players": [
{
"draftAuctionValue": 0,
"id": 3032977,
"keeperValue": 1,
"keeperValueFuture": 1,
"lineupLocked": false,
"onTeamId": 4,
"player": {
"active": true,
"defaultPositionId": 4,
"draftRanksByRankType": {
"STANDARD": {
"auctionValue": 64,
"published": false,
"rank": 2,
"rankSourceId": 0,
"rankType": "STANDARD",
"slotId": 0
}
},
"droppable": false,
"eligibleSlots": [
3,
6,
8,
9,
10,
11,
12,
13
],
"firstName": "Giannis",
"fullName": "Giannis Antetokounmpo",
"ownership": {
"activityLevel": null,
"auctionValueAverage": 64.22289156626506,
"auctionValueAverageChange": -2.9199655765920767,
"averageDraftPosition": 2.6674573758339513,
"averageDraftPositionPercentChange": -0.6431361088656256,
"date": 1637244022069,
"leagueType": 0,
"percentChange": -0.006086844650013745,
"percentOwned": 99.95081910133877,
"percentStarted": 85.24790654758796
},
},
"rosterLocked": true,
"status": "ONTEAM",
"tradeLocked": false```