-
Notifications
You must be signed in to change notification settings - Fork 426
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
Add explicit link to next page of results in search API #7841
Comments
+1 to the I've also seen that more often. |
The Confluence API is similar to https://stateless.co/hal_specification.html (see also https://datatracker.ietf.org/doc/html/draft-kelly-json-hal-08), but slightly different, as link values are just strings, as opposed to objects in the HAL spec. |
Some more resources: Blog post about different ways of embedding links in APIs: https://evertpot.com/json-links/ |
There is currently an issue in h where the search API call may sometimes return pages that are incomplete, even if there are more pages of results to fetch afterwards [1]. A non-full page caused the client to stop fetching more pages as it incorrectly assumed it had reached the end. Ultimately this needs to be resolved in the API [2] by adding an explicit next-page link. Until that is done, change the client to continue paging through results as long as the current page has at least one entry (needed to construct the cursor) and we expect more results based on the `total` value in the response. Fixes #5219 [1] hypothesis/h#7840 [2] hypothesis/h#7841
There is currently an issue in h where the search API call may sometimes return pages that are incomplete, even if there are more pages of results to fetch afterwards [1]. A non-full page caused the client to stop fetching more pages as it incorrectly assumed it had reached the end. Ultimately this needs to be resolved in the API [2] by adding an explicit next-page link. Until that is done, change the client to continue paging through results as long as the current page has at least one entry (needed to construct the cursor) and we expect more results based on the `total` value in the response. Fixes #5219 [1] hypothesis/h#7840 [2] hypothesis/h#7841
There is currently an issue in h where the search API call may sometimes return pages that are incomplete, even if there are more pages of results to fetch afterwards [1]. A non-full page caused the client to stop fetching more pages as it incorrectly assumed it had reached the end. Ultimately this needs to be resolved in the API [2] by adding an explicit next-page link. Until that is done, change the client to continue paging through results as long as the current page has at least one entry (needed to construct the cursor) and we expect more results based on the `total` value in the response. Fixes #5219 [1] hypothesis/h#7840 [2] hypothesis/h#7841
There's also a possible use of the HTTP From Range header, I choose you (for pagination)! :
GET /users
200 OK
Accept-Ranges: users
Content-Range: users 0-9/200
[ 0, …, 9 ]
GET /users
Range: users=1000-
416 Requested Range Not Satisfiable
GET /users
Range: users=-5
206 Partial Content
Accept-Ranges: users
Content-Range: users 195-199/200
[ 195, …, 199 ] Pity there's no standard JS API for parsing |
It does not fit the requirements, indeed. I was a bit too happy to get all informations using a (I'm querying the API to get the total count of annotations per URI using |
It'd be interesting to include the first and last annotations of the whole result. With pagination, to be able to display next and previous buttons, for a query I'm also fetching the first ( |
The search API supports cursor-based pagination using the
search_after
parameter. The responses do not include an explicit link to the next page of results, so API clients have to figure out how to construct that themselves, and also how to tell when they have reached the end of the results. This has caused some problems:search_after
because they did not construct the next-page link correctly, or got confused by the fact that "after" refers to the order of entries in the results, and not necessarily "after" in a chronological sense. Providing an explicit link would avoid the need for manual construction for the most common use case, and also provide a live example of how the parameter is used.What I would suggest we do is add an explicit "next page" link to the results, which is omitted for the last page. Some examples in other APIs:
_links
object in JSON response)Of the approaches above, I think I would favor a field in the JSON response, as being easier to discover and to parse.
The text was updated successfully, but these errors were encountered: