!hours command to return steam game hours

Ok so I’ve been looking everywhere and I just can’t find what I want so far. I’m trying to replicate a command I’ve seen in other channels that shows the current total hours in a steam game. Other channels seem to use the urlfetch variable which I’m fine with doing but I just don’t know what url to use to get these stats:

so I’d like the command to be !hours and when that’s typed I’d like a message to say “user has played game a for x hours”

I have the steam url of the streamer in question, and the game is Rocket League, but I just don’t know what else I need to include in this command to pull out the steam profiles total game hours. Anyone help?

Since you have the Steam URL, you can get the Steam64 ID using something like SteamID.co

Then you can use a custom API I wrote for this: https://decapi.me/steam/hours?id=STEAM_ID_HERE&appid=252950

Where you replace “STEAM_ID_HERE” with the Steam64 ID. The “appid” is currently set to Rocket League, but you can relatively easily find the app ID of other games by checking the store page URL (example: Rocket League’s Steam page is: http://store.steampowered.com/app/252950/ and the app ID is the number after “/app”).

Another important note to mention: If the Steam account is not public, then the custom API will probably not be able to get the amount of hours.
There is a way to get around this, which is using the Steam API key of the account owner (which they can get from here: https://steamcommunity.com/dev/apikey) and append to the URL using &key=STEAM_API_KEY_HERE. Just be careful to not add this through chat, as anyone that sees that key could use it for malicious reasons.

Here’s what you put as the command result in Nightbot:

  • Without API key
    • <Streamer> has played Rocket League for $(urlfetch https://beta.decapi.me/steam/hours?id=STEAM_ID_HERE&appid=252950)
  • With API key
    • <Streamer> has played Rocket League for $(urlfetch https://beta.decapi.me/steam/hours?id=STEAM_ID_HERE&appid=252950&key=STEAM_API_KEY_HERE)
    • As I mentioned, I would be careful if you plan on adding this in chat. I recommend doing it through the Nightbot dashboard: https://beta.nightbot.tv/dashboard if possible, to prevent malicious users from abusing it.

The result should look similar to this:
<Streamer> has played Rocket League for 123.45 hours


100% perfection! Thanks very much

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.