| id | pagination |
|---|---|
| title | Pagination |
| description | Paginate through large result sets using ListPage or generator-based iteration. |
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock';
import ApiLink from '@site/src/components/ApiLink';
import PaginationAsyncExample from '!!raw-loader!./code/08_pagination_async.py'; import PaginationSyncExample from '!!raw-loader!./code/08_pagination_sync.py';
Most methods named list or list_something in the Apify client return a ListPage object. This object provides a consistent interface for working with paginated data and includes the following properties:
items- The main results you're looking for.total- The total number of items available.offset- The starting point of the current page.count- The number of items in the current page.limit- The maximum number of items per page.
Some methods, such as list_keys or list_head, paginate differently. Regardless, the primary results are always stored under the items property, and the limit property can be used to control the number of results returned.
The following example shows how to fetch all items from a dataset using pagination:
{PaginationAsyncExample} {PaginationSyncExample}This approach lets you efficiently retrieve large datasets through pagination while keeping memory usage under control.
:::tip
For most use cases, prefer iterate_items() which handles pagination automatically and yields items one by one.
:::