When a viewer is redeeming a custom channel point reward, I would like to get the information of “Who redeemed which CP Reward?”. It seems to be that I get this info from the Channel Points Custom Reward Redemption Add Notification. But I am already having troubles with getting connected to the twitch API. I am working with nodeJS and for example when I try to connect with the streamlabs API, all I need to do is:
~ register app on streamlabs
~ take the Socket API Token and create a windows environment variable
~ install socket.io-client
~ and then just write this 3 lines:
After those steps, I can get information from things like Test Subs. But this easy way is not mentioned in the streamlabs dev docs. And looking into the twitch dev docs makes it again more complicated than easy (I could rant SO MUCH about how user/beginner unfriendly these docs are written, but that would be too much text and not help here ).
So I have this feeling there MUST be also an almost equal simple way to connect to the twitch API like with the streamlabs API. But how?
Steps I have already taken is to register an app on twitch, so I already have a Client ID and a Client Secret. And as mentioned above, nodeJS and socket.io-client are installed.
You need a server (such as running express for example, since we are talking node).
That is capable of recieving HTTP post requests
Ok, express is installed now.
A more channel points specific event sub example
So this is what I have to use to test the finished code for channel points rewards?
What specifically is complicated in the docs?
Well the first thing is, that the code examples are just written in one langage, which seems to be called cURL. As soon as a reader doesn’t know this language (like me), it gets confusing. Streamlabs has a refernce website with 5 different languages. That does not mean, that a js-idiot like me immediatly understands it, but atleast the chances are higher that I can find it out by looking at my language and also the others. E.g. when I looked into the twitch dev docs for my problem, first I looked into Twitch API. But the first code that I see there is this:
The second thing is, that the docs don’t give enough information. So for example: As mentioned at the start post, I would like to connect to the twitch API and get the CP reward infos. You are so nice and help me by saying “Better you look into PubSub”. So I look into PubSub and the info it gives me is “A PubSub is [explaination].” and “The content of a PubSub is [list of content]”. But there is no “And THIS is how you get the content.”. All I see is “Something, something wss://pubsub-edge.twitch.tv, ping, pong, listen, reconnect” and “Not that important, but good to know”-info like the API Limits. And this way of giving information basicly goes through the whole dev docs. There are no examples of "Here is the summarizing example code for this topic. In chase you want to copy-paste it, there are [EXAMPLE] fields. E.g. one info you need is your Client ID. So look for [EXAMPLE Client ID], delete it including the , and write you Client ID."
So all in all the dev docs are written in a way, that feels like you have to be the programmer who programmed all of twitch and with that understand 100% of EVERY single word in it. I mean, of course this site is made for people who know what it is about. And I am just a stupid beginner. But how much it is just assuming that you should know and also remember is really user unfriendly. Just look at my short explaination of how I connect to streamlabs: 4 steps and just 3 lines of code. That’s all. Why is it so hard to put such examples into the twitch dev docs? The dev docs just makes me feel dumb by reading it, annoyed by being forced to ask for help again, and angry that I have to waste somebody else time by answering my stupid question.
Ok, enough of this little rant. Sorry for the text block, it’s just all so exhausting with how hard it is, especially when it could be way easier.
It’s late here now and I go to bed. See you tomorrow. Good night and thanks for helping me (or more like “trying to help” because I am an idiot).
the URL to call https://api.twitch.tv/helix/search/channels?query=a_seagull
you need two headers, a client-ID header and and Authorization
(--location --request and superflous, and some of the newer docs, the doc writer has been using the “longer” form of the cURL flags/arguments)
This is then translatable into any langauge, Streamlabs does 5, well what about the others, such as PHP or brainfuck or lua for example?
Aside from being opinated on the languages, SL also is opnatiated on the libraries to use, like nodeJS they suggest you use node-fetch
Which means you learn to use node-fetch instead. As then we’ll get questions like “I’m trying to do this in axios/got/other module/no module at all”. So cURL is given as a cURL call can be translated to match whatever language you are working in and whatever module/library you are working with.
Which is why cURL is the first example in the Streamlabs docs, as cURL is universal
Given that all of Twitch’s offerings (except kraken) requires an oAuth token to do anything, you can’t just copy paste without getting a token first, so you can’t really do “simple” copy/pasta examples
cURL is “standard” and language agnostic.
Most lanaguaages generally just implement cURL under the hood and provide helper libraries to convert to cURL. So the Twitch docs are unopinated on langauge.
Not really thats, “heres how to use nodeJS library of socket IO to connect” it’s an “opinated” piece of documetnation that says “you should be using nodeJS”.
It’s four steps of “heres socket.io just use that”, (granted they are using a socket.io server). So the ways to connect to socket.io are limited, to the langauges that socket.io has been ported to. Twitch uses websockets (which socket.io uses underneath), and websockets can be made to work much more easily in any langauge, and thus the docs don’t give an opinion on language or modules to use.
Twitch’s docs tell you the endpoints you can call and the responses to those endpoints, so it doesn’t say use socket.io as thats an opinion on what you should use, as apposed to “heres the calls, use what you are used to using”
The only stupid question is the one you don’t ask.
Of course this is all irrelevant if instead of reading the docs, you use someone elses Twitch library (for nodeJS if you stay in node), as then you follow their docs for their library instead.
Feel free to use any module that can recieve HTTP Posts requests, I use express myself, so use what you are comfortable with, and you don’t have to use NodeJS.
For channel points first you need an access token (with the relevant scopes attached) to a channel that has channel points enabled, which is affiliate+
So I have an access token now, but:
1.1 My channel has NOT channel points enabled. Can I still make tests?
1.2 If yes, I should use your twitch misc aboutchannel points then?
2.1 The PubSub says, I need a constant connection to the topic with LISTEN, PING and wss://pubsub-edge.twitch.tv. Do I have to do that with this?
2.2 If yes, how would it look like combined with twitch? Something like this?