/helix/clips pagination cursor loops endlessly


#1

Endpoint https://api.twitch.tv/helix/clips will return pagination cursors that loop infinitely as the last pagination cursor returns the first pagination cursor.

Initial request:

curl -H 'Client-ID: <clientId>' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id=129117300&first=100'

Response:

{"data":[...],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1UQXcifX0"}}

Request with last pagination cursor in chain:

curl -H 'Client-ID: <clientId>' -X GET 'https://api.twitch.tv/helix/clips?broadcaster_id=129117300&first=100&after=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6IiJ9fQ'

Response:

{"data":[...],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1UQXcifX0"}}

The pagination cursor in the final request returns the same pagination cursor in the first request which causes pagination to loop endlessly as there is no halting condition.

In previous times when I ran my script I believe the last pagination cursor was set to the string “null” which provided a way to halt the script.

Please confirm if this is a bug or if there is a different way to determine the halting condition.

Many thanks.


#2

You could try and compare the data received against the limit.
As soon as the data array length is less you could programmatically stop it.
AFAIK if the last page contains the same amount as the limit provided it shoul return the next page as an empty page, I have yet to have tested this though. Can be easily done by setting the limit to 1


#3

It looks like it was a bug. I checked it again yesterday and it was correctly returning null as a halting condition.