Pagination

The Crater API employs pagination to efficiently deliver large sets of data, defaulting to 10 items per page to optimize performance and manageability.


Parameters

  • Name
    page
    Type
    number
    Description

    The page number to retrieve.

  • Name
    limit
    Type
    number
    Description

    The number of items per page.

Pagination Details in Responses

When a list of resources is requested from the API, the response includes:

  • A data attribute containing an array of the current page's items.
  • A meta attribute offering pagination details such as the current page, total number of items, and the total number of pages.
  • A links attribute with URLs to navigate directly to the first, last, previous, and next pages when available.

Pagination Control

To tailor your data retrieval, use the following parameters in your query:

  • page: Determines the page number of the dataset you wish to access.
  • limit: Sets how many items will be displayed on each page.

Navigating Through Pages

Use the URLs provided in the links attribute for easy navigation:

  • first and last will take you to the beginning or the end of the list, respectively.
  • prev and next can be used to move sequentially through the pages, although in the example above, these are null since there is only one page of data.

With these tools, you can effectively manage and access large volumes of data provided by the Crater API.

Manual pagination using cURL

curl -G https://payments.your-domain.com/api/v2/invoices \
  -H "Authorization: Bearer {token}" \
  -d page="1" \
  -d limit=10

Example Response

{
  "data": [
    {
      "id": "INV-001",
      // ...
    },
    {
      "id": "INV-002",
      // ...
    },
    {
      "id": "INV-003",
      // ...
    }
  ],
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 3,
    "path": "https://payments.your-domain.com/api/v2/invoices",
    "per_page": 10,
    "to": 10,
    "total": 30
  },
  "links": {
    "first": "https://payments.your-domain.com/api/v2/invoices?page=1&per_page=10",
    "last": "https://payments.your-domain.com/api/v2/invoices?page=3&per_page=10",
    "prev": null,
    "next": null
  }
}