Loading stream information json into Glitch Twitchbot

Recently started working on the Twitch Chatbot and have the bot doing very basic commands but as soon as I attempt to request stream information I get a bit lost. When I do an online Curl Request I can get all the json data no problem. However when I try to fetch in the Glitch bot.js I just get

error: ‘Bad Request’,
status: 400,
message: ‘No client id specified’

Any ideas?

I also tried to migrate to the new helix API but I cant seem to figure out the new https.

For helix you need to include a oAuth header and a ClientID.

That error suggests you omitted the clientID and probably that oAuth token.

So you need to show your code so we can help

and read

That error was from the kraken api because I’ve been a bit unsure about the format of the helix.
Here is the fetch I was using on the kraken api.


if thats_all_ you specified, then you have not incldued any headers with your request

    headers: {
        'Client-ID': YOURCLIENT,
        'Accept': 'application/vnd.twitchtv.v5+json'

Thankyou Barry this helped alot and got it all working for me but I’m starting to realize I should probably make the switch to the new Helix api. Any idea how to translate the fetch over to helix? I assume it will return a similar json.

    ‘https://api.twitch.tv/helix/streams?user_id=’ + id,
    headers: {
        'Client-ID': YOURCLIENT,
        'Authorization': 'Bearer ' + YOURTOKEN

That’s currently only returning

[object Object]

Assuming the ‘YOURTOKEN’ is my OAUTH_TOKEN I’m not sure what I did wrong.

The response needs to be JSON parsed. Before it can be used. Depending on the rest of your code

So it returns data in a different format than kraken api does?

Here’s what I’m working with.

function fetchChatter()
fetch('https://api.twitch.tv/helix/streams?user_id=' + chatterUID, {
headers: {
    'Client-ID': process.env.Client_ID,
    'Authorization': 'Bearer ' + process.env.OAUTH_TOKEN
        //return resp.json();

Yes, it’s still JSON just formatted different

So any idea why it’s just returning

 {object Object}

your code example seems incomplete above.

If you are getting an object that suggests that you didn’t json decode

I’m not completely sure what you mean by json decode sorry.

Your call to resp.json() is one method of calling a json decode. It’s a javascript/API basic since the data is returned as a string and has to be parsed for use, it’s a bit of a fundamental

You probably need to do

        return resp.json();

To solve the issue you are having.

I’m not sure what the issue is as all you are doing is logging the output not parsing/using it at all.

Here is the current code if you have a chance to take a look.
The issue I’m currently having is transitioning from kraken to helix. The helix fetch is just returning an empty object.

That would suggest the stream you are looking up is not live, hence the empty object

I thought this could be used to check a user’s stats inreguards to the stream such as when they followed.

That is the stream endpoint it returns information about that user_id’s stream if the stream is live.

Otherwise it doesn’t return anything as there is no live stream to return the details of

Just went live to test and I still received the same result.
Also tested with
fetch(‘https://api.twitch.tv/helix/users/follows?to_id=’ + chatterUID, {