Skip to content

Pagination

The Compliance API uses two pagination shapes. Cursor pages (Activity Feed, Chats, Messages) and offset pages (everything else). Both are modelled here as generic dataclasses, and every paginated resource ships a .list() method returning one page and a .iter() method that auto-paginates.

pagination

Pagination primitives for the Compliance API.

The Compliance API uses two pagination shapes:

  • CursorPage — used by Activity Feed, Chats, and Messages. Each page payload carries first_id, last_id, and has_more. Forward via after_id=last_id; backward via before_id=first_id.
  • OffsetPage — used by everything else paginated. Each page payload carries an opaque next_page token; pass it back as the page query parameter to fetch the next page.

Both page classes are plain dataclasses (no Pydantic) parameterised over the item type T. They are used identically by sync and async resources.

Each paginated resource also exposes an .iter() method that drives these pages for you: it fetches consecutive pages and yields items one at a time, so you rarely need to construct a page object yourself.

AsyncCursorPage module-attribute

AsyncCursorPage = CursorPage

AsyncOffsetPage module-attribute

AsyncOffsetPage = OffsetPage

CursorPage dataclass

Bases: Generic[T]

A single cursor-paginated page.

Attributes:

Name Type Description
data list[T]

Decoded items from the page's data array.

first_id str | None

ID of the first item in the page (server-side). None when the page is empty.

last_id str | None

ID of the last item in the page. Pass as after_id on the next request to fetch the page after this one.

has_more bool

Server-supplied flag indicating whether further pages exist after this one.

from_dict classmethod

from_dict(
    body: Mapping[str, Any], item_factory: ItemFactory[T]
) -> "CursorPage[T]"

Build a CursorPage from a decoded response body.

OffsetPage dataclass

Bases: Generic[T]

A single offset-paginated page.

Attributes:

Name Type Description
data list[T]

Decoded items from the page's data array.

has_more bool

Server-supplied flag indicating whether further pages exist after this one. Equivalent to next_page is not None.

next_page str | None

Opaque pagination token returned by the server. Pass it as the page query parameter to fetch the next page. None when this is the last page.

from_dict classmethod

from_dict(
    body: Mapping[str, Any], item_factory: ItemFactory[T]
) -> "OffsetPage[T]"

Build an OffsetPage from a decoded response body.