(Webhook?) Get currently played game

Hey,

I want to get all games that I('ve) play(ed) on my Stream and display the BoxArt in an Angular App.
I’m using the MEAN stack and I’ve managed it to get some data via this nice API-Wrapper: https://github.com/d-fischer/twitch

But since I could change my currently played game while streaming, it would be awesome to receive something like “Hey dude, you’ve just changed your game, here is the game data!”. And that’s where I stumbled upon the WebHooks reference.

The only problem is: I want to use my Angular App locally… so the callback URL would be “localhost:1337”, which wouldn’t work…

I could send a request every now and then, but I guess this isn’t the intended way to do it, right?

const game = await twitchClient.helix.games.getGameByName(channel.game);

This returns the needed game data, but it’s just a “one time request” and not connected to something like a WebHook.

So well, what are my options now?

And out of curiosity: why WebHooks and not WebSockets?
I mean this previously linked API-Wrapper runs in the frontend, too?! So the clientId and clientSecret is always kind of “exposed”.

clientSecret is NEVER exposed

Cost/scale is a short answer

Yes the streamChange webhook which’ll give you the game ID, then lookup the gameID against the hexlix API.

This will account for any changes to the Game Art or the name of the game. This appears to be what you are already doing with twitchClient.helix.games.getGameByName but you need to switch to using getGameByID if this library you refer to supports it.

Correct it would have to be on a “real server” that is web accessable. Sure you could open a port in your firewall, but that is NOT advised or suggested.

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