New Twitch API (Helix) returns null on Clip request with pagination

Hello there,

I get an empty response from the API when requesting clips information with a given “after” pagination.

Here’s exactly what happens:

  1. I make a request to the API for the channel “EXBC” with this url:

  2. I get the JSON and keep the “pagination” cursor in memory.

  3. I make another request to the API with the same url but this time with the pagination parameter:

  4. I get the JSON again and keep the new “pagination” cursor in memory.

  5. I make yet another request to the API with the new cursor:

Except this time instead of receiving JSON from the API I get an empty page. This goes without saying that it completely breaks the normal execution flow of my program and prevents me from getting more than about 180 clips from the channel, making my code completely useless as it doesn’t satisfy the job it was required to accomplish.

Why does it do that? Is your API broken? I suppose it is broken as normally I’d at least receive a JSON object saying null or error or something.

Halp plz!

Thank you in advance.

Can you show us the code you’re using to make the request? It’s working perfectly fine here and I’m getting all the results for that channel as normal.

Also, it would be helpful to know the exact response you’re getting when you say you get an empty response, what was the status code?

Last Edit: I was using “stripslashes” in my PHP code on the output returned by the API before converting it to a JSON object with “json_decode”, it seemed to work well for the first 2 requests but removing the “antislashes” in the last one prevented “json_decode” from making a correct object, thus making my code fail.

I am sorry for the trouble and thank you for your time and patience.
I didn’t need “stripslashes”, I just removed it.

Thank you very much for your help!

Hello again,

I am using PHP and I make a curl request to the API.

The response is completely blank from the server and the status code is 200.

Here is the curl_getinfo dump from the “broken” request:

string(117) “” array(2) { [0]=> string(42) “Client-ID: CENSORED” [1]=> string(29) “Content-Type:application/json” } array(26) { [“url”]=> string(117) “” [“content_type”]=> string(31) “application/json; charset=utf-8” [“http_code”]=> int(200) [“header_size”]=> int(550) [“request_size”]=> int(222) [“filetime”]=> int(-1) [“ssl_verify_result”]=> int(0) [“redirect_count”]=> int(0) [“total_time”]=> float(0.280246) [“namelookup_time”]=> float(0.004603) [“connect_time”]=> float(0.01934) [“pretransfer_time”]=> float(0.064084) [“size_upload”]=> float(0) [“size_download”]=> float(51399) [“speed_download”]=> float(183567) [“speed_upload”]=> float(0) [“download_content_length”]=> float(-1) [“upload_content_length”]=> float(-1) [“starttransfer_time”]=> float(0.265061) [“redirect_time”]=> float(0) [“redirect_url”]=> string(0) “” [“primary_ip”]=> string(13) “” [“certinfo”]=> array(0) { } [“primary_port”]=> int(443) [“local_ip”]=> string(15) “CENSORED” [“local_port”]=> int(60886) }

Edit: Again, the code works fine and the flow of execution is exactly the same as from the request I make in step #3 (from my original post), but it turns out that the last request I make (the one in #5) returns a completely blank page from the Twitch API when I give it the pagination “eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qQXcifX0”.

Note: this line: [“size_download”]=> float(51399) is what made me think that there was something wrong with my code, I was getting an empty response but the download size said otherwise, thank you Dist for pointing me in the right direction.

I’m glad you figured out what was the issue :slight_smile:

I’m not a PHP person, so I’ve no knowledge of “antislashes”, but from what I gather it removes backslash from the string. Which would explain why you had no issues with some pages of results, but as soon as you ran into a page with titles such as "title": "\"Hahahah ahaha I Did It hahahah\"", it would no longer be valid JSON if the backslashes were removed.

That’s exactly it Dist!

You’re the man!
:smiley: thank you again for the help

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