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

Implementing Link Header Pagination #29

Open
rlrezende opened this issue Oct 9, 2019 · 0 comments
Open

Implementing Link Header Pagination #29

rlrezende opened this issue Oct 9, 2019 · 0 comments

Comments

@rlrezende
Copy link
Contributor

In the past few years, more and more APIs have begun to follow the RFC5988 convention of using the Link header to provide URLs for the next page.

An API that uses the Link header can return a set of ready-made links so the API consumer doesn't have to construct links themselves. This is especially important when pagination is cursor based. Here is an example of a Link header used properly, grabbed from GitHub's documentation:

Link: https://api.github.com/user/repos?page=3&per_page=100; rel="next",
https://api.github.com/user/repos?page=50&per_page=100; rel="last"

next - shows the URL of the immediate next page of results.
last - shows the URL of the last page of results.
first - shows the URL of the first page of results.
prev - shows the URL of the immediate previous page of results.

The response includes also additional information about pagination like total entries and total pages.

Example headers:

X-Total-Entries: 60
X-Total-Pages: 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant