Features

Auto Pagination

Paginate through API responses easily

Pro Feature

This feature is only available on paid plans. Please schedule a demo or email us to get started.

Instead of forcing SDK users to learn the intricacies of your pagination system, Fern SDKs will return an iterator so that user’s can simply loop through all the results.

When pagination for an endpoint is configured, the TypeScript SDK method will return a Page<T> where T is the underlying data type. The Page<T> will implement the AsyncIterable interface, allowing you to use it in a for await loop.

Below is an example method signature for a list endpoint:

1import core from "../core";
2
3export interface UsersClient {
4
5 /**
6 * List all users
7 * @param props
8 * @returns A page of users
9 */
10 list(
11 request: ListUsersRequest = {},
12 requestOptions: core.RequestOptions = {}
13 ): core.Page<User>;
14}

And here is an example of how a user would use the list method:

1const response = await client.users.list();
2for await (const user of response) {
3 console.log(user);
4}

Supported Pagination Types

Fern supports the following pagination schemes:

Pagination SchemeSupported
Offset-based
Cursor-based
Link-based