Pagination

Pagination is the process of requesting small sections of a larger set of results. Pax8 supports pagination on all endpoints which return a list. Always refer to documentation for each endpoint for explicit field names and conventions.

Counting Nuances

  • When we request pages, page numbers are measured begining at 0 instead of 1.
  • Totals, like the number of pages or results on a page, are measured starting at 1

Say for example, we have 100 results and we wish each page to contain 10 results. We can ask for the first page like so:

curl https://sample.pax8.com/order?limit=10&page=0

And we expect size, totalElements, and totalPages to be measured starting at 1
whereas the number is measured starting at 0.

{
  "content": [ { ... }, ... ],
  "page": {
    "size": 10,
    "totalElements": 100,
    "totalPages": 10,
    "number": 0
  }
}

We can ask for the last page with:

curl https://sample.pax8.com/order?limit=10&page=9

Again, we expect size, totalElements, and totalPages to be measured starting at 1
whereas the number is measured starting at 0

{
  "content": [ { ... }, ... ],
  "page": {
    "size": 10,
    "totalElements": 100,
    "totalPages": 10,
    "number": 9
  }
}

If we ask for page 10

curl https://sample.pax8.com/order?limit=10&page=10

We expect to receive zero results (or perhaps a Not Found Exception)
because we're actually asking for the eleventh page and there are only ten.

{
  "content": [],
  "page": {
    "size": 10,
    "totalElements": 100,
    "totalPages": 10,
    "number": 10
  }
}