Fern’s auto pagination supports offset-based and cursor-based pagination schemes, providing SDK users with simple iterators to loop through all results instead of managing pagination complexity manually.
This page describes how to configure auto pagination for your API endpoints.
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> will implement the AsyncIterable interface, allowing your users to
use it in a for await loop.
Example generated method signature:
Example of how users would call the list method:
Setting up auto pagination involves defining your pagination scheme and where your results are located.
To set up auto pagination for OpenAPI:
x-fern-pagination extension.offset or cursorresults are located, using dot-access notation.For example, if results of my_nested_object are located in the subfield
inner_list, the dot-access path would be results: $response.my_nested_object.inner_list.
To set up auto pagination for the Fern Definition:
pagination field.offset or cursorresults are located, using dot-access notation.