API Stream Query

I’m trying to perform a call to get the response to tell if the channel is live or not.
The code so far appears as:

<script src="/script/jquery-1.11.3.min.js"></script>
<script>
console.log("Begin Script");
$.ajax(
{
	dataType: "jsonp",
	url: "https://api.twitch.tv/kraken/streams/straconischannel",
	success: function(channel)
	{
		console.log("Results:");
		console.log(channel);
	},
	error: function(){
	    console.log("The Request Failed");
	}
	
});
console.log("End Script");
</script>

The Jquery file is located in the location specified.
The result that returns is {“error”:“Bad Request”,“message”:“No client id specified”,“status”:400}

This is the same response that returns when running the Example Request from the API documentation in bash.

Client ID’s are required for almost all API calls now.

Using that information I’ve made it further, but I’m not sure what to do from here.

Try removing the “?oauth_token=” portion, so your URL should just be

https://api.twitch.tv/kraken/streams/straconischannel

OAUTH_Token is unnecessary in this case, though I’d still expect it to work since the client ID is being identified. If you still receive errors, then please list what error you are seeing.

There is still an error without the OAUTH_token, without it I still get the Bad Request for no client ID.

I tried out the jQuery AJAX example in the blog and it worked as expected for me - the only real difference I see between your code and the code example is your example does not specify:

type: “GET”,

unfortunately I am not well-versed in AJAX so my help may be limited - try adding that identifier prior to your dataType: and see if that resolves your issue.

With your assistance I got it working, I was too close to the problem to see it. It wasn’t just the missing GET command, it was the included datatype command that was causing an issue. After these two changes the code is now working. Thank you.

Glad to hear it’s now working! :slight_smile:

jsonp does not support modified headers, you should use json instead.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.