Difference between revisions of "WebAPI/GetPlayerItems"

From Team Fortress Wiki
Jump to: navigation, search
(URL)
 
(21 intermediate revisions by 10 users not shown)
Line 1: Line 1:
This documentation is for version v0001 of the '''WebAPI (GetPlayerItems)'''. This method returns the specified player's [[backpack]] content.
 
 
 
== URL ==
 
== URL ==
 
<nowiki>http://api.steampowered.com/IEconItems_<ID>/GetPlayerItems/v0001/</nowiki>
 
<nowiki>http://api.steampowered.com/IEconItems_<ID>/GetPlayerItems/v0001/</nowiki>
Line 6: Line 4:
 
See the [[WebAPI#appids|ID list]] for a valid ID.
 
See the [[WebAPI#appids|ID list]] for a valid ID.
  
 +
== Method-specific parameters ==
 +
; SteamID
 +
: The 64-bit ID of the user the backpack will be retrieved for.
  
 +
== Result data ==
 +
;result:
  
'''Example:''' 
+
:;status: The status of the request.
 
+
::;1: Success
<nowiki>http://api.steampowered.com/IEconItems_</nowiki>'''<Game_ID>'''/GetPlayerItems/v0001/?steamID='''<Your ID>'''&key='''<Your API Key Here>'''&format='''xml'''&lang='''en_US'''
+
::;8: The steamid parameter was invalid or missing.
 
+
::;15: Backpack is private.
 
+
::;18: The Steam ID given does not exist.
 
 
'''Game_ID''':  
 
 
 
440: Team Fortress 2
 
 
 
520: Team Fortress 2 Public Beta
 
 
 
620: Portal 2
 
 
 
 
 
'''Your ID''': Your steam community id. (Ex: 76561197993107733)
 
 
 
To get your id go to http://www.vacbanned.com and enter your name/steam profile url.  Your id will be the first element listed.
 
 
 
  
'''Format''': (can be one of the following)
+
:;num_backpack_slots: The number of backpack slots this user has.
  
json - The output will be returned in the JSON format
+
:;items: A list of item objects.
  
xml - Output is returned as an XML document
+
::;id: The unique ID of the specific item.
  
vdf - Output is returned as a VDF file.
+
::;original_id: The ID of the item before it was customized, traded, or otherwise changed.
  
 +
::;defindex: The defindex of the item, as found in the item array returned from [[../GetSchema|GetSchema]].
  
'''Language''': See below for language options.
+
::;level: The arbitrary "level" value of the item as displayed in the inventory.
  
 +
::;quantity: The number of "uses" an item has, generally only has a value in excess of '1' on "usable items", such as the [[Dueling Mini-Game]].
  
'''Completed Example''' (for TF2 items, my community id, xml output, en_US language):  
+
::;{{API optional|origin<ref name="tf2specific">Specific to the TF2 interface.</ref>}}: An integer used to lookup an origin name via [[../GetSchema#origin|GetSchema]].
  
<nowiki>http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?steamID=76561197993107733&key=</nowiki>'''<Your API Key Here>'''&format=xml&lang=en_US
+
::;{{API optional|flag_cannot_trade}}: A boolean value that is true if the item cannot be traded. Assume false if not present.
  
 +
::;{{API optional|flag_cannot_craft}}: A boolean value that is true if the item cannot be used in crafting. Assume false if not present.
  
'''C# Example'''
+
::;inventory (<span style="color: red;">Partially deprecated</span><ref>Assume fields for equipped classes to be incorrect, favor '''equipped'''</ref>): An inventory token as described [[#Inventory_token|here]], or '0' if the item has been awarded and not yet found (placed in the backpack).
  
string responseText= string.empty;
+
::;quality: The [[Rarity|quality]] of the item (see definition in [[../GetSchema|GetSchema]]).
  
string address = <nowiki>"http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?steamID=76561197993107733</nowiki>&key='''<Your API Key Here>'''&format=xml&lang=en_US";
+
::;{{API optional|custom_name}}: The item's custom name if it has one.
  
 +
::;{{API optional|custom_desc}}: The item's custom description if it has one.
  
using (WebClient client = new WebClient())
+
::;{{API optional|contained_item}}: All the information for the item that this item contains for gift-wrapped items.
  
{
+
::;{{API optional|style}}: An integer that can be used as an index to the item's [[../GetSchema#styles|style list]].
  
<nowiki> Response = client.DownloadString(address);</nowiki>
+
::;{{API optional|attributes}}: If the item has additional effects to the ones normally associated with it as described in GetSchema, contains a list of objects.
 
+
:::;defindex: The index to the attributes definition in the schema, e.g. 133 for the medal number attribute for the [[Gentle Manne's Service Medal]].
}
+
:::;value: The value for this attribute for this item, e.g. the medal number for the [[Gentle Manne's Service Medal]].
 
+
:::;{{API optional|float_value}}: The floating point value for this attribute if it has one.
XmlDocument itemSchema = new XmlDocument();
+
:::;{{API optional|account_info}}: Set on attributes with a Steam ID as the value.
 
+
::::;steamid: The specified user's unique 64-bit Steam ID.
itemSchema.Load(responseText);
+
::::;personaname: The specified user's current name on Steam.
 
 
== Method-specific parameters ==
 
; SteamID
 
: The 64-bit ID of the user the backpack will be retrieved for.
 
 
 
== Status codes ==
 
*'''<tt>1</tt>''': OK. Data returned as specified below.
 
*'''<tt>8</tt>''' ("<tt>SteamID parameter was missing</tt>"): The "steamID" parameter of the URL was not included, or if present was not a valid SteamID64 value.
 
*'''<tt>15</tt>''' ("<tt>Permission denied</tt>"): The player's profile is set to "Private".
 
*'''<tt>18</tt>''' ("<tt>Unknown account</tt>"): The "steamID" parameter was not registered to an account.
 
 
 
== Result data ==
 
A list of the player's items is returned as follows:
 
  
;'''num_backpack_slots''': The number of backpack slots this user has.
+
::;{{API optional|equipped<ref name="tf2specific"></ref>}}: If the item is equipped, contains an array of equip information
;'''items''': An object containing a list of associative arrays.
+
:::;class: The class the weapon is equipped to (numeric index).
:;'''id''': The unique ID of the specific item.
+
::::;0: Scout
:;'''original_id''': The ID of the item before it was customized, traded, or otherwise changed.
+
::::;1: Scout <ref>This is probably the correct mapping for the scout and all equipped fields with 0 in it will probably have this as well. I'm guessing this is either an off-by-one bug or a workaround of it</ref>
:;'''defindex''': The defindex of the item, as found in the item array returned from [[../GetSchema|GetSchema]].
+
::::;2: Sniper
:;'''level''': The arbitrary "level" value of the item as displayed in the inventory.
+
::::;3: Soldier
:;'''quantity''': The number of "uses" an item has, generally only has a value in excess of '1' on "usable items", such as the [[Dueling Mini-Game]].
+
::::;4: Demoman
:;'''flag_cannot_trade''': A boolean value that is true if the item cannot be traded. This is true for items granted by an [[achievement]], [[purchase]]d items, and certain [[promotional items]].
+
::::;5: Medic
:;'''inventory''': An inventory token as described [[#Inventory_Token|here]], or '0' if the item has been awarded and not yet found (placed in the backpack).
+
::::;6: Heavy
:;'''quality''': The [[Rarity|quality]] of the item (see definition in [[../GetSchema|GetSchema]]).
+
::::;7: Pyro
:;'''custom_name''' ''(<span style="color: red;">Optional</span>)'': The item's custom name if it has one.
+
::::;8: Spy
:;'''custom_desc''' ''(<span style="color: red;">Optional</span>)'': The item's custom description if it has one.
+
::::;9: Engineer
:;'''contained_item''' ''(<span style="color: red;">Optional</span>)'': All the information for the item that this item contains for gift-wrapped items.
+
:::;slot: The slot the weapon is equipped in (numeric index).
:;'''style''' ''(<span style="color: red;">Optional</span>)'': An integer that can be used as an index to the item's [[../GetSchema#styles|style list]].
+
::::;0: Primary
:;'''attributes''' ''(<span style="color: red;">Optional</span>)'': If the item has additional effects to the ones normally associated with it as described in GetSchema, contains a list of associative arrays.
+
::::;1: Secondary
::;'''defindex''': The index to the attributes definition in the schema, e.g. 133 for the medal number attribute for the [[Gentle Manne's Service Medal]].
+
::::;2: Melee
::;'''value''': The value for this attribute for this item, e.g. the medal number for the [[Gentle Manne's Service Medal]].
+
::::;4: Building
::;'''float_value''' ''(<span style="color: red;">Optional</span>)'': The floating point value for this attribute if it has one.
+
::::;6: PDA2
::;'''account_info''' ''(<span style="color: red;">Optional</span>)'': Set on attributes with a Steam ID as the value.
+
::::;7: Head
:::;'''steamid''': The specified user's unique 64-bit Steam ID.
+
::::;8: Misc 1
:::;'''personaname''': The specified user's current name on Steam.
+
::::;9: Action
:;'''equipped''' ''(<span style="color: red;">Optional</span>)'': If the item is equipped, contains an array of equip information
+
::::;10: Misc 2
::;'''class''': The class the weapon is equipped to (numeric index).
+
::::;65535: Set when the class had the item equipped previously.
::;'''slot''': The slot the weapon is equipped in (numeric index).
 
  
 
== Inventory token ==
 
== Inventory token ==
Line 107: Line 86:
  
 
   ┌─────────────────────────────────────────────────────────────── Always '1'
 
   ┌─────────────────────────────────────────────────────────────── Always '1'
   │ ┌─┬─┬─┬─┬─┬─────────────────────────────────────────────────── Unused
+
   │ ┌─┬─┬─┬─┬─┬─────────────────────────────────────────────────── Placed in Backpack<ref>This bit is 0 when the item has been placed in the backpack and has its own slot. It is 1 if it has been recently dropped/traded for and it hasn't been allocated a backpack space.</ref>
 
   │ │ │ │ │ │ │ ┌───────────────────────────────────────────────── Engineer  
 
   │ │ │ │ │ │ │ ┌───────────────────────────────────────────────── Engineer  
 
   │ │ │ │ │ │ │ │ ┌─────────────────────────────────────────────── Spy  
 
   │ │ │ │ │ │ │ │ ┌─────────────────────────────────────────────── Spy  
Line 129: Line 108:
 
                                                                     in backpack slot 42
 
                                                                     in backpack slot 42
  
{{Languages|WebAPI/GetPlayerItems}}
+
== Notes ==
 +
<references/>
  
 
[[Category:WebAPI|GetPlayerItems]]
 
[[Category:WebAPI|GetPlayerItems]]

Latest revision as of 04:20, 21 October 2014

URL

http://api.steampowered.com/IEconItems_<ID>/GetPlayerItems/v0001/

See the ID list for a valid ID.

Method-specific parameters

SteamID
The 64-bit ID of the user the backpack will be retrieved for.

Result data

result
status
The status of the request.
1
Success
8
The steamid parameter was invalid or missing.
15
Backpack is private.
18
The Steam ID given does not exist.
num_backpack_slots
The number of backpack slots this user has.
items
A list of item objects.
id
The unique ID of the specific item.
original_id
The ID of the item before it was customized, traded, or otherwise changed.
defindex
The defindex of the item, as found in the item array returned from GetSchema.
level
The arbitrary "level" value of the item as displayed in the inventory.
quantity
The number of "uses" an item has, generally only has a value in excess of '1' on "usable items", such as the Dueling Mini-Game.
origin[1] (Optional)
An integer used to lookup an origin name via GetSchema.
flag_cannot_trade (Optional)
A boolean value that is true if the item cannot be traded. Assume false if not present.
flag_cannot_craft (Optional)
A boolean value that is true if the item cannot be used in crafting. Assume false if not present.
inventory (Partially deprecated[2])
An inventory token as described here, or '0' if the item has been awarded and not yet found (placed in the backpack).
quality
The quality of the item (see definition in GetSchema).
custom_name (Optional)
The item's custom name if it has one.
custom_desc (Optional)
The item's custom description if it has one.
contained_item (Optional)
All the information for the item that this item contains for gift-wrapped items.
style (Optional)
An integer that can be used as an index to the item's style list.
attributes (Optional)
If the item has additional effects to the ones normally associated with it as described in GetSchema, contains a list of objects.
defindex
The index to the attributes definition in the schema, e.g. 133 for the medal number attribute for the Gentle Manne's Service Medal.
value
The value for this attribute for this item, e.g. the medal number for the Gentle Manne's Service Medal.
float_value (Optional)
The floating point value for this attribute if it has one.
account_info (Optional)
Set on attributes with a Steam ID as the value.
steamid
The specified user's unique 64-bit Steam ID.
personaname
The specified user's current name on Steam.
equipped[1] (Optional)
If the item is equipped, contains an array of equip information
class
The class the weapon is equipped to (numeric index).
0
Scout
1
Scout [3]
2
Sniper
3
Soldier
4
Demoman
5
Medic
6
Heavy
7
Pyro
8
Spy
9
Engineer
slot
The slot the weapon is equipped in (numeric index).
0
Primary
1
Secondary
2
Melee
4
Building
6
PDA2
7
Head
8
Misc 1
9
Action
10
Misc 2
65535
Set when the class had the item equipped previously.

Inventory token

The inventory token is a combination of class loadout flags and position in the player's backpack. This unsigned 32-bit integer is split into two two-byte words. The high word contains flags for each class. 1-bit in a class's slot indicates that the item is equipped in the appropriate loadout slot for that class. The low word contains the backpack position with '0' if the item has been awarded, but not yet found (placed in the backpack), '1' being the upper left slot, '2' the second slot from the left on the top row, etc. Here it is visually:


  ┌─────────────────────────────────────────────────────────────── Always '1'
  │ ┌─┬─┬─┬─┬─┬─────────────────────────────────────────────────── Placed in Backpack[4]
  │ │ │ │ │ │ │ ┌───────────────────────────────────────────────── Engineer 
  │ │ │ │ │ │ │ │ ┌─────────────────────────────────────────────── Spy 
  │ │ │ │ │ │ │ │ │ ┌───────────────────────────────────────────── Pyro 
  │ │ │ │ │ │ │ │ │ │ ┌─────────────────────────────────────────── Heavy 
  │ │ │ │ │ │ │ │ │ │ │ ┌───────────────────────────────────────── Medic 
  │ │ │ │ │ │ │ │ │ │ │ │ ┌─────────────────────────────────────── Demoman 
  │ │ │ │ │ │ │ │ │ │ │ │ │ ┌───────────────────────────────────── Soldier 
  │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌─────────────────────────────────── Sniper (or Atlas)
  │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌───────────────────────────────── Scout (or P-Body)
  │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─ Backpack position 
  │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Examples:

  1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1  Equipped Pyro item 
                                                                   in backpack slot 9
  1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1  Unequipped item 
                                                                   in backpack slot 41
  1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0  Equipped by Pyro and Engineer
                                                                   in backpack slot 42

Notes

  1. a b Specific to the TF2 interface.
  2. Assume fields for equipped classes to be incorrect, favor equipped
  3. This is probably the correct mapping for the scout and all equipped fields with 0 in it will probably have this as well. I'm guessing this is either an off-by-one bug or a workaround of it
  4. This bit is 0 when the item has been placed in the backpack and has its own slot. It is 1 if it has been recently dropped/traded for and it hasn't been allocated a backpack space.