Twitch API and PubSub access


this little component let’s you connect to the Twitch API v5 as well as the PubSub API to subscribe to topics such as when users “cheer” a channel, somebody subscribes to a channel, a purchase is made on the channel or somebody “whispers” your twitch account.

The underlying network consists of the webCOMP from the palette as well as a websocket DAT to connect to the PubSub interface.

To get started you need to:

  1. register an App on
  2. create a callback page on a webserver you own
  3. retrieve an OAuth token
  4. start and configure the attached component

Register an App on
with a twitch account already registered go to Here select “Apps” and click on “Register Your Application”.

Fill out the required fields and note the OAuth Redirect URL. This will be the place where you will retrieve your OAuth Token. Click the “Create” button.

create a callback page on a webserver you own
At the location you have specified for your OAuth callback URL create a page. The page needs to link to the endpoint with parameters passed being the

  • redirect_url (exactly as you entered it in the App Create Page)
  • client_id (you can retrieve this from your Manage Application Page on twitch)
  • the scope strings which is a list of data points you want to have access to from your twitch component. A full list of available scopes and what access they will allow you can be found here:
<a href=>Click me for access</a>

retrieve the OAuth Token
Navigate in your browser to the callback page where you created the link shown above. Click onthe link and you should be asked to either login to your Twitch Account, or if you are already logged in, it will ask you if you want to give all the permissions to the App that you have been requesting via the scope parameter passed along in the link.

You should be redirected to the page with the link. Here, copy the url and search for the “access_token” parameter. An example url would look like this:

copy the access token.

start and configure the twitch component
Start the attached file and copy Client ID as well as OAuth Token into the parameters on the Twitch parameter page.
NOTE: KEEP THAT OAuth TOKEN A SECRET! depending on what rights you have given the application, anyone with the OAuth token now can make use of the API to control the account it is associated with. You can either recreate a token to invalidate the previous one or make sure to delete it from your file before passing it on to others or showing the parameters of the Twitch Component on a Twitch Stream!


Switch over to the PubSub parameter page and click the “Get ChannelID” Pulse parameter.
If a ChannelID is being displayed in the ChannelID Parameter, you are now ready to start listening to Bits, Channel Subscriptions, Commerce Events and Whispers.

Any event is being passed into the callback DAT specified under the Callbacks parameter. By default the received json is printed to the textport. By editing the Callbacks DAT you can control what should be happening on such an event.

For example a whisper event will return a python dictionary similar to this:

	'thread_id': '104027510_114993034', 
	'tags': {
		'badges': [], 
		'login': 'touchdesigner', 
		'emotes': [], 
		'user_type': '', 
		'color': '', 
		'display_name': 'touchdesigner'
	'recipient': {
		'profile_image': None, 
		'badges': [], 
		'display_name': 'Wuestenarchitekten', 
		'user_type': '', 
		'id': 104027510, 
		'color': '', 
		'username': 'wuestenarchitekten'
	'body': 'Hello Wuestenarchitekten!!', 
	'id': 26, 
	'from_id': 114993034, 
	'sent_ts': 1543873537, 
	'nonce': '2af192ba897205942937d9cf7e14877f', 
	'message_id': '6ce98ed0-a944-44e1-9a31-204a6c262d32'

An overview over all PubSub topics can be found here:

Access to the Twitch API v5
You can use the included webCOMP to access the Twitch API v5

For example to get more information about your channel use following python code:

# specify the path of the Twitch Component
twitchCOMP = op('twitch')
url = ''
requestType = 'get'
header = {
	'Accept': 'application/vnd.twitchtv.v5+json',
	'Client-ID': twitchCOMP.par.Clientid.eval(),
	'Authorization': 'OAuth {0}'.format(twitchCOMP.par.Oauthtoken.eval())
twitchCOMP.Send(url=url, requestType=requestType, header=header)

The response from the Twitch server will be processed by a DAT called “webCOMPCallback” inside the Twitch Component. In it’s included “receive” function is were you would have to parse the responses.
twitch.tox (13.6 KB)

small update to the Twitch component.

You can now connect to channel chats and chat rooms. Messages are relayed to a callback DAT and you can also send messages.

After following the instructions on how to get an app going and connected (don’t forget to click the “Get Channel Info” pulse parameter), you can now turn on the chat feature by enabling the “Connect” parameter on the “Chat” parameter page. All available rooms in your channel will be loaded and via the “Room” parameter dropdown, you can choose where to send messages to. All received messages are dealt with in the “chatCallback” DAT inside the Twitch component.

to join another channel:

# specify the path of the Twitch Component
twitchCOMP = op('twitch')

to send a message to another channel:

# specify the path of the Twitch Component
twitchCOMP = op('twitch')
twitchCOMP.SendMsg(channel=<channelName>, msg=Sample Message)

to part from a channel:

# specify the path of the Twitch Component
twitchCOMP = op('twitch')

to access the Twitch API v5, the header is now optional:

# specify the path of the Twitch Component
twitchCOMP = op('twitch')
url = ''

Bug fixes:

  • the webCOMP inside the Twitch component would not connect automatically on restart.

This is really cool! I’m very interested in getting this working.

I’m running into trouble getting the OAuth callback URL to work. I’ve created a webpage on a domain I own using your HTML code but when I click on the link the page just goes white.
I’ve changed the URL and client ID to my own in the code. Curious if you had any insight as to what I might be doing wrong??

Also, I think the URL in your WebCOMP needs to be changed to

According to the Twitch wiki “The domain dedicated to Twitch authentication is domain for Twitch authentication will continue to work until the end of 2018, when we remove Twitch API v5 functionality”


thanks for the note about the changed URL. I’ll upload a new version in a bit.
Regarding the website on your server - I just had to make sure that the oAuth redirect URL and the link in it matched exactly what was specified in my application at
Especially important is the whole www part…

The content of my index.html is:

<a href=>Click me for access</a>

I ran into an issue initially but it was all because of a typo… Took me a while to figure that out…


I was able to get redirected back to my callback page with the access token, I put the access token and client id into the component parameters, but pulsing ‘Get Channel Info’ doesn’t seem to do anything. Any tips on what to look at to diagnose?