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 data array with the current page of items.
  • A links object that contains navigation URLs.
  • A meta object 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=10

Query parameters

Use the following parameters to control pagination:

NameTypeDescription
pageIntegerThe page number to return (default is 1).
per_pageIntegerThe 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

An array of results for the current page.


links

Navigation 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 (or null if you're on the first page).
  • next: URL of the next page (or null if you're on the last page).

meta

Information about the current state of pagination:

FieldTypeDescription
current_pageIntegerThe current page number.
fromIntegerThe index of the first item on this page.
toIntegerThe index of the last item on this page.
per_pageIntegerThe number of items per page.
totalIntegerThe total number of items.
last_pageIntegerThe total number of pages.
pathStringThe base URL of the API endpoint.
linksArrayOptional UI-style pagination controls.

Each item in meta.links includes the following:

  • url: The page URL.
  • label: A page label such as 1 or Next.
  • active: Whether the page is currently selected.