Difference between revisions of "WebAPI"

From Team Fortress Wiki
Jump to: navigation, search
(GetPlayerItems (v0001))
m (GetPlayerItems (v0001))
Line 73: Line 73:
 
The first 32 items listed describe the original class weapons, with the name being the symbolic token for that weapon. The next 3 (defindex 32-35) describe abortive attempts at the original Medic unlockables, with the names being "Level 1 X" (where X is the name of the original item), and the original's art files defined (although the saw lists the Ubersaw's icon).
 
The first 32 items listed describe the original class weapons, with the name being the symbolic token for that weapon. The next 3 (defindex 32-35) describe abortive attempts at the original Medic unlockables, with the names being "Level 1 X" (where X is the name of the original item), and the original's art files defined (although the saw lists the Ubersaw's icon).
  
== GetPlayerItems (v0001) ==
+
=== GetPlayerItems (v0001) ===
  
 
The GetPlayerItems call returns a the items for the player specified. If a player has their Steam community profile set to Private you will not be able to retrieve their items.  
 
The GetPlayerItems call returns a the items for the player specified. If a player has their Steam community profile set to Private you will not be able to retrieve their items.  
Line 79: Line 79:
 
Example URL: http://api.steampowered.com/ITFItems_440/GetPlayerItems/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamID=12345678  
 
Example URL: http://api.steampowered.com/ITFItems_440/GetPlayerItems/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamID=12345678  
  
=== Arguments ===
+
==== Arguments ====
  
 
*'''steamID'''  
 
*'''steamID'''  
Line 86: Line 86:
 
** Format you want the request to be returned. See above.
 
** Format you want the request to be returned. See above.
  
=== Return Value ===
+
==== Return Value ====
  
 
A list of the player's items is returned, as follows (json):  
 
A list of the player's items is returned, as follows (json):  

Revision as of 11:36, 2 July 2010

The Steam Web API is documented at http://steamcommunity.com/dev. Where the Steam Web API ends and the TF2 Web API begins is not yet defined (the latter currently comprising the whole of the former), so this page documents everything not listed there.

Format differences

Every method can return its results in 3 different formats: JSON, XML, and VDF. Each format represents the data described herein differently:

  • JSON
    • The API contains an object containing an object named "result".
    • Arrays are represented as an array with the name of the type of the objects in the array (ie. an object named "items" containing an array of objects of type "item" would be represented as an object named "items" containing an array named "item" containing several objects following the "item" structure).
    • Null is represented as JSON's null.
  • XML
    • XML Attributes are not used.
    • Arrays are represented as a series of sub-elements in the containing element of the type of the array.
    • Null is represented by the word "null" between the element's tags.
  • VDF (Valve Data Format)
    • This is Valve's internal data format, seen in TF2's "scripts" folder (available in "team fortress 2 client content.gcf"). GetSchema returns data similar to "items/items_game.txt" (although qualities are not expanded into objects with a "value" field).
    • It appears to be undocumented, but it works similarly to JSON's objects:
      • A member is represented by a quoted string, followed by a newline and an open brace.
      • A value is represented as a key-value pair of quoted strings on the same line separated by a tab character. Each sub-object is indented by one tab character.
    • Arrays in the data are represented as a VDF array with the name of the type of the objects in the array, with a VDF array being an object with each item being prefixed with its numeric key as a quoted string.
    • Null is represented as an empty string.

If no format is specified, the API will default to JSON.

Methods

The following web API calls allow you to retrieve information from the item system in Team Fortress 2. Each call requires a valid API Key to function. You can get your own API Key here.

GetSchema (v0001)

This method returns the item schema for the current build of Team Fortress 2. It takes no additional parameters.

Example URL: http://api.steampowered.com/ITFItems_440/GetSchema/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&format=json

Return data layout

  • "result": An object containing the results of the call.
    • "status": A numeric status code of unknown meaning.
    • "qualities": An object containing the numeric values corresponding to each "quality" an item can have (excluding three entries for the standard Medic weapons between the standard weapons and the unlockable weapons, which have the unlisted quality of 255):
      • "normal" (0): All of the standard inherent basic class weapons have this listed as their quality.
      • "common" (1): No weapons have this listed as their quality.
      • "rare" (2): No weapons have this listed as their quality.
      • "unique" (3): All other items have this listed as their quality.
      • "community" (7): No weapons have this as listed their quality.
      • "developer" (8): No weapons have this as listed their quality.
      • "selfmade" (9): No weapons have this as listed their quality.
    • "items": An object containing an array of "item":
      • "name": A string describing the item (eg. "Unique Achievement Feign Watch" for the Dead Ringer).
      • "defindex": The item's unique index as seen in GetPlayerItems.
      • "item_class": The item's class in game (ie. what you would use as the argument to "equip" in the console to equip it).
      • "item_type_name": The string containing pound-prefixed tokens for the string in TF2's language files that describes the item's class (ie. "#TF_Wearable_Shield" for the Chargin' Targe).
      • "item_name"
      • "item_slot"
      • "item_quality"
      • "image_inventory":
      • "model_player": The model to display for the item, or null if the object has no model.
      • "attributes" (Optional): If the item has gameplay effects, an object containing an array of "attribute":
        • "name": The attribute's "name" (see below)
        • "class":
        • "value":
    • "attributes": An object containing an array of "attribute":
      • "name": A name describing the attribute (eg. "scattergun has knockback" for the Force-A-Nature's knockback)

Return data implementation

The first 32 items listed describe the original class weapons, with the name being the symbolic token for that weapon. The next 3 (defindex 32-35) describe abortive attempts at the original Medic unlockables, with the names being "Level 1 X" (where X is the name of the original item), and the original's art files defined (although the saw lists the Ubersaw's icon).

GetPlayerItems (v0001)

The GetPlayerItems call returns a the items for the player specified. If a player has their Steam community profile set to Private you will not be able to retrieve their items.

Example URL: http://api.steampowered.com/ITFItems_440/GetPlayerItems/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamID=12345678

Arguments

  • steamID
    • SteamID of an user.
  • format
    • Format you want the request to be returned. See above.

Return Value

A list of the player's items is returned, as follows (json):

{ 
  "result": { 
      "status": 1, 
      "items": { 
          "item": [ 
              { 
                  "id": 827, 
                  "defindex": 166, 
                  "level": 5, 
                  "quality": 3, 
                  "inventory": 2147483650, 
                  "quantity": 1, 
                  "attributes": 
                  { 
                      "attribute": [ 
                          { 
                              "defindex": 143, 
                              "value": 1272326400.000000 
                          } 
                      ] 
                  } 
              }, 
          ] 
      }
  } 
} 

If a player's profile is set to Private the status field will be set to 15 (Access Denied) and there will be no items field.

Other interfaces and methods

GetNewsForApp (v0001)

GetNewsForApp returns the latest of a game specified by it's appID.

Example URL http://api.steampowered.com/ISteamNews/GetNewsForApp/v0001/?appid=440&count=3&maxlength=300&format=xml

Arguments

  • appid
    • AppID of the game you want the news of.
  • count
    • How many news enties you want to get returned.
  • maxlength
    • Maximum length of each news entry.
  • format
    • The type of the format you want the request to be returned. See above.


GetGlobalAchievementPercentagesForApp (v0001)

Returns on global achievements overview of a specific game in percentages.

Example: http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0001/?gameid=440&format=xml

Arguments

  • appid
    • AppID of the game you want the news of.
  • format
    • The type of the format you want the request to be returned. See above.