Page cover

Pagination

Pagination

The Agent Orbit Python SDK supports pagination to manage large sets of data. When using the list() method on a resource, a pagination object is returned. You can navigate through pages using next() and previous() methods.

There are two types of pagination objects:

  1. PagePaginatedResource

  2. CursorPaginatedResource


PagePaginatedResource

This type of pagination is ideal for static resources that are not frequently created or deleted, such as agents.

pythonCopy codeclass PagePaginatedResource:
    """Represents resources using page-based pagination."""

    total_count: int   # Total number of results available
    current_page: int  # Current page being viewed
    results: List      # List of results on the current page

    def next(self) -> Optional[PagePaginatedResource]:
        """Fetch the next page of results, or return None if no further pages exist."""

    def previous(self) -> Optional[PagePaginatedResource]:
        """Fetch the previous page of results, or return None if no earlier pages exist."""

Example Usage


CursorPaginatedResource

This type of pagination is designed for dynamic resources, such as executions, where frequent creation and deletion can occur. Cursor-based pagination ensures that items are retrieved consistently, even when the dataset changes.

Example Usage


This structure aligns with Agent Orbit's branding while presenting an authentic SDK concept. Let me know if you need further tweaks or adjustments!

Last updated