Getting realtime channel events for any channel

I’m trying to get real-time subscription and bits info from a channel.

Kinda stuck with the pubsub topic in that it isn’t accepting my OAuth token. I’m confused about whether this token is supposed to be a user access token or an app access token.

I read here that if I need to consume topics from another channel, then that channel will have to go through my authentication process? How will that work out?

“Also keep in mind that you need a token of the channel you wish to receive events from.”

How do I get a token for any channel to get that channel’s real-time events? Is that even possible?

For channel subscriptions on pubsub, you will need a User Access token with the channel_subscriptions scope. App access tokens aren’t for accessing anything that requires user authorization.

To get a User Access Token you can follow the documentation

You need the owner of the channel you want to get events for to go through the authentication flow for your app and that will provide you with a User Token that you can use to get subscriber events for their channel. For bits any scope will work, you don’t need a specific one, but it does have to be from the channel owner of the channel you want events for.

Alternatively you can use an IRC or Websocket connection to Twitch Chat and listen to events through that but again you will need permission from the channel owner to do so or you could be breaking the Developer Agreement.

1 Like

Will individual chat messages have any information that tells me that they are cheers? I just tried connecting to a channel and got it’s chat stream. I can see that some of these messages have the cheer icon with them but they don’t appear to have anything particular in them that identifies that.

You need to enable the TAGS capability and consume badges on PRIVMSG. The cheer icon/badge tells you that a person has cheered on that channel.

Cheer events:

1 Like

Would I need to fetch my auth token with a specific permission to enable the TAGS capability? I tried passing USERNOTICE command after connecting but I get a 421 message saying it’s an invalid command.



1 Like

Here’s the list of commands I’m sending now:

        s = socket.socket()
        s.connect((HOST, PORT))
        s.send("PASS {}\r\n".format(PASS).encode("utf-8"))
        s.send("NICK {}\r\n".format(NICK).encode("utf-8"))
        s.send("JOIN {}\r\n".format(CHAN).encode("utf-8"))
        s.send("CAP REQ".encode("utf-8"))

I’m still only getting the message in PRIVMSG.

This is the first time I’m using the irc protocol so the questions are a bit noobish. I’m using python btw.

Check the Raw line.

Sounds like your python IRC lib is extracing the tags from the message and putting them somewhere else for refering to

1 Like

I think you might be missing a \r\n there.


I needed to send s.send("CAP REQ".encode("utf-8")) before all the other commands. I’ve received the ACK now and I’m getting all the badges. Thank you all for your responses.

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