Skip to main content

Pagination

Every list method returns a page holding the current items, a total (when the API reports it), and a link to the next page. You can iterate one page or transparently across all of them.

Iterate everything

A page is async-iterable across every page:

const rooms = await client.rooms.list({ perPage: 50 });

for await (const room of rooms) {
console.log(room.roomId);
}

Work with one page

const first = await client.rooms.list({ perPage: 20 });

first.data; // items on this page
first.total; // total across all pages, when reported
first.hasNextPage; // whether another page exists

Parameters

Every list method accepts a page number, a page size, and a cursor (from a previous page) alongside its own filters.

await client.rooms.list({ page: 2, perPage: 50 });

Got a Question? Ask us on discord