Pagination

How to work with paginated responses when querying the Mercantive API. By default, responses are paginated with 25 results per page.

Making Paginated Requests

To fetch different pages of results, you can append the page parameter to your API requests. For example, to retrieve the second page of users:

Response Structure

  • Name
    data
    Type
    array
    Description

    An array of objects representing the items on the current page. Each object contains customer information such as id, name, and email.

  • Name
    links
    Type
    object
    Description

    Contains URLs for navigating between pages, including first, last, previous, and next page links.

  • Name
    meta
    Type
    object
    Description

    Provides metadata about the pagination, including current page, total pages, items per page, and total item count.

The meta object tells us we're on page 1 of 4, with 25 items per page and a total of 100 items.

Request

curl -X https://api.mercantive.com/v1/customers \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d page=2

Response

{
  "data": [
      {
          "id": "9d1a6ef4-05b2-420c-8237-ba4f99cb206c",
          "name": "Elon Musk",
          "email": "[email protected]"
      },
      {
          "id": "8d1a6ef1-05b3-420c-1233-ca4f99cb2064",
          "name": "Steve Jobs",
          "email": "[email protected]"
      }
  ],
  "links": {
    "first": "https://api.mercantive.com/v1/customers?page=1",
    "last": "https://api.mercantive.com/v1/customers?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "links": [
      {
        "url": null,
        "label": "Previous",
        "active": false
      },
      {
        "url": "https://api.mercantive.com/v1/customers?page=1",
        "label": "1",
        "active": true
      },
      {
        "url": null,
        "label": "Next",
        "active": false
      }
    ],
    "path": "https://api.mercantive.com/v1/customers",
    "per_page": 25,
    "to": 3,
    "total": 3
  }
}

Was this page helpful?