Skip to main content
The Notion SDK provides helper functions to simplify working with paginated API endpoints.

iteratePaginatedAPI

Returns an async iterator over the results of any paginated Notion API. This is memory-efficient for large datasets as it fetches pages on demand.

Signature

Parameters

  • listFn - A bound function on the Notion client that represents a conforming paginated API (e.g., notion.blocks.children.list)
  • firstPageArgs - Arguments that should be passed to the API on the first and subsequent calls. Any necessary next_cursor will be automatically populated by this function

Example

collectPaginatedAPI

Collects all results of paginating an API into an in-memory array. Use this for smaller datasets when you need all results at once.

Signature

Parameters

  • listFn - A bound function on the Notion client that represents a conforming paginated API (e.g., notion.blocks.children.list)
  • firstPageArgs - Arguments that should be passed to the API on the first and subsequent calls. Any necessary next_cursor will be automatically populated by this function

Example

When to Use Each Helper

Use iteratePaginatedAPI when:
  • Working with large datasets that might not fit in memory
  • You want to process items as they arrive
  • You may not need all results (e.g., searching for a specific item)
Use collectPaginatedAPI when:
  • The dataset is small enough to fit in memory
  • You need all results before processing
  • You need to perform operations that require the full dataset (sorting, filtering, etc.)

iterateDataSourceTemplates

A specialized iterator for data source templates. This helper simplifies iterating through all page templates available for a data source.

Signature

Parameters

  • client - An instance of the Notion client
  • args - Arguments for the dataSources.listTemplates API call, including data_source_id

Example

collectDataSourceTemplates

Collects all data source templates into an array. Use this when you need to work with the full list of templates at once.

Signature

Parameters

  • client - An instance of the Notion client
  • args - Arguments for the dataSources.listTemplates API call, including data_source_id

Example

Supported Endpoints

These helpers work with any paginated Notion API endpoint, including:
  • notion.blocks.children.list
  • notion.dataSources.query
  • notion.dataSources.listTemplates (use specialized helpers above)
  • notion.users.list
  • notion.comments.list
  • notion.fileUploads.list
  • notion.search