Steam web api 获取物品标签 (TF2) [英] Steam web api get items tag (TF2)
问题描述
我正在尝试从某些项目中获取标签,但我找不到提供这些标签的功能.我正在使用 Steam Web API 中的 GetPlayerItems
来获取播放器物品,但它不会给我商品标签,我该怎么办?
I am trying to get the tags from some items but i cant find a function that give me these tags..
I am using GetPlayerItems
from the steam web API to get the player items but it wont give me
the item tags, what should i do?
有没有办法给我标签?
我还有一个问题,有没有一种快速的方法来拉取物品的图像?不是通过将其存储在我的服务器上?我的意思是像通过蒸汽服务器或其他东西的图像 URL..
and i have another question, is there a fast way to pull the image of the item? not by storing it on my server? i mean like an URL to the image through steam server or something..
我尝试了 GetSchema
来查找某个项目的信息,但我不知道它是如何工作的.
i have tried GetSchema
to find information for an item but i dont really get how it works.
谢谢!
推荐答案
您需要组合两个单独的 API 调用,以将 GetPlayerItems 链接到数据的实际含义.
You need to combine two separate API calls to link the GetPlayerItems to what the data actually means.
执行GetPlayerItems
调用并返回数据.在返回数据中,您将遍历 result['items']
以获取玩家物品的列表.
Perform you GetPlayerItems
call and return data. In the return data, you will iterate over result['items']
to get a listing of the player items.
该数组中的一项可能如下所示:
One item in that array may look like this:
{
"id": 493336261,
"original_id": 493336261,
"defindex": 5050,
"level": 50,
"quality": 6,
"inventory": 2147483948,
"quantity": 1,
"origin": 2,
"attributes": [
{
"defindex": 195,
"value": 1065353216,
"float_value": 1.000000
}
]
},
使用此数据,您可以使用 defindex
查看从 GetSchema
调用返回的 result['items']
数组.您必须遍历每个项目,将 GetPlayerItems
defindex 与 GetSchema
defindex 进行比较.当它匹配时,您就知道该项目是什么.
Using this data, you can use the defindex
to look at the result['items']
array returned from your GetSchema
call. You will have to iterate through each of those items comparing the GetPlayerItems
defindex to the GetSchema
defindex. When it matches you have know what the item is.
在上面的例子中,5050
是一个 Backpack Expander
.您可以通过查看 GetSchema
匹配项上的 image_url
或 image_url_large
值来提取此项目的图像.
In the above case, 5050
is a Backpack Expander
. You can pull the image for this item by looking at the image_url
or image_url_large
values on the GetSchema
match.
对于您提到的标签",我假设您的意思是 attributes
.这些可以通过遵循类似的过程进行匹配,但与 GetSchema
result['attributes']
数组匹配.同样,您必须遍历所有内容并比较 defindex
值.
For the "tags" that you mention, I am assuming you mean attributes
. These can be matched by following a similar process, but instead matching against the GetSchema
result['attributes']
array. Again, you'll have to loop through all and compare defindex
values.
对于上面的示例,defindex = 195
的属性与此匹配:
For the above example, the attribute with defindex = 195
matches this:
{
"name": "always tradable",
"defindex": 195,
"attribute_class": "always_tradable",
"description_string": "#Attrib_Always_Tradable",
"description_format": "value_is_additive",
"effect_type": "negative",
"hidden": true,
"stored_as_integer": false
},
GetPlayerItems
属性中1.0
的float_value
表示该对象具有该属性.所以,这个背包扩展器总是可以交易的.
The float_value
of 1.0
in the GetPlayerItems
attributes indicates that this object has that attribute. So, this backpack expander is always tradable.
这篇关于Steam web api 获取物品标签 (TF2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!