To allow the API Query to be able to fetch very large requests, they are automatically split into "pages" of data returned (usually up to 500 entries per page).
APIs that support pagination, accept two optional query parameters:
Parameter Name | Description | Default Value |
---|---|---|
page | Page number of the total data to return (starting from 1) | 1 |
per_page | Data entries to return per page | 500 (unless otherwise specified) |
The query will return the data in the following format:
{
"items": [],
"has_next_page": false
}
Field | Description |
---|---|
items | An array of entries returned for this query |
has_next_page | A value of true signifies there are more pages of data available, to retrieve more entries another query should be made with the page paramter increased by 1. |
Sample pseudo-code
page = 1
finished = false
while (!finished) {
returned_data = query_api("url&page={page}")
if (!returned_data.has_next_page) {
finished = true
} else {
page = page + 1
}
process_data(returned_data.items)
}
Errors
Passing invalid values to the page
or per_page
will result in 422
errors.