Webhook sometimes sending blank "user_name"

Hi I’m using node.js (no express atm) to get a stream goes live event webhook.

The webhook handshake works and notifications are sent to my discord webhook but sometimes the data I receive from twitch contains a blank “user_name” field.

Subscribing via hub.topic: https://api.twitch.tv/helix/streams?user_id=XXXXX

What I expect with both my user_name and user_id sent: https://puu.sh/CC0N9.png

What I seem to “randomly” receive:

{“community_ids”:[“3f35d6f4-1c06-4073-aa1e-4ffb52d6085f”,“739ca24b-ef02-4bad-b859-6953fb9b1cb1”,“8387b4ef-510b-4940-9876-e1787c8822de”],“game_id”:“18122”,“id”:“32386002304”,“language”:“en”,“started_at”:“2019-01-26T11:09:13Z”,“tag_ids”:null,“thumbnail_url”:“https://static-cdn.jtvnw.net/previews-ttv/live_user_todgins-{width}x{height}.jpg",“title”:"Prog? Afflock PoV”,“type”:“live”,“user_id”:“45748839”,“user_name”:"",“viewer_count”:0}

This results in the discord post randomly dropping streamers name, such as in this case (he restarted his stream 3 times after a crash and all 3 worked, but earlier stream has dropped data): http://puu.sh/CCzoi.png

Is this something on my end? Do I need to add some sort of delay on the code or is it literally Twitch just dropping the data from that field before it is sent?

It’s a known issue with the API that is being worked on, so it’s not your code that is at fault.

The best way I can suggest to mitigate the issue is to keep a cache on your end of the user id’s and their corresponding usernames, that way when you need to make use of the username, such as in a Discord post, you get the username from your cache or database for that user_id and use that rather than attempting to use the user_name field which is sometimes missing.

Thanks for that sanity check!

I’m going to request the game endpoint to grab game name from the ID so will try to poke at the users endpoint and grab a display name from the name ID.

Caching locally sounds like a great backup plan, again many thanks!

EDIT: For reference sending user ID from the streams subscription to the users endpoint to get user’s display name and login name seem like a solid workaround for now. Likewise game ID from streams subscription to games endpoint works fine too.

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