Hi! I am having trouble understanding how to use the urls that make up the twitch api. Say I want to get the json data from https://api.twitch.tv/helix/streams/ (My end goal is to make a !isLive command in discord.js but if this works that shouldn’t be hard). I was playing around with node-fetch but I am kind of stuck. Here is what I have so far:
const fetch = require('node-fetch')
fetch('https://api.twitch.tv/helix/streams/', {
method: 'GET',
headers: {
//not sure what goes here, i have tried multiple things
}
})
.then(res => res.json())
.then(res => {
console.log(res) // I keep getting "OAuth token is missing"
});
Say my OAuth token is oauth:thisismytokenyoucannothaveit (the one you get from https://twitchapps.com/tmi) and my Client ID is thisismyclientidyoucannothaveit (The one you get from making an app on https://dev.twitch.tv/console/). How would I incorporate these into headers: {} (or wherever) so I get the desired result? Also is this the right URL to get stream information?
Since you have used twitchapps token generator, you’ll need their clientID and theToken should have oauth: removed from the start.
You also need to update the URL to include the username or ID or the channel you wish to lookup, otherwise right now you’ll just get the first/top 20 streams on the platform.
You cannot use, your clientID and a token generated from someone elses tool.
Ideally you should generate and use your own token.
Hmm… I made a fresh app and got the client id from there, then got a fresh token, and I get something other than “OAuth token is missing” (yay!). However I still get “ClientID and OAuth token do not match”. Any ideas?
Also what should I add to the url to specify one channel? My username is komali09
I’m sorry if these are obvious answers but I have no clue
Sorry, but I don’t understand… am I supposed to do something with the OAuth token when making the application? I don’t see a spot except for “OAuth Redirect URLs” and I thought that was supposed to be https://localhost:xxxx or whatever website we are using (I’m using localhost)
Ok I am still confused
I was using the string found under “Client ID” in the application menu (“Client Secret” is under that)
Also where do I put the POST command? It doesn’t work in command prompt and I’m confused where to put things like that