Pagination
Lists are divided into pages. The default page size is 50, but this can be adjusted with the limit parameter. The maximum page size is 1000.
Cursors
Cursors are object IDs that define your position in a list. Unlike offset-based pagination, cursors eliminate the possibility of returning duplicate objects and gracefully handle new items as they are added.
Every list resource supports the starting_after, and ending_before parameters. To request the next page, set starting_after to the last object ID in the current page. To request the previous page, set ending_before to the first object ID in the current page.
The List object
Responses containing a record of multiple objects are returned wrapped in the list object.
- Name
object
- Type
- "list",
- Description
- Literal representing the object’s type.
- Name
has_more
- Type
- boolean,
- Description
- Whether there are more items in the list
- Name
items
- Type
- array,
- Description
- An array containing the current page of list items
Example
List pages
Auto-pagination
Sometimes, it may be be necessary to retrieve a large number of objects. For this reason, the SDK provides fetchListPages and iterateListPages utilities to automatically paginate through a list.