Pagination

Pagination

Most API endpoints with lists of records will include
the following standardized pagination system.

Request Parameters

per_page

integer

The number of records per page.

Defaults to 100 and the maximum allowed is 2000.

page

integer

The current page number (see below).

Defaults to 0.

page and page_token must not be specified in the same request.

page_token

string

The page token to retrieve.

page and page_token must not be specified in the same request.

Response

The response will also contain the following extra keys:

per_page

integer

The number of records per page

num_records

integer

The total number of records that match the query

num_pages

integer

The total number of pages that match the query

page

integer

The current page number

page_token

string

The page token supplied for this page.

next_page_token

string

The next page token to retrieve.

Usage

There are two ways to page through the data:

  • Sequentially increment page to specify additional page numbers until you
    have retrieved every page of the results. When records are added or removed
    the page boundaries may shift, and it’s possible that some records will be missed
    between pages or returned on two adjacent pages.

  • Provide in page_token the next_page_token value returned by the most recent
    call to this API which got the previous page. This guarantees that the next returned page
    will start immediately after the previous page, with all pages being contiguous and
    non-overlapping. When a next_page_token of null is returned, that indicates that this
    is the last page.

If you are presenting a list of pages to the user, you probably want to use
page. If you want to retrieve all of the data, page_token is likely what you want.
(When retrieving all data, the page_token method allows SendSage to more efficiently
provide the data.)

Both page and page_token may not be specified in the same request.

Example Response with page

{
  "data": [ {}, {}, {}, {} ],
  "page": 0,
  "per_page": 100,
  "num_records": 4,
  "num_pages": 1
}

Example Response with page_token


{
  "data": [ {}, {}, {}, {} ],
  "next_page_token": "YjMmVjZzImY5QWfiQWaiojI5J2XyVGZy9mIsUTM6ICZpJye",
  "page_token": "IWM1IDMiFWZ1MWfiQWaiojI5J2XyVGZy9mIsMTM6ICZpJye",
  "per_page": 2,
  "num_records": 4,
  "num_pages": 2
}