Difference between revisions of "WebAPI"

From Team Fortress Wiki
Jump to: navigation, search
(Methods)
(Remove some joerelics. Definition lists definition lists I looove youuuu, yes I dooooo)
Line 1: Line 1:
 
The Steam Web API is documented on [http://steamcommunity.com/dev Steam Community] and has a Valve Developer Wiki entry, [[vdc:Steam_Web_API|Steam Web API]]. The mapping of the API data to each data format is described on the latter.
 
The Steam Web API is documented on [http://steamcommunity.com/dev Steam Community] and has a Valve Developer Wiki entry, [[vdc:Steam_Web_API|Steam Web API]]. The mapping of the API data to each data format is described on the latter.
 
This page documents the web API calls that allow you to retrieve information from the item system in Team Fortress 2.
 
  
 
Calls to the TF2 Web API require a valid Steam Web API key to function. You can get your own API Key [http://www.steamcommunity.com/dev/apikey here]. Each example URL will only work after replacing "<code>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</code>" with your API key.
 
Calls to the TF2 Web API require a valid Steam Web API key to function. You can get your own API Key [http://www.steamcommunity.com/dev/apikey here]. Each example URL will only work after replacing "<code>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</code>" with your API key.
Line 7: Line 5:
 
== Common elements ==
 
== Common elements ==
  
=== Arguments ===
+
=== Parameters ===
  
 
All TF2 methods take the following arguments in their URL:
 
All TF2 methods take the following arguments in their URL:
  
*'''<code>key</code>''': Your Steam Web API key. Without this, the server will return a 403 Forbidden HTTP status.
+
;key: Your Steam Web API key. Without this, the server will return an HTTP 403 (forbidden) error.
*'''<code>format</code>''' ''(optional)'': The format to return the data in ("'''<code>json</code>'''" for JSON, "'''<code>xml</code>'''" for XML, or "'''<code>vdf</code>'''" for VDF). The structure of the data for each format is described [[vdc:Steam_Web_API#Formats|here]]. If no format is specified, the data will be returned with the default of JSON.
+
;format ''(<span style="color: red;">Optional</span>)'': The format to return the data in ("'''<code>json</code>'''" for JSON, "'''<code>xml</code>'''" for XML, or "'''<code>vdf</code>'''" for VDF). The structure of the data for each format is described [[vdc:Steam_Web_API#Formats|here]]. If no format is specified, the data will be returned with the default of JSON.
 
 
=== Result structure ===
 
 
 
All TF2 methods return a "'''<code>result</code>'''" object containing a status code (at "'''<code>status</code>'''") and either the data requested or a status message explaining why the data was not returned (at "'''<code>statusDetail</code>'''").
 
  
 
=== Terminology ===
 
=== Terminology ===
Line 24: Line 18:
 
== Methods ==
 
== Methods ==
  
* [[/GetSchema|GetSchema]]
+
;[[/GetSchema|GetSchema]]: Returns information about the items in a supporting game.
* [[/GetPlayerItems|GetPlayerItems]]
+
;[[/GetPlayerItems|GetPlayerItems]]: Lists items in a player's backpack.
* [[/GetAssetPrices|GetAssetPrices]]
+
;[[/GetAssetPrices|GetAssetPrices]]: Prices of items in the economy.
* [[/GetAssetClassInfo|GetAssetClassInfo]]
+
;[[/GetAssetClassInfo|GetAssetClassInfo]]: Asset metadata
* [[/ResolveVanityURL|ResolveVanityURL]]
+
;[[/ResolveVanityURL|ResolveVanityURL]]: Resolve vanity URL parts to a 64 bit ID.
* [[/GetNewsForApp|GetNewsForApp]]
+
;[[/GetNewsForApp|GetNewsForApp]]: News feed for various games
* [[/GetGlobalAchievementPercentagesForApp|GetGlobalAchievementPercentagesForApp]]
+
;[[/GetGlobalAchievementPercentagesForApp|GetGlobalAchievementPercentagesForApp]]: Statistics showing how much of the player base have unlocked various achievements.
  
 
== Notes ==
 
== Notes ==
Line 37: Line 31:
  
 
{{anchor|appids}}
 
{{anchor|appids}}
* <code>440</code>: Team Fortress 2
+
;440: Team Fortress 2
* <code>520</code>: Team Fortress 2 Public Beta
+
;520: Team Fortress 2 Public Beta
* <code>620</code>: Portal 2
+
;620: Portal 2
  
 
=== Methods Requiring a 64-bit User ID ===
 
=== Methods Requiring a 64-bit User ID ===
If a user's 64 bit ID is not readily available it can be obtained either by an OpenID transaction or by fetching the XML version of the user's Community profile page. This is accomplished by adding <code>?xml=1</code> to a normal community URL (for example: <code>http://steamcommunity.com/id/robinwalker?xml=1</code>) and reading the value given in the <code>steamID64</code> tag.
+
Most API requests that take an ID parameter require a 64 bit ID, if one is not readily available a vanity URL part can be resolved via [[/ResolveVanityURL|ResolveVanityURL]].
  
 
== Implementations ==
 
== Implementations ==

Revision as of 16:10, 8 December 2011

The Steam Web API is documented on Steam Community and has a Valve Developer Wiki entry, Steam Web API. The mapping of the API data to each data format is described on the latter.

Calls to the TF2 Web API require a valid Steam Web API key to function. You can get your own API Key here. Each example URL will only work after replacing "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" with your API key.

Common elements

Parameters

All TF2 methods take the following arguments in their URL:

key
Your Steam Web API key. Without this, the server will return an HTTP 403 (forbidden) error.
format (Optional)
The format to return the data in ("json" for JSON, "xml" for XML, or "vdf" for VDF). The structure of the data for each format is described here. If no format is specified, the data will be returned with the default of JSON.

Terminology

A "tokenized string" refers to a string containing "#"-prefixed tokens that are replaced with the equivalent string in the game's VDF for the chosen language. For instance, "TF_Weapon_Jar" is defined as "Jar Based Karate" in tf/resource/tf_english.txt (as found in "team fortress 2 content.gcf").

Methods

GetSchema
Returns information about the items in a supporting game.
GetPlayerItems
Lists items in a player's backpack.
GetAssetPrices
Prices of items in the economy.
GetAssetClassInfo
Asset metadata
ResolveVanityURL
Resolve vanity URL parts to a 64 bit ID.
GetNewsForApp
News feed for various games
GetGlobalAchievementPercentagesForApp
Statistics showing how much of the player base have unlocked various achievements.

Notes

List of valid IDs

440
Team Fortress 2
520
Team Fortress 2 Public Beta
620
Portal 2

Methods Requiring a 64-bit User ID

Most API requests that take an ID parameter require a 64 bit ID, if one is not readily available a vanity URL part can be resolved via ResolveVanityURL.

Implementations

See also