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

const firstPage = await bias.customers.list();
if (firstPage.object === "error") throw new Error(firstPage.error.message);

const secondPage = await bias.customers.list({
    starting_after: firstPage.items.at(-1)?.id,
});

Auto-pagination

The SDKs can fetch the following pages for you:

  • In TypeScript, fetchListPages collects the pages into one list, up to maxItems objects. iterateListPages yields one page at a time.
  • In Python, a page’s auto_paging_iter() yields every object across pages.
  • In Rust, list_paginate returns a Paginator whose items() is a Stream over every object.
// Auto-paginate to array
const customers = await fetchListPages(
    bias.customers.list,
    { limit: 1000 }, // Use the maximum limit per page
    { maxItems: 10000 }, // Fetch up to 10,000 customers (10 pages) in total
);

// Auto-paginate page by page
for await (const page of iterateListPages(bias.customers.list, { limit: 100 })) {
    if (page.object === "error") throw new Error(page.error.message);
    for (const customer of page.items) {
        // Do something with the customer
    }
}