kittycad.pagination

Pagination support for KittyCAD API with OpenAI-style auto-iteration.

Functions

create_async_page_iterator(page_fetcher, kwargs)

Create an asynchronous page iterator.

create_sync_page_iterator(page_fetcher, kwargs)

Create a synchronous page iterator.

Classes

AsyncPageIterator(page_fetcher, initial_kwargs)

Asynchronous iterator for paginated API responses.

SyncPageIterator(page_fetcher, initial_kwargs)

Synchronous iterator for paginated API responses.

class kittycad.pagination.AsyncPageIterator(page_fetcher, initial_kwargs, item_type=None)[source][source]

Asynchronous iterator for paginated API responses.

Provides OpenAI-style async auto-pagination that handles page tokens automatically.

Initialize the async page iterator.

Parameters:
  • page_fetcher (Callable[..., Any]) – Async function to fetch a page (e.g., client.api_calls.list_api_calls)

  • initial_kwargs (Dict[str, Any]) – Initial arguments for the first request

  • item_type (Optional[Type[TypeVar(T, bound= BaseModel)]]) – Type of items being paginated

class kittycad.pagination.SyncPageIterator(page_fetcher, initial_kwargs, item_type=None)[source][source]

Synchronous iterator for paginated API responses.

Provides OpenAI-style auto-pagination that handles page tokens automatically.

Initialize the sync page iterator.

Parameters:
  • page_fetcher (Callable[..., BaseModel]) – Function to fetch a page (e.g., client.api_calls.list_api_calls)

  • initial_kwargs (Dict[str, Any]) – Initial arguments for the first request

  • item_type (Optional[Type[TypeVar(T, bound= BaseModel)]]) – Type of items being paginated

kittycad.pagination.create_async_page_iterator(page_fetcher, kwargs, item_type=None)[source][source]

Create an asynchronous page iterator.

Parameters:
  • page_fetcher (Callable[..., Any]) – Async function that fetches a page

  • kwargs (Dict[str, Any]) – Arguments to pass to the page fetcher

  • item_type (Optional[Type[TypeVar(T, bound= BaseModel)]]) – Type of individual items

Return type:

AsyncPageIterator

Returns:

AsyncPageIterator that can be async iterated to get all items

kittycad.pagination.create_sync_page_iterator(page_fetcher, kwargs, item_type=None)[source][source]

Create a synchronous page iterator.

Parameters:
  • page_fetcher (Callable[..., BaseModel]) – Function that fetches a page

  • kwargs (Dict[str, Any]) – Arguments to pass to the page fetcher

  • item_type (Optional[Type[TypeVar(T, bound= BaseModel)]]) – Type of individual items

Return type:

SyncPageIterator

Returns:

SyncPageIterator that can be iterated to get all items