Getting CS: GO Statistics

How can I use the Steam Web API to get player statistics, such as Total Kills or Total Wins. Some sites that use these features include http://csgo-stats.com and http://csgo-stats.net . I tried using http://api.steampowered.com/ISteamUserStats/GetGlobalStatsForGame/v0001/?format=xml&appid=730&count=1&name[0]=total_wins without success. Where is the documentation for such statistics?

+6
source share
1 answer

I believe that you are using the wrong API endpoint for this. Use GetUserStatsForGame .

Your call will look like this:

 http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=<<KEY>>&steamid=<<PROFILEID>> 

Instead of <<KEY>> you will replace your API key and <<PROFILEID>> with the profile identifier (not SteamID) of the user you are interested in. This value will be the same as you when you log in through Valde OpenID.

This will return a result similar to this:

 { "playerstats": { "steamID": "7656-EDITED-OUT", "gameName": "ValveTestApp260", "stats": [ { "name": "total_kills", "value": 110527 }, { "name": "total_deaths", "value": 95930 }, { "name": "total_time_played", "value": 5784386 }, { "name": "total_planted_bombs", "value": 2726 }, { "name": "total_defused_bombs", "value": 594 }, { "name": "total_wins", "value": 26937 }, ... ] } } 

You can see that you need to iterate through the ['playerstats']['stats'] element and look at the name attribute of each to find the statistics you need.

+8
source

Source: https://habr.com/ru/post/980455/


All Articles