A Little About Steam Web Api



Valve's Steam digital distribution service is becoming increasingly popular among players. As of January 2013, over three thousand products are distributed through Steam, which are subject to daily, weekly and weekend discounts, and the number of registered accounts has exceeded 60 million.

Currently, there is very little information in Runet about the use of Steam Api (or Steam Web Api) . In this topic, I’ll talk about how to get the information you need from the Steam community to integrate it into your sites, blogs, or just get user information without logging into Steam.

Let's start with the main thing. After simple steps, I created one php page, which, at the request of the username , or SteamIDor SteamcommunityID , displays a lot of detailed Steam profile information. There is much more information than similar English-language services provide.

You can view the page here . If desired, you can significantly modify the service, for example, add the ability to determine what games are on the account of a particular user, and how much they cost (as steamcalculator once did ) .

Who cares about the source code of my page, the algorithm for determining the type of input data, or the algorithm for sorting the same xml parameters, you can write to me here, or in the contact information on that page.

Open the hood of Steam
Steam user information can be obtained in several ways. The most popular of them are:
- use the Steam Web Api, which they themselves offer (but alas, there is not much information provided there)
- receive and process community data directly, in xml format.
- receive and process community data directly, in json format.

The first method is not particularly interesting to me, I used the two remaining ones at once.

XML
Getting user information is pretty simple. Just enter the query in the address bar of the browser in the form:
steamcommunity.com/profiles * SteamID * /? Xml = 1
For example:
steamcommunity.com/profiles/76561198036370701/?xml=1
(by the way, if the user has CustomURL, then the link address will change from " ... / profiles / * SteamID * / ... " to " ... / id / * CustomURL * / ... ") You

can catch this page and process with the help of cURL or (which is easier for me) the simplexml_load_file () functions ; , for example:
$slf = "http://steamcommunity.com/profiles/76561198036370701/?xml=1";
$url = simplexml_load_file($slf);

Now, to display, for example, the contents of the <steamID> ... </ steamID> tags, anywhere in your page, you can use the following code:
steamID;?>

JSON
First of all, you need apikey . You can register it here .

You can get summary information about the Steam user using the link of the form:
api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key= * apikey * & steamids = * SteamID *
For example:
api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=38A3BEAE3EFA726E44B78076577076577076577076577076577077076577076577076577076577077076577076577076577076577076577077076577076577076577076577076577076577077077

and 7707707 and 7707657707657707 and 770765770765770765777076577076577076577076577077707 and file_get_contents , and later convert everything to an array in approximately this way:
$urljson = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=*apikey*&steamids=*steamid*");
$data = (array) json_decode($urljson)->response->players[0];

For example:
$urljson = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=38A3BEAE3EFA726E4438207D08CB0EC7&steamids=76561198036370701");
$data = (array) json_decode($urljson)->response->players[0];

And output, for example, the contents of the profileurl block with a line of code: To


summarize The
methods for obtaining information about the Steam user are not limited to those that I cited. Those links with which I received data are used only to obtain the total (total)information. Separately, you can get a list of user's games, a list of friends, a list of groups, items of inventory and a workshop, and much more.

Based on the data received, you can also make a service for generating banners, userbars, profiles for forums and blogs, by analogy with the steamprofile service .

Among the shortcomings of the service, we can distinguish that at the peak of the load on Steam servers, to obtain information about the user, the time for requesting data can vary from 0.1 to 12 seconds, and error 503 often occurs (the service is unavailable), you have to send the request again. As an option to solve the problem - do not send a request more than once every 10 seconds. If you have other ways to solve the problem, write.

Some links to help you learn Steam Web Api:
steamcommunity.com/dev?l=russian
partner.steamgames.com/documentation/webapi
developer.valvesoftware.com/wiki/Steam_Web_API
steamcommunityapi.googlecode.com/svn-history/r5/trunk

Also popular now: