Configure auto-pagination

View as Markdown
Pro and Enterprise feature

This feature is available only for the Pro and Enterprise plans. To get started, reach out to support@buildwithfern.com.

Fern’s auto-pagination supports offset, cursor, URI, and path-based pagination schemes, providing SDK users with simple iterators to loop through all results instead of managing pagination complexity manually.

Generated SDK behavior

Once you’ve configured pagination for an endpoint, Fern generates a TypeScript SDK method that returns a Page<T> where T is the underlying data type. The Page<T> implements the AsyncIterable interface, allowing your users to use it in a for await loop.

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

Setting up auto-pagination

Define your pagination scheme and specify where your results are located:

1...
2paths:
3 /plants:
4 x-fern-pagination:
5 offset: $request.page_number
6 results: $response.results
7...

For full configuration details, see the docs for your API definition format: