Getting broadcaster data in Extension

  1. Is it possible to get broadcaster username using twitch helper?
  2. Is it possible to get broadcaster avatar using twitch helper?
  3. I found an api call like POST https://api.twitch.tv/extensions/<client ID>/<extension version>/channels/<channel ID>/chat. It sends chat message and works fine but i expected that chat message would contain broadcaster username but it’s an extension name from settings. Is it possible to send chat message with broadcaster username?
  1. No
  2. No

Decode the JWT which gives you the UserID, then use the UserID against the TwitchAPI

  1. No

Ok, thank you for your reply!

If you really wanted to do this, you would need to setup an oAuth loop via the config panel to request the relevant chat permission. BUT you will need to make it clear why and what it’s for and most Broadcasters will prefer NOT to provide this access as it represents quite a security risk to them.

I have to get back to this topic.
The third point is no longer needed.
I still have a problem with getting broadcaster data. As you wrote i need UserID from decoded JWT, but JWT doesn’t give me broadcaster userID when role is viewer. This is obvious, but my question was about the broadcaster data. So is it possible to get broadcaster data when the viewer is any user (logged in or not logged in)? What i noticed is that the channel_id (from decoded JWT) is equal to broadcaster userID, but i don’t know if that is a rule.

The channel_id is the channel_id of the page that you are on.

The broadcaster_id of channel_id is one and the same

When the broadcaster is using your extension the user_id is in the JWT is that of the broadcaster.

You can use the channel_id from the JWT to lookup the channel in the API

To answer your Points 1/2 better. You can take the channel_id and perform that lookup against the Twitch Users API. It can’t be done via the helper itself.

Thank you. It seems to be what i need.
Can i have one more question? I also want to get viewer data. It also could be done using userID (and then with Twitch Users API). But JWT gives me opauqe_user_id which cannot be use with API to retreive viewer data. Is there any way to do that?

You need to parse the JWT to get the user_id

The user_id is only populated if the user has chosen to share their user ID with the extension and you have identity enabled

The user’s Twitch user ID. This is provided only for users who allow your extension to identify them. There are no guarantees this will be available, as users can revoke an extension’s ability to identify them at any time. Users who revoke an extension’s ability to identify them are issued a new opaque identifier.