# PubSub Multiple Users

**URL:** <https://discuss.dev.twitch.com/t/pubsub-multiple-users/31873>\
**Category:** API\
**Created:** [May 29, 2021, 9:06pm UTC](https://discuss.dev.twitch.com/t/pubsub-multiple-users/31873 "2021-05-29T21:06:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kd88](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/kd88/32/12078_2.png) [@kd88](https://discuss.dev.twitch.com/u/kd88)\
**Post date:** [May 29, 2021, 9:06pm UTC](https://discuss.dev.twitch.com/t/pubsub-multiple-users/31873/1 "2021-05-29T21:06:06Z")

</div>

I am looking to read multiple twitch channels, channel point redemptions simultaneously. I currently know how to read a single channel’s redemptions, but am not sure how to syntactically do multiple twitch channels.

I use the PubSub to read a single channel and noticed it allows multiple topics, unsure if I need to get all users with a single auth token or create a list of both user topics and user auth tokens individually

---

<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:** [May 29, 2021, 9:16pm UTC](https://discuss.dev.twitch.com/t/pubsub-multiple-users/31873/2 "2021-05-29T21:16:15Z")

</div>

When using pubsub, you sub with a topic and a token for that topic.

So you’ll send, for exmaple,

> listen liriktopics liriktoken

then as a second listen request

> listen ninjatopics ninjatoken

---

<div class="post-metadata">

**Author:** ![kd88](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/kd88/32/12078_2.png) [@kd88](https://discuss.dev.twitch.com/u/kd88)\
**Post date:** [May 29, 2021, 9:21pm UTC](https://discuss.dev.twitch.com/t/pubsub-multiple-users/31873/3 "2021-05-29T21:21:10Z")

</div>

```
ws.onopen = function (event) {

    var messageListen = {
        type: 'LISTEN',
        data: {
            topics: ['channel-points-channel-v1.<userID>'],
            auth_token: '<token>',
        }
    };

    ws.send(JSON.stringify(messageListen));

    ws.onerror = function (error) {
        console.log('ERR: ' + JSON.stringify(error) + '\n')
    };
};

```

Above is my code for example, would I have to do multiple ws.send for multiple users? Or is there a way to combine all the users into a single ws.send ?

---

<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:** [May 29, 2021, 9:25pm UTC](https://discuss.dev.twitch.com/t/pubsub-multiple-users/31873/4 "2021-05-29T21:25:32Z")

</div>

You would need one `ws.send` per user.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [June 28, 2021, 9:26pm UTC](https://discuss.dev.twitch.com/t/pubsub-multiple-users/31873/5 "2021-06-28T21:26:15Z")

</div>

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