Pagination
List endpoints return objects a page at a time, most recently created first. limit sets the page size, from 1 to 1,000, and defaults to 50. Filters narrow a list to the objects you need.
Cursors
A cursor is an object ID that marks your place in a list. Objects created while you page through a list don’t shift your place, so no object appears twice.
To get the next page, set starting_after to the ID of the last object on the current page. To get the previous page, set ending_before to the ID of the first object.
The List object
List endpoints return their objects in a list object.
- Name
object
- Type
- "list",
- Description
- The object's type.
- Name
has_more
- Type
- boolean,
- Description
- Whether there are more objects beyond this page.
- Name
items
- Type
- array,
- Description
- The objects on this page.
Example
List pages
Auto-pagination
The SDKs can fetch the following pages for you:
- In TypeScript,
fetchListPagescollects the pages into one list, up tomaxItemsobjects.iterateListPagesyields one page at a time. - In Python, a page’s
auto_paging_iter()yields every object across pages. - In Rust,
list_paginatereturns aPaginatorwhoseitems()is aStreamover every object.