# Getting broadcaster data in Extension

**URL:** <https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745>\
**Category:** Extensions\
**Created:** [January 28, 2019, 9:25am UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745 "2019-01-28T09:25:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![miketag](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@miketag](https://discuss.dev.twitch.com/u/miketag)\
**Post date:** [January 28, 2019, 9:25am UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/1 "2019-01-28T09:25:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 28, 2019, 9:32am UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/2 "2019-01-28T09:32:44Z")

</div>

1. No
2. No

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

1. No

---

<div class="post-metadata">

**Author:** ![miketag](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@miketag](https://discuss.dev.twitch.com/u/miketag)\
**Post date:** [January 28, 2019, 1:19pm UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/3 "2019-01-28T13:19:46Z")

</div>

Ok, thank you for your reply!

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [January 28, 2019, 1:21pm UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/4 "2019-01-28T13:21:09Z")

</div>

> [@miketag](#):
>
> Is it possible to send chat message with broadcaster username?

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.

---

<div class="post-metadata">

**Author:** ![miketag](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@miketag](https://discuss.dev.twitch.com/u/miketag)\
**Post date:** [March 6, 2019, 11:41am UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/5 "2019-03-06T11:41:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 6, 2019, 12:14pm UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/6 "2019-03-06T12:14:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![miketag](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@miketag](https://discuss.dev.twitch.com/u/miketag)\
**Post date:** [March 6, 2019, 12:43pm UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/7 "2019-03-06T12:43:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 6, 2019, 12:52pm UTC](https://discuss.dev.twitch.com/t/getting-broadcaster-data-in-extension/19745/8 "2019-03-06T12:52:12Z")

</div>

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

> **[Extensions Reference](https://dev.twitch.tv/docs/extensions/reference/#jwt-schema)**
>
> Extensions Reference

> 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.
