Pagination
By default, the API returns 100 items per response - if there are more than 100 items, these will be paginated.
You can, optionally, get the API to return up to 500 items per response using the limit parameter - this can be added to the request URL in the format:
https://api02.naturalhr.net/api/v1/time-off?limit=250
Should you omit the limit or enter a number greater than 500, this will default back to 100.
To aid with pagination being used, in addition to the data being returned, we also return links to the first, last, previous and next pages as well as meta data which will let you know the number of pages, total items, last page and so on.
{
"data": [
],
"links": {
"first": "https://api02.naturalhr.net/api/v1/time-off?page=1",
"last": "https://api02.naturalhr.net/api/v1/time-off?page=4",
"prev": null,
"next": "https://api02.naturalhr.net/api/v1/time-off?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 4,
"path": "https://api02.naturalhr.net/api/v1/time-off",
"per_page": 100,
"to": 100,
"total": 361
}
}
In the above example, there are 361 items returned split over 4 pages (maximum of 100 per page).
To access page 2, you simply append ?page=2 to the URL - when you do so the response would look like below:
{
"data": [
],
"links": {
"first": "https://api02.naturalhr.net/api/v1/time-off?page=1",
"last": "https://api02.naturalhr.net/api/v1/time-off?page=4",
"prev": "https://api02.naturalhr.net/api/v1/time-off?page=1",
"next": "https://api02.naturalhr.net/api/v1/time-off?page=3"
},
"meta": {
"current_page": 2,
"from": 101,
"last_page": 4,
"path": "https://api02.naturalhr.net/api/v1/time-off",
"per_page": 100,
"to": 200,
"total": 361
}
The main difference this time is that there is now a previous page link and, additionally, you can see that the current page contains records 101 (from) to 200 (to).
Updated over 3 years ago