Hello! I wanted to get the title of my stream for my chatbot but I don’t know how can I get this. Can you give me an example of code line to get the title of my stream please? (Sorry if my english isn’t very well)
What language?
- Generate any kind of token, since it’s a chat bot you could use the token the chat bot uses to login to chat with
- Call Get Channel Information which provides the streams title (and game)
I coded my bot in Javascript
I didn’t understand how API works…
A HTTP API is you make a cURL request to a URL and data comes back.
And with the Chat API (technically its an API) you make a socket connection then you can send/recieve chat messages.
So you’d need a cURL library (for language of choice), since JS, if in the browser you’d use fetch since it’s built in.
Since a chat bot you could use node-fetch as it works the same way
An incomplete javascript snippet that works for browser and nodeJS:
for node your’ also need to invoke/require node-fetch
fetch(
'https://api.twitch.tv/helix/channels?broadcaster_id=123123',
{
"headers": {
"Client-ID": client_id,
"Authorization": "Bearer " + access_token
}
}
)
.then(resp => resp.json())
.then(resp => {
// do stuff with resp as it will match whats in the example response linked above
Thank you very much!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.