We’ve been working on some changes to pagination for v2, and I wanted to send out a general warning that we’re going to be pushing out some breaking changes later this week.
Short story
We’re going to a cursor-based pagination scheme.
Long Story
Requests will look like:
https://www.wanikani.com/api/v2/assignments?page_after_id=12345678
https://www.wanikani.com/api/v2/assignments?page_before_id=12345678
The pagination section of the response will look like:
pages: {
next_url: :string_or_null,
previous_url: :string_or_null
}
Notes
- We’ll respond with an empty data set if you try and go too far forward or too far back.
- We’ll respond with nulls on the appropriate URLs if you’re at the beginning or the end of the result set.
- The value for the
page_(before/after)_id is the ID of the record that acts as the cursor.
- If you want to prep for this change, you can send those new request parameters along with the old ones — we’ll ignore the ones we don’t support when we don’t support them.
It’s far more performant when there are a ton of records and you’re further into the results, and this handles some of the weirdness of pagination when records can appear, disappear, or move around in the results.
We know there are some disadvantages to this scheme, namely that it’s hard/impossible to get the pages in parallel. We’re hoping that the performance gains from this (and ongoing work on performance) will let us bump the per page limit, reducing the number of calls necessary.
Thoughts?
Let us know what you think. It’s a reasonably common scheme, but it’s not quite as easy to process (mentally or programmatically) as ye old page numbering.