On this page
At a glance#
A list operation returns one page at a time. The request names the page and its size; the response carries the page, the total and the links in the body, never in a header.
| Parameter | Type | Rule |
|---|---|---|
page | integer | 1-based. The default is 1. |
per_page | integer | The size of the page. It declares a maximum of at most 100 and a default that does not exceed it. Most of the platform's lists default to 15. |
sort_by | string | The property to sort by, in snake_case. |
sort_dir | string | asc or desc. |
pageNumber, pageSize, page_number, page_size, size, limit, offset and cursor are not the platform's names for paging. An API that needs cursor paging for a very large collection says so in its description and still offers page and per_page.
The response#
{
"data": [
{ "order_id": "ord_1042", "status": "shipped" },
{ "order_id": "ord_1043", "status": "open" }
],
"meta": {
"current_page": 1,
"last_page": 12,
"per_page": 15,
"total": 172
},
"links": {
"first": "https://gate.api360.sa/<product-slug>/v1/orders?page=1&per_page=15",
"next": "https://gate.api360.sa/<product-slug>/v1/orders?page=2&per_page=15",
"prev": null,
"last": "https://gate.api360.sa/<product-slug>/v1/orders?page=12&per_page=15"
}
}datais an array, empty when the page holds nothing. A page after the last answers200with an emptydata, not404.meta.totalis the number of items in the whole collection. A client that needs a count never reads a header or counts pages.- An API that wraps every answer in
success,messageanddata, as the platform's console API does, puts the page one level down:data.dataanddata.meta. The rule accepts both shapes.
Limits#
A per_page above the maximum is answered with 400 and the error envelope. Clamping silently hides the mistake from the caller. A page or per_page below 1 is also 400.
The maximum is a safety limit as well as a contract: without it a caller can ask for the whole table in one request.
Checked by#
| Rule | Severity | Checks |
|---|---|---|
api360-pagination-params | error | A GET with a paging parameter uses page and per_page; per_page is an integer with a maximum of at most 100 and a default within it |
api360-pagination-response | error | The 200 response of such a GET carries data (an array) and meta.total |