Configure auto-pagination
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
TypeScript
Python
Go
Java
C#
Rust
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.
Once you’ve configured pagination for an endpoint, Fern generates a Python SDK
method that returns a Pager[T] where T is the underlying data type. The
Pager[T] implements the Generator interface, allowing your users to
use it in a for ... in loop.
or with the asynchronous client:
Once you’ve configured pagination for an endpoint, Fern generates a Go SDK
method that returns a *core.Page[T] where T is the underlying data type.
Page.Iterator() returns an iterator that fetches subsequent pages as needed,
and Page.GetNextPage(ctx) iterates page by page.
Once you’ve configured pagination for an endpoint, Fern generates a Java SDK
method that returns a SyncPagingIterable<T> where T is the underlying data
type. The iterable fetches subsequent pages as your users loop over or stream
the items, and nextPage() paginates manually.
or as a stream:
Once you’ve configured pagination for an endpoint, Fern generates a C# SDK
method that returns a Pager<T> where T is the underlying data type. The
Pager<T> implements IAsyncEnumerable<T>, allowing your users to use it in
an await foreach loop.
Once you’ve configured pagination for an endpoint, Fern generates a Rust SDK
method with a _paginated suffix alongside the single-page method. It returns
an AsyncPaginator<T> where T is the underlying data type. The
AsyncPaginator<T> implements the futures Stream trait and fetches
subsequent pages as your users iterate. The generated prelude
re-exports StreamExt, so use your_crate::prelude::*; provides
.next().await without a direct futures dependency.
Setting up auto-pagination
Define your pagination scheme and specify where your results are located:
For full configuration details, see Pagination in OpenAPI.