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

(API) Missing "Link" header for pagination #1748

Closed
tateisu opened this issue Oct 1, 2019 · 4 comments
Closed

(API) Missing "Link" header for pagination #1748

tateisu opened this issue Oct 1, 2019 · 4 comments
Labels
🔃 API For accessing Pixelfed data

Comments

@tateisu
Copy link

tateisu commented Oct 1, 2019

The description of many API has "Pagination" section like as:

https://docs.joinmastodon.org/api/rest/timelines/#pagination-1

This API returns Link headers containing links to the next and previous page. However, the links can also be constructed dynamically using query params and id values.

https://docs.joinmastodon.org/api/rest/favourites/#pagination

This API returns Link headers containing links to the next and previous page. Since it is using an internal ID, it is not possible to dynamically generate query parameters to paginate. You must rely on the Link header.

Especially in case of some API, we can't know pagenation key from data array. For example, /api/v1/favourites returns user's favourites order by "favourite id" (nearly equals to favourited time order, but ID is unique.) , but its "favourite id" is not exposed in ID in data array.

Even in other cases, the boundary indicated by the Link header may be outside of the data array. They occur when items are excluded from the DB query result by filtering.

The client app should always paginate based on the Link header, not from the data array.

For more Information about Link header, there is RFC standard https://tools.ietf.org/html/rfc5988
that referenced in Mastodon's old document https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#notes .

For most GET operations that return arrays, the query parameters max_id and since_id can be used to specify the range of IDs to return. API methods that return collections of items can return a Link header containing URLs for the next and prev pages. See the "Link header RFC" for more information.

@tateisu tateisu changed the title (API) timelines does not return "Link" header. (API) Missing "Link" header for Pagination Oct 1, 2019
@tateisu tateisu changed the title (API) Missing "Link" header for Pagination (API) Missing "Link" header for pagination Oct 1, 2019
@tateisu
Copy link
Author

tateisu commented Oct 1, 2019

If the Link header missing "next" or "prev" relation, it means "end of list".
for example. reading home timeline.
Its Link header may not has "next" relation because timeline always have old end.
But Link header always has "prev" relation because timeline may have newer posts when next request.

@trwnh trwnh added the 🔃 API For accessing Pixelfed data label Oct 1, 2019
@dansup
Copy link
Member

dansup commented Oct 2, 2019

@tateisu Added in 8752d21

@dansup dansup closed this as completed Oct 2, 2019
@tateisu
Copy link
Author

tateisu commented Oct 2, 2019

oh, this implement does not indicate the id of read range.

@dansup dansup reopened this Oct 4, 2019
@trwnh trwnh added this to the 0.10.0 - Collections Update milestone Jan 26, 2020
@dansup
Copy link
Member

dansup commented Jul 14, 2021

This has been fixed!

@dansup dansup closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔃 API For accessing Pixelfed data
Projects
None yet
Development

No branches or pull requests

3 participants