How can a client follow pagination links in an API response?
Quick answer
Check the API documentation for where pagination links appear. If the response includes a documented next link—such as a Link header relation marked rel="next" or a JSON field—request the returned link as the API instructs, then check the new response the same way. Stop when the documented instructions indicate there are no more pages. Don’t guess parameter names; pagination formats vary by API. [S1] [S2]
The question, the details, the next step.
A practical checklist
Find the API’s documented pagination format and where the next link appears.
Inspect the response for the documented link or relation.
Use the returned link according to the API’s instructions; don’t guess parameter names.
Check each new response for the next link in the documented location.
Follow the documentation on when to stop or what to do if the format is unclear.
A few more useful answers
Does every paginated API use a Link header?
No. A Link header with rel="next" is one possible format. An API may document a JSON field or another scheme, so check the documentation for the API you are calling. [S1]
Can I assume a field named `nextLink` uses `$after`?
No. The documented nextLink and $after pattern applies to Microsoft Data API builder’s described pagination scheme, not APIs generally. Follow the instructions for the API you are calling. [S2]
What does the absence of a next link prove?
By itself, it does not establish why the link is absent. Check the API’s documentation for what that response means and whether another page should be requested.
Sources
References used for this guide.
- [S1] Link header — MDN Web Docs developer.mozilla.org · Checked
- [S2] How to call REST endpoints — Data API builder learn.microsoft.com · Checked
