Fix ideas for Streams pagination
Pagination on some Helix endpoints, such as Get Streams, is just bad, and can lead to endless looping. So here are some suggestions.
The goal of any solution would be for any dev paging through any Helix endpoint to have a clear and reliable indication of "there are no more results, you can stop pagination". And if for whatever reason that can't be indicated, the endpoint should safely return an empty data array rather than looping the user back to the start.
Currently, the final page of the Streams endpoint still contains a cursor (for use in before) so simply relying on the lack of a cursor can't work.
One solution may be for Twitch to validate the cursor on their end, so for example if that final cursor is used as the after value, rather than returning to page 1 (like what would happen with any request lacking or having a bad after value) there could be a check and if that cursor isn't appropriate for paging forwards then there could be a response with just an empty data array, and a cursor that allows paging backwards still with before but the same after object in the cursor so any repeated use will just return to the same final/empty page rather than the start.
Another suggestions that has come up would be for the inclusion of an additional pagination value in addition to the already existing cursor that the endpoint returns that can be a simple flag to indicate if there are more results (this could also be used to indicate if you're on Page 1, so unable to use the before param).
A final suggestion would be is if it's possible to encode metadata related to the pagination state in the cursor, so Base64 decoding it could give a dev details such as if they're on the final page, their current page, etc... I don't think this would be the most user friendly option though, as ideally devs shouldn't need to touch with the Decoding of a cursor.
All of these ideas should be non-breaking, as they don't change has cursors function, from the dev side of things and I think the first option, of the final cursor returning a page with an empty data array could be best as this could stop any endless loops in existing implementations, where as additional flags wouldn't help until the dev integrates that into their apps.