WebHook response from a "stream is offline" event

I subscribed to events with the topic Stream-Changed
If a stream is offline I get the response:

{
   "data": []
}

How can I know from the response which stream is offline if I subscribe to events from few streams? I think it would have been good if such respond had had at least user_id.

1 Like

The payload matches what the response is under helix API which is data:[] as per the webhooks specification.

But, there are a couple of options, you can parse one of the headers:

Or more usefully, is to setup, so that your callback URL is:

https://mydomain.com/twitchwebhooks/$webhooktype/$userid

For the hook

https://api.twitch.tv/helix/streams?user_id=5678

Which would result in you setting your Callback URL to

https://mydomain.com/twitchwebhooks/streams/5678

Then just parse the URL for the parameters you need. Which is child’s play under nodeJS Express.

request.route('/twitchwebhooks/:hook/:id', function(req, resp) {
    switch (req.params.hook) {
        case 'streams':
            // snip
2 Likes

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