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:
If you look in the headers of the request you can parse the “link” header:
Something like (from my log)
"link":"<https://api.twitch.tv/helix/webhooks/hub>; rel=\"hub\", <https://api.twitch.tv/helix/users/follows?to_id=TWITCHOD>; rel=\"self\"
So you can parse that out.
Personally I’m using NodeJS and Express Param routing.
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
system
Closed
December 23, 2018, 9:17am
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.