我requests
用来从 ESPN Fantasy API 中提取 NBA 球员的统计数据。在下游,我正在构建一个 pandas df。我遇到的一件事是过滤对 JSON 嵌套更深的字段的请求。我可以在我的标题中过滤status
和排序PercOwned
,但我似乎无法过滤像statSplitTypeId
or之类的项目auctionValue
。有什么想法吗?
当前标题:
headers = {
'X-Fantasy-Filter': '{"players":\
{"filterStatus":{"value":["FREEAGENT","WAIVERS","ONTEAM"]},\
"sortPercOwned":{"sortAsc":false,"sortPriority":1}}}'
}
示例 JSON 响应
{
"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```