Inconsistent results from API?

I am running the following code:

$client->get('https://api.twitch.tv/helix/streams', [
	'headers' => [
		'Authorization' => 'Bearer '.$token,
		'Client-ID' => $client_id,
	],
	'query' => [
		'game_id' => ["10872","10970","11406","16951","18902","23579","27098","29448","30639","313204","31568","458126","460167","461067","476449","488615","490500","490698","490709","494544","494995","496464","497385","497877","500626","502447","510578","510799","5218","5645","9041"],
		'language' => [],
		'type' => 'live',
		'first' => 100,
		'after' => '',
	],
]);

It fetches for a list of live streams playing the specific list of games. There are literally thousands of streams which fit these parameters; but it limits to the top 100. So what it should do, is return the first 100, then give me a “pagination cursor”, so I can get the next group of 100 by putting that cursor value into the after field. I loop through this 5 times, to get the top 500 streams that match these parameters.

Sometimes I will get proper results. However, more often than not, I will not get proper results. Instead of getting the first 100… I will instead get around 40-60 results, and it will return a VERY SPECIFIC cursor value:

eyJiIjp7IkN1cnNvciI6ImV5SnpJam95TVRjeExqazBNak0xTVRneU5EVTVNRE1zSW1RaU9tWmhiSE5sTENKMElqcDBjblZsZlE9PSJ9LCJhIjp7IkN1cnNvciI6IiJ9fQ

This cursor always returns an empty list as the second page. So instead of getting the top 500 results, I only get 40-60.

I’m noticing similar behaviour as of roughly 6pm UTC yesterday (07/29). Results seem extremely inconsistent via this cursor right now.
Here’s results of tracking new streams over the last 24 hours. Things are fairly consistent, then start climbing gradually before dropping into inconsistency.

Or slightly more dramatic visuals, every stream detected (not just new) in the same time frame

After a few days of watching this, it looks like it happens EVERY NIGHT, consistently. At around 8pm EST, it starts happening, and persists for a few hours.

I’ve determined that the pagination cursor of:

eyJiIjp7IkN1cnNvciI6ImV5SnpJam95TVRjeExqazBNak0xTVRneU5EVTVNRE1zSW1RaU9tWmhiSE5sTENKMElqcDBjblZsZlE9PSJ9LCJhIjp7IkN1cnNvciI6IiJ9fQ

Specifically means there are no more pages. But as I said, there should be over 500 streams right now that fit my parameters. I can keep on re-running the script, and eventually I will get proper results… but I shouldn’t have to do this.

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