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 necessarynext_cursorwill 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 necessarynext_cursorwill be automatically populated by this function
Example
When to Use Each Helper
UseiteratePaginatedAPI 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)
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 clientargs- Arguments for thedataSources.listTemplatesAPI call, includingdata_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 clientargs- Arguments for thedataSources.listTemplatesAPI call, includingdata_source_id
Example
Supported Endpoints
These helpers work with any paginated Notion API endpoint, including:notion.blocks.children.listnotion.dataSources.querynotion.dataSources.listTemplates(use specialized helpers above)notion.users.listnotion.comments.listnotion.fileUploads.listnotion.search