Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With v5 offset changes, setting an offset greater than 0 makes the API response lack one item #67

Closed
jbulava opened this issue Feb 23, 2020 · 3 comments
Labels
product: v5 API endpoints in the "v5" namespace ticketed Has been given an internal tracking ticket

Comments

@jbulava
Copy link
Member

jbulava commented Feb 23, 2020

The following report is a copy/paste from this forum post comment: https://discuss.dev.twitch.tv/t/upcoming-changes-to-the-streams-v5-endpoints/23926/10. I am unable to replicate this issue (receiving limits as expected). Including in cause the API team can replicated or confirm this is no longer an issue.

Whatever the reasons for these changes were, you also introduced a bug related to the offset and limit parameters. See this:

offset=0, limit=12

$ curl -s \
  -H "Accept: application/vnd.twitchtv.v5+json" \
  -H "Client-ID: YOUR_CLIENT_ID" \
  "https://api.twitch.tv/kraken/streams?offset=0&limit=12" \
  | jq "[.streams[]] | length"
12

offset=12, limit=12

$ curl -s \
  -H "Accept: application/vnd.twitchtv.v5+json" \
  -H "Client-ID: YOUR_CLIENT_ID" \
  "https://api.twitch.tv/kraken/streams?offset=12&limit=12" \
  | jq "[.streams[]] | length"
11

As you can see, setting an offset greater than 0 makes the API response lack one item.

This API bug is currently breaking my application, because its infinite scroll mechanism has a fallback for when the _total metadata is/was missing (as it was inconsistent before), and it expects the number of results of the API response to be equal to the requested limit. If fewer records are returned than requested, it treats this as the end of the available records.

I know that this could be implemented differently and another query could be made and then checked if there are no records in the response, but that’s one additional and unnecessary API request, especially considering API rate-limiting on helix once I made the switch. The API bug is also annoying, because my infinite scroll implementation has a calculation for how many records are needed in order to fill the route’s page with just one query, and having one item missing from the API response breaks this as well.

Could you please take a look at this bug? Other endpoints than /streams are also affected by this, eg /games/top (offset=12, limit=12).

@jbulava jbulava added the product: v5 API endpoints in the "v5" namespace label Feb 23, 2020
@bastimeyer
Copy link

It's been working earlier today, but now it's broken again, even if no offset is set. All queries return limit-1 results.

@jbulava
Copy link
Member Author

jbulava commented Mar 6, 2020

This has been ticketed internally as VXL-823.

@jbulava jbulava added the ticketed Has been given an internal tracking ticket label Mar 6, 2020
@jbulava
Copy link
Member Author

jbulava commented May 28, 2020

This should be resolved in production as of March 30. Please let us know if you are still seeing any issues with offset though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: v5 API endpoints in the "v5" namespace ticketed Has been given an internal tracking ticket
Projects
None yet
Development

No branches or pull requests

2 participants