Using Steamworks Web API to Expand on Greenworks / Greengrinds functionality

3

Stats

814 visits, 978 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 24 Mar, 2021. Last updated 26 Mar, 2021

Wanted to share this tutorial for the benefit of anyone who is using Greenworks or Greengrinds for Steam integration but is looking for slightly more functionality. Thanks to Mikal for pointing out Steam's Web API to me when I got stuck.

Steam's web API can be used to get info beyond that is available through Greenworks and Greengrinds, specifically global stats.

These include:

  • Get Global Achievement Percentages
  • Get Global Stats
  • Get Number of Current Players
  • Get User Stats (for any user, not specific to current player)
  • And more..

The documentation for the web API can be found here: https://partner.steamgames.com/doc/webapi/ISteamUserStats

Example call

An example call for my project is: "https://api.steampowered.com/ISteamUserStats/GetGlobalStatsForGame/v1/?appid=1559620&count=1&name[0]=GooperAttemptsGlobal"

If you copy and paste the example call in your browser, you'll see that the return includes an integer, representing the total stat value for all my players. This currently reads:

"{"response":{"globalstats":{"GooperAttemptsGlobal":{"total":"319"}},"result":1}}"

Using AJAX to call Steam's web API in your project

To access the web API in your project, you can use an AJAX request.[Note this won't work in preview, see AJAX documentation for cross-domain requests]

Use cases

Example 1

Using GetGlobalStatsForGame (as in the example request above), you can return the aggregate stat value for all players of your game. In my case, I use this to track the number of players deaths and in my main menu include a "Test Subject: {return}" for a bit of thematic flavour.

Example 2

Using GetGlobalAchievementPercentagesForApp you will return the % acquisition for each achievement in your game. You can then use this to show your player how their progress compares to the player base as a whole.

Example 3

Calling GetNumberOfCurrentPlayers returns the number of active players at that time. This can be useful if your game has a community aspect, or matchmaking etc.

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!