Pagination
Use pagination to manage large sets of data returned by the API.
All list endpoints support pagination using the page query parameter. This improves performance and user experience by limiting the number of results returned in each response.
How pagination works
When you request a list of resources (such as products, policies, or promotions), the API returns a paginated response. This response includes the following:
- A
dataarray with the current page of items. - A
linksobject that contains navigation URLs. - A
metaobject that provides information about the pagination state.
Use the page parameter to request a specific page. You can optionally use the per_page parameter to set how many results to return per page.
GET /api/products?page=2&per_page=10Query parameters
Use the following parameters to control pagination:
| Name | Type | Description |
|---|---|---|
page | Integer | The page number to return (default is 1). |
per_page | Integer | The number of results per page. Optional. |
Paginated response structure
Here’s what a typical paginated response looks like:
{
"data": [ ... ],
"links": {
"first": "https://...page=1",
"last": "https://...page=5",
"prev": null,
"next": "https://...page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 5,
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "https://...page=1",
"label": "1",
"active": true
},
{
"url": "https://...page=2",
"label": "Next »",
"active": false
}
],
"path": "https://.../api/products",
"per_page": 10,
"to": 10,
"total": 50
}
}Fields in the response
data
dataAn array of results for the current page.
links
linksNavigation links that help you move between pages:
first: URL of the first page.last: URL of the last page.prev: URL of the previous page (ornullif you're on the first page).next: URL of the next page (ornullif you're on the last page).
meta
metaInformation about the current state of pagination:
| Field | Type | Description |
|---|---|---|
current_page | Integer | The current page number. |
from | Integer | The index of the first item on this page. |
to | Integer | The index of the last item on this page. |
per_page | Integer | The number of items per page. |
total | Integer | The total number of items. |
last_page | Integer | The total number of pages. |
path | String | The base URL of the API endpoint. |
links | Array | Optional UI-style pagination controls. |
Each item in meta.links includes the following:
url: The page URL.label: A page label such as1orNext.active: Whether the page is currently selected.
Updated 3 months ago