First of all, how come my link for going to their page isn’t working for going to their channel? (line 29, 35, 64, 67) data2._links.self was what i used and i get: {"error":"Bad Request","status":400,"message":"No client id specified"}
Is their anyway i can make it so when i search, for example, C, it searches for all the channels that start with C, not just any channels that their complete name is C. Also not case sensitive
If no results are found, how do i change that h3 text based uon that? I’m having a issue with testing that their is no results. This is what i tried (doesn’t work, line 58):
if (data == undefined) {
document.getElementById("ThatRandomText").html("No results found...")
}
I mean like if I type C, it searches all of twitch for streamers that start with C and c. Currently it searches all of twitch, but needs to be exactly their name. StarWarsHQ works, but starWarsHQ doesn’t. I didnt see anything about twitch auto-complete. Is their anyway to access their servers/ data base?
Hi,
The Twitch api has changed a few times over the past year.
404 or 400 status codes means that it is not found or doesn’t exist. You will see these for the “Closed Accounts” users.
Here is the current api that I know works at the moment: //Main ajax function that request for streams/user.
$.ajax({
url: ‘https://api.twitch.tv/kraken/streams/’ + user
, dataType: “json”
, headers: {
‘Client-ID’: ‘PLACE you CLIENT ID here’
}
//Check Account Closed
, statusCode: {
404: function (xhr)
{
//if user offline this secondary Ajax function is used for channels/user.
$.ajax({
url: ‘https://api.twitch.tv/kraken/channels/’ + user
, dataType: “json”
, headers: {
‘Client-ID’: ‘PLACE you CLIENT ID here’
I am able to get their status of offline or online. I basically have a working api. My only issues, as i said before was going to their webpage. They JSON provides a link, which i used.
These links should work.?? If they don’t i’m petty annoyed on how they just change a api and screw us over like this. If it says robotcaleb in the url, go to robotcaleb profile. I’m not hacking the pentagon, no need to give me a error.
kraken/streams + streamers should give you those who are online
kraken/channels + streamers should give you those who are offline.
These are online: “ESL_SC2” and “OgamingSC2”.
These are not found and should be in the Account Closed list: “brunofin”, "comster404"
The others are currently offline, including freeCodeCamp
The only other thing I can see is that you need a Twitch Client ID. It should be shown in each api call and in its header. Both places.
To get the Account Closed you need to check the status :
after headers ClientID:
}
//Check Account Closed
, statusCode: {
400: function (xhr)
{
console.log(user + " has no account");
You need to do the same thing that you did for the online streamers but check the channels of the missing streamers:
kraken/channels + streamers
Okay this is my code. It was working before for the online streamers, but only because it had no client ID since i forgot a period between data2 and _ID.
Now i still want to push the users on the page who are offline. I am already currently doing this, but as i said before, the link isn’t working.
Okay now both my offline and online streamers pop up. Only online streamers links work. I wanted the offline to link the profile, and online link to their stream(which it does link to stream)
I’m still getting the {"error":"Bad Request","status":400,"message":"No client id specified"} only for offline streamers.
This is how i pasted your code
$.ajax({
url: "https://api.twitch.tv/kraken/channels/" + streamers[i],
dataType: "json",
headers: {
'Client-ID': 'PLACE you CLIENT ID here'
}
});
The only thing i need at this point is a Key, because offline streamers don’t link to their profile. I tried many things at this point. I shouldn’t need all this stuff just to put in a freakin link. Like really??? I’m starting to think this is a ego thing.
if streamer is offline so twitch will return null means he/she offline. you could go to the channel page in their api to get another information like logo img…etc