Get user's playtime of a game on Steam with DecAPI Steam API without providing Steam app id.
Useful for custom chatbot commands and Twitch integration.
- Clone this repo.
- Install Node.js dependencies:
npm install
- Create a
.env
file on the root directory. - Set the streamer's Steam user ID and (optional) Steam API key in the .env file.
- Run the server:
node server
- Fastify server will run on port
3000
.
Once the server is started, the API can be called through /playtime/<GAME_NAME>
.
Expected response:
Gaben has been playing NEKOPARA Vol. 1 for 6.83 hours.
Using Nightbot and DecAPI, one can automate the API call and get the playtime of the currently streamed game on Twitch.
The Nightbot command will use two APIs respectively:
- ✨This API✨
<HOSTNAME>/playtime/<GAME_NAME>
, and - DecAPI
https://decapi.me/twitch/game/<CHANNEL_NAME>
.
Implementation in Nightbot can be done by nesting Nightbot variables:
$(urlfetch <HOSTNAME>/playtime/$(urlfetch https://decapi.me/twitch/game/<CHANNEL_NAME>))