[Resolved] Twitch.tv api's challenge (getting json)

[Resolved] Twitch.tv api's challenge (getting json)


Hi everyone,

I don’t understand how to access to JSON on twitch API.

I would like to know if I’ve well understood freecodecamp’s basic solution. Do I have to create a variable and copy/paste this JSON ?

If I do this, it implies that informations will be fake and not reloaded.

Thanks for your help. here is my twitch project



If you’d prefer not to copy the example JSON you can still make an API call which returns a current JSON response with the live information.

This was tricky for me to figure out how to access since the API documentation on twitch is switching over to a new version and we’re being asked to use an external site to mine the older version of the API. To access the user list JSON you want to use these two URLs:

https://wind-bow.glitch.me/twitch-api/users/{username you’re trying to look up here}

and to check for the streams use this one:

https://wind-bow.glitch.me/twitch-api/streams/{username you’re trying to look up here}

If you’re unsure of how to make basic API calls and retrieve JSON data there’s plenty of information about how to do that on the web. There’s a great section at the end of Code Academy’s beginner JS course that really cleared it up for me. You can use jQuery’s $.ajax (probably the easiest way for a beginner) or regular old JavaScript with the XMLHttpRequest object. One problem you might run into is that your calls will be asynchronous (returning once the request has finished) so whenever the data comes back you won’t be able to do anything with the data unless you explicitly instruct it to do so inside the request/response itself. The first thought is that maybe you should make them synchronous (which there is an option for in the XMLHttpRequest object) but this is NOT recommended since it will cause your page to hang while the data is loading. There are ways around this such as using .fetch and .then, Promises, or asnyc await functions.


thank you very much for your clear, complete and explicit answer. I thought I had missed something in the explanations and had read that there were problems with the twitch API. Only I found it stupid to build a code to give something instantaneous with false information. I think I’ll do it again and I’ll try to get it with $ get.JSON () or ajax request.

Thank you again marcaaron :wink:


Thanks for your answer mubaidr, I had already read this but not fully understood.


I have the same problem with trying to figure out the request URL for the GET request.
for example when i send the following request :

$.getJSON('https://wind-bow.gomix.me/twitch-api/users/freecodecamp', function(json){console.log(json)});

I receive the following error:

Failed to load https://wind-bow.gomix.me/twitch-api/users/freecodecamp: Redirect from ‘https://wind-bow.gomix.me/twitch-api/users/freecodecamp’ to ‘https://wind-bow.glitch.me/twitch-api/users/freecodecamp’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access.

Is the FCC request URL still valid to date, march 2018?


I’m having the same error! Any updates on this?