Streams API returning incorrect results


is it a known bug or undocumented ‘feature’ that /kraken/streams?limit=2&channel=channel1,channel2 returns a) more than 2 results b) not the results I asked for?

I ask this in the context of wanting to query whether a specific list of channels is online or not. Is there another way to do this? It seems cumbersome to then have to filter the result set.

Thank you

Sounds like a bug. Specifying limit when the max is the list of channels you specify is redundant though.

I can’t reproduce this at all. What’s the exact request? I’ve tried with both streams offline, both online, one offline/one online, and accounts that don’t exist just to make sure.

Agree with @3ventic that it is redundant to have a limit, but I used it to test repro.

Thank you 3ventic and DallasNChains for the reply, greatly appreciated.

The exact request url is:,nl_kripp

I am using PHP / curl, cache-control: no-cache, as well as CURLOPT_FRESH_CONNECT if it makes any difference.

Thank you

That request works for me in the offline scenario. I’ll have to try when one or the other is online. I’m assuming you’re passing in a Client-ID and getting a full response, right? And this happens with every request?

As an aside, I wouldn’t recommend using those two configurations. The cache-control isn’t respected for performance reasons, and the load balancer likely puts you in the same data center in the new connections case. :slight_smile:

Thank you for the replies.

@DallasNChains - yes, I am specifying a Client-ID. Here is my current curl function:

function getCurl($url, $client_id) {
$ch = curl_init();

$options = [
		'Client-ID: '.$client_id,
		'Content-type: text/plain',
	CURLOPT_URL => $url

curl_setopt_array($ch, $options);

$data = curl_exec($ch);

return $data;


As an aside, if I access the url passed to this function and tack on the &client_id=… the results are correct (shows a result ONLY for the channels I specify. I’m only seeing this behaviour (returns 25 results regardless of how many channels I specify) when I access the endpoint via PHP.

To confuse things even more, if I do this all through PHP’s file_get_contents it works perfectly fine.

Thanks for any pointers.

Try removing the ‘Content-type: text/plain’ header. Our API defaults to JSON, so you might be getting back a weird result since you’re requesting plaintext.

Thanks for the reply @DallasNChains.

The presence of the content-type doesn’t make a difference, but I’ve removed it as per your recommendation. I am still getting 25 results rather than the 3 I am requesting results for. Again, this only happens with PHP’s curl_exec. If I use file_get_contents() it works as expected (max of 3 results depending on who’s online).

Can you send your URL that you’re requesting? That would help me reproduce the issue locally.

Here’s the full set up:

class Twitch {
	public static function getCurl($url) {
		$ch = curl_init();

		$options = [
			CURLOPT_HTTPHEADER => ['Client-ID: '.$client_id],
			CURLOPT_URL => $url

		curl_setopt_array($ch, $options);

		$data = curl_exec($ch);

		return $data;

 $url = ",gamesdonequick";
 $data = json_decode(Twitch::getCurl($url), true);
var_dump($data); # yields 25 results

Thank you

I don’t see your code setting Client-ID. Are you copying and pasting your exact code? If I set $client_id in getCurl, I only get a single response back. Here is the truncated var_dump showing a single response:

         ]=>string(13)"Congo's Caper"[

Pardon, I modified the code slightly when pasting. line 6 - CURLOPT_HTTPHEADER => ['Client-ID: '.$client_id],

was meant to say $GLOBALS[‘twitch_client_id’]; Clearly it’s working because I’m getting results, right? It’s set to error out if there is no client id. I’m wondering if it’s some local php.ini setting that’s blocking this?

I’m not sure if this is related to your issue exactly, but I actually had a similar problem with my PHP JSON format. It wasn’t limiting to a certain amount of results, which I wanted. It turned out it wasn’t the Twitch API, but more the json_decode variable I had set. I can’t remember exactly but I believe it was one of the “curl_setopt” functions that had caused my issue.
Here’s what I needed to get it working:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $file);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl);
$response = json_decode($content, true);

Then in my case, I simply used this to fetch the info: $response[“display_name”]
Again, I’m not sure if it’s relevant to your issue but I thought I’d post, in case it helped.

1 Like

Your code is certainly working. I copy and pasted it directly into my editor and ran it locally. I still only get one result (kripp is offline and AGDQ is online), which is expected. I can’t reproduce getting 25 back every call. Can you copy and paste a var_dump from the code above?

Thank you for all your effort @DallasNChains, @MadMikeGamerXL1’s suggestion of adding CURLOPT_HTTPGET resolved the issue! Thank you very much Mike!

I’m very glad I could help! Thanks for letting me know it worked for you too :smile:

I wonder if this is a configuration in PHP that is set on and off depending on how it was installed? I’m using MAMP, so it might default to including that option. Thanks for the help, @MadMikeGamerXL1! Good tip for other folks that may run into this. :slight_smile:

1 Like

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