Steam Web API

From Valve Developer Community
Jump to: navigation, search

API result structure

The API returns a "result" object containing a status code (at "status") and either the data requested or a status message explaining why the data was not returned (at "statusDetail").

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 returns an object containing an object named "result" containing the status data.
    • 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.

Game interfaces and methods

Team Fortress 2 functions are described at http://wiki.teamfortress.com/w/index.php?title=WebAPI.

Other interfaces and methods

GetNewsForApp (v0001)

GetNewsForApp returns the latest of a game specified by its appID.

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

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.

GetGlobalAchievementPercentagesForApp (v0001)

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

Example: http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0001/?appid=440

Arguments

  • appid
    • AppID of the game you want the news of.