新端点
截至 2016 年 12 月,有一个用于获取库存的新端点。下面列出的旧端点仍然有效(目前)。两者似乎都受到高度限制。
新的库存路径是:
http://steamcommunity.com/inventory/<PROFILEID>/440/2?l=english&count=5000
有了这条新路,l
是您想要接收数据的语言count
是一次接收返回的项目数。最大值为 5000。
您也可以使用这个新端点进行分页:
http://steamcommunity.com/inventory/<PROFILEID>/440/2?l=english&count=5000&start_assetid=468336866
这将拉取以 assetid 开头的接下来 5000 个项目468336866
.
终点返回一个大的 json 对象,其结构如下:
{
'assets': <list>,
'descriptions': <list>,
'total_inventory_count': integer,
'success': 1/0,
'rwgran': integer
}
我不完全确定什么rwgran
就在此时。
The assets
键,返回如下所示的数据:
[{'amount': '1',
'appid': '440',
'assetid': '4985815666',
'classid': '134',
'contextid': '2',
'instanceid': '0'},
{'amount': '1',
'appid': '440',
'assetid': '4985815941',
'classid': '22989188',
'contextid': '2',
'instanceid': '0'},
...
]
The descriptions
key 包含这样的条目。请注意,这比旧端点包含更多信息。
[{'actions': [{'link': 'http:\\/\\/wiki.teamfortress.com\\/scripts\\/itemredirect.php?id=241&lang=en_US',
'name': 'Item Wiki Page...'}],
'appid': 440,
'background_color': '3C352E',
'classid': '134',
'commodity': 0,
'currency': 0,
'descriptions': [{'type': 'text',
'value': 'Is an enemy player questioning your skills, personal hygiene, and\\/or ancestry?\nUse these stylish firearms to challenge them to a duel!\nSee the Mann Co. Catalog for full details.'},
{'type': 'text', 'value': ' '},
{'color': '00a000',
'type': 'text',
'value': 'This is a limited use item. Uses: 5'}],
'icon_url': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgECbwgfYh_3vTRKhs_ZAfOeD-VOyo4z4clTizJqwQcpYOHnNDFmcweRVqQPCqVq91C-WCM26pFnB4PjofUWJ1uAGDnHsA',
'icon_url_large': 'fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZULUrsm1j-9xgECbwgfYh_3vTRKhs_ZAfOeD-VOyo4z4clTizJqwQcpYOHnNDFmcweRVqQPCqVq91C-WCM26pFnB4PjofUWJ1uAGDnHsA',
'instanceid': '0',
'market_hash_name': 'Dueling Mini-Game',
'market_marketable_restriction': 0,
'market_name': 'Dueling Mini-Game',
'market_tradable_restriction': 7,
'marketable': 0,
'name': 'Dueling Mini-Game',
'name_color': '7D6D00',
'tags': [{'category': 'Quality',
'color': '7D6D00',
'internal_name': 'Unique',
'localized_category_name': 'Quality',
'localized_tag_name': 'Unique'},
{'category': 'Type',
'internal_name': 'TF_UsableItem',
'localized_category_name': 'Type',
'localized_tag_name': 'Usable Item'},
{'category': 'Class',
'internal_name': 'Scout',
'localized_category_name': 'Class',
'localized_tag_name': 'Scout'},
{'category': 'Class',
'internal_name': 'Sniper',
'localized_category_name': 'Class',
'localized_tag_name': 'Sniper'},
{'category': 'Class',
'internal_name': 'Soldier',
'localized_category_name': 'Class',
'localized_tag_name': 'Soldier'},
{'category': 'Class',
'internal_name': 'Demoman',
'localized_category_name': 'Class',
'localized_tag_name': 'Demoman'},
{'category': 'Class',
'internal_name': 'Medic',
'localized_category_name': 'Class',
'localized_tag_name': 'Medic'},
{'category': 'Class',
'internal_name': 'Heavy',
'localized_category_name': 'Class',
'localized_tag_name': 'Heavy'},
{'category': 'Class',
'internal_name': 'Pyro',
'localized_category_name': 'Class',
'localized_tag_name': 'Pyro'},
{'category': 'Class',
'internal_name': 'Spy',
'localized_category_name': 'Class',
'localized_tag_name': 'Spy'},
{'category': 'Class',
'internal_name': 'Engineer',
'localized_category_name': 'Class',
'localized_tag_name': 'Engineer'}],
'tradable': 1,
'type': 'Level 5 Usable Item'},
...
]
与旧方法一样,assets
and descriptions
通过以下方式链接classid
同时。
旧端点
更新:自 2022 年 11 月 11 日欧洲中部时间 00:00 起,此端点部分不可用
该端点将返回{ "success": false, "Error": "Unsupported request" }
在某些地区(取决于帐户地区)。预计所有地区都将在不久的将来关闭此端点。
如果目标的配置文件权限设置适当,您可以获得一些有限的信息。
您可以查看结果json
使用这两个链接中的任何一个进行测试(以及礼物,如果设置了适当的权限)清单的文件
http://steamcommunity.com/id/<CUSTOMURL>/inventory/json/753/1
http://steamcommunity.com/profiles/<PROFILEID>/inventory/json/753/1
CUSTOMURL
是玩家选择使用的用户友好名称。玩家可以随时更改此设置。如果您正在编写网页,我假设您知道如何获取这条信息,对吗?PROFILEID
是您创建帐户时 Steam 为玩家提供的 64 位 ID。这是不可更改的,并且在使用 OpenID 实现登录时由 Steam 返回。
使用这些 URL 时,有几种可能的响应。第一个是用户是否将其个人资料设置为私人。
{"success":false,"Error":"This profile is private."}
第二个是库存中“东西”的列表
{
"success":true,
"rgInventory":
{
"1586670077416875609":
{
"id":"1586670077416875609",
"classid":"149742033",
"instanceid":"0",
"amount":"1",
"pos":1
},
"1586670077416875905":
{
"id":"1586670077416875905",
"classid":"149742033",
"instanceid":"0",
"amount":"1",
"pos":2
},
"1586670077416877092":
{
"id":"1586670077416877092",
"classid":"149742033",
"instanceid":"0",
"amount":"1",
"pos":3
}
},
"rgCurrency":[],
"rgDescriptions":
{
"149742033_0":
{ "appid":"753",
"classid":"149742033",
"instanceid":"0",
"icon_url":"ZyjGwQD4ogROtSm7KvtdP99kDHBEiKxKm3Gg7pMaBJyiPu4iS_PzF6QhOUdOwk-m0WhXYQ7X8AbNL6Hz1VxOnq4-8iBC5MlBuXMuElaaCrHQLww9T5S1Ecoqo_PYWg==",
"icon_url_large":"a6FEz5nbBlvu8bGd1oDggdPtjn7dqwgVOzU4yG9huSKut2ws0tBXSARloWGyufIY3eHVb5f0VFltaznVKSfzK6amZz7FjFhcTTm6Maz860eOrMo937A=",
"icon_drag_url":"",
"name":"Steam Trading Card Beta",
"market_name":"",
"name_color":"",
"background_color":"",
"type":"Gift",
"tradable":1,
"marketable":0,
"descriptions":[
{"value":"Steam Trading Card Beta Access - Extra Copy"},
{"value":"Grants early access to the Steam Trading Cards beta, game badges, and the new profile. Join the Steam Trading Cards Group and post your feedback in the Discussions area. Select \u201cAdd to my game library\u201d to activate."}
],
"actions":[
{"name":"View in store","link":"http:\/\/steamcommunity.com\/tradingcards"}
]
}
}
}
如果该 URL 是您的 ID 并且您已登录 Steam,您还可以看到列出的项目Gift
。否则,这些默认情况下是隐藏的。
由于这不是官方 API,因此没有太多关于此特定模式的文档。然而,似乎其中的项目rgInventory
链接到中的项目reDescriptions
by classid
。编写解析器作为读者的练习。
这些显示了测试版访问。
如果您正在查找交易卡信息,请更改1
在上面的 URL 中6
http://steamcommunity.com/id/<CUSTOMURL>/inventory/json/753/6
http://steamcommunity.com/profiles/<PROFILEID>/inventory/json/753/6
这些的架构布局似乎是相同的。