How could I use the Steam Web API to get a player's stats, such as "Total Kills" or "Total Wins". Some sites that use these features include http://csgo-stats.com and http://csgo-stats.net. I have tried using http://api.steampowered.com/ISteamUserStats/GetGlobalStatsForGame/v0001/?format=xml&appid=730&count=1&name[0]=total_wins
with no success. Where is the documentation for such statistics?
Asked
Active
Viewed 2.3k times
6

Andrew
- 273
- 1
- 3
- 16
1 Answers
11
I believe you are using the wrong API end point for this. Utilize the GetUserStatsForGame
end point instead.
Your call will look like this:
http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=<<KEY>>&steamid=<<PROFILEID>>
You'll replace <<KEY>>
with your API key and <<PROFILEID>>
with the profile ID (not SteamID) of the user you are interested in. This value is the same one passed to you when you sign in via Valve's 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 stats you are looking for.
-
does this work now? I dont think so... I am trying but it is giving me empty results – Umair Ayub Sep 28 '16 at 21:17
-
@Umair Maybe You are trying to get "Your own" stats, i.e. Your `steamid` parameter is the same that is linked to Your API `key`. I had very similar problem today. It seems like You cannot do that with `GetUserStatsForGame`. (Internal Server Error) – Skipper Feb 24 '18 at 10:14