The example
The JSON above is the example. Explore it in the Tree tab, press Download to save it as a .json file, or Share to send someone a link to it. All names, ids, emails and values are invented.
Fields explained
| Path | Type | Notes |
|---|---|---|
data | array of objects | The items of the current page. |
meta.page / perPage | number | Where you are and how big a page is. |
meta.total / totalPages | number | How many items and pages exist in total. |
links.next / prev | string or null | Ready-made URLs. On the last page, next is usually null or missing. |
Read it in code
JavaScript:
let url = firstUrl;
const all = [];
while (url) {
const page = await (await fetch(url)).json();
all.push(...page.data);
url = page.links.next ?? null;
}Python:
url, items = first_url, []
while url:
page = requests.get(url).json()
items += page["data"]
url = page["links"].get("next")What this example is good for
- Testing a client that follows next links until none is left
- Mocking list endpoints
- Learning the envelope pattern used by many APIs
Tips
- Page numbers are simple but can skip or repeat items when data changes between requests. Cursor-based pagination (a next token instead of page numbers) avoids that.
- Always stop when there is no next link instead of trusting totalPages.
Convert this example
Open it in a converter, then switch the output in the Code tab:
- JSON to TypeScript
- JSON to Zod
- JSON to Python (Pydantic)
- JSON to Go
- JSON to JSON Schema
- JSON to CSV
- JSON to YAML
- JSON to XML