My steam game has a leaderboard. No one is playing yet but I hope they will.

As a way to promote community for the game I thought it would be cool to get leaderboard updates in official discord community for the game. Here’s how I did it.

For this method to work you need to have access to Steamworks Admin page for the game.

TLDR

  1. Create a Discord Webhook
  2. Get a Publisher key with General key permissions for Steam Web API
    • official doc, scroll to the very end
    • make sure to create a Publisher Key, not a User key
    • if you are unsure if your key works, you can test it with this
  3. Get your AppID for your Steam game
  4. Use ISteamLeaderboards interface of the Steam Web API with the Publisher key
    • official docs
    • specifically, you need methods:
      • GetLeaderboardsForGame to get the Steam internal leaderboardid of your leaderboard
      • GetLeaderboardEntries to the leaderboard entries
    • you can test requests by using Steam Web API reference by xPaw.

For hosting, I chose GitLab CI scheduled pipeline, because of its generous free tier.

At this point you can just feed this to any AI model with a prompt to make a bot that will post leaderboard updates into Discord and, I’m confident, it will nail it on the first try.

Steam Web API with Publisher Key

The hardest part of this entire project was to find the appropriate way to interact with Steam servers: appropriate interfaces, methods, and a correct API key.

Steam has:

  • an SDK
  • Web API
  • deprecated XML API

Confusingly, deprecated XML data API has a Leaderboard endpoint mentioned here. However, I couldn’t figure out how to get CommunityGameName slug for my game, and I’m not the only one: next month there will be 10 year anniversery of this guy’s question. So I turned to Steam Web API.

To hinder me still, I’ve found a few pages with Steam Web API documentation. Unsurprisingly, the best one was on official Steamworks site here.

At first, all my requests to API failed, but it was because I was using User API key, when Publisher key was required. API doc does make it clear to use Publisher key, but who reads it before trying out the API first?