Pagination

Overview

Every endpoint that returns a list of resources is paginated. A paginated response returns one page of results at a time, along with the links and counts needed to walk through the rest of them.

An endpoint is paginated if its response contains the links and meta objects described below. The API Reference lists the page and per_page query parameters on each of these endpoints.

Query Parameters

ParameterTypeDefaultDescription
pageinteger1The page of results to return.
per_pageinteger10The number of results to return on each page. Minimum 1, maximum 5000.

Both parameters are optional. Requesting a page beyond the last page returns an empty data array rather than an error.

GET /v3/accounts?page=2&per_page=50

Response Format

A paginated response wraps the results in data and adds links and meta:

{
  "data": [],
  "links": {
    "first": "https://api.aet.dev/api/v3/accounts?page=1",
    "last": "https://api.aet.dev/api/v3/accounts?page=12",
    "prev": null,
    "next": "https://api.aet.dev/api/v3/accounts?page=2"
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "to": 10,
    "last_page": 12,
    "per_page": 10,
    "total": 118,
    "path": "https://api.aet.dev/api/v3/accounts",
    "links": []
  }
}

links

FieldDescription
firstURL of the first page.
lastURL of the last page.
prevURL of the previous page, or null on the first page.
nextURL of the next page, or null on the last page.

meta

FieldDescription
current_pageThe page number that was returned.
fromIndex of the first result on this page within the full result set, or null when the page is empty.
toIndex of the last result on this page within the full result set, or null when the page is empty.
last_pageThe number of the final page.
per_pageThe page size that was applied.
totalTotal number of results across every page.
pathBase URL of the endpoint, without the pagination query string.
linksPage links rendered for a paginator UI, each with a url, a label, and an active flag.

Working Through Every Page

Request the first page, then follow links.next until it is null. The links carry forward any other query parameters that were sent, such as filters and sorting, so they can be requested as-is.

Page boundaries are evaluated at request time. If records are created or deleted while paging through a list, a result can shift between pages and be seen twice or missed. When that matters, sort by a stable field or narrow the list with a filter before paging.

Prefer a larger per_page over many small requests when retrieving a full list, and keep in mind that a large page takes longer to return.


Did this page help you?