Pagination
PhantomJSON uses page-based pagination for all collection endpoints.
Query Parameters
Section titled “Query Parameters”| Parameter | Default | Min | Max | Description |
|---|---|---|---|---|
page |
1 |
1 |
— | Page number to retrieve |
limit |
20 |
1 |
100 |
Number of items per page |
Example
Section titled “Example”curl "https://api.phantomjson.app/v1/users?page=2&limit=10"Response
Section titled “Response”{ "data": [ { "id": 11, "firstName": "User11", "lastName": "Lastname11" }, { "id": 12, "firstName": "User12", "lastName": "Lastname12" } ], "meta": { "total": 100, "page": 2, "limit": 10, "totalPages": 10 }}Meta Fields
Section titled “Meta Fields”| Field | Description |
|---|---|
total |
Total number of items matching the query |
page |
Current page number |
limit |
Number of items per page |
totalPages |
Total number of pages |
Pagination Examples
Section titled “Pagination Examples”First Page
Section titled “First Page”curl "https://api.phantomjson.app/v1/users?page=1&limit=20"Large Page
Section titled “Large Page”curl "https://api.phantomjson.app/v1/posts?limit=100"Last Page
Section titled “Last Page”curl "https://api.phantomjson.app/v1/todos?page=15&limit=20"Combining with Other Parameters
Section titled “Combining with Other Parameters”Pagination works with all other query parameters:
# Paginated search resultscurl "https://api.phantomjson.app/v1/users?q=john&page=1&limit=10"
# Paginated filtered resultscurl "https://api.phantomjson.app/v1/todos?completed=true&page=2&limit=5"