Skip to contentnotionic
Docs menu

Reference

Fetch functions

fetchBlocks and fetchPage, from notionic/fetch.

TypeScript
import { fetchBlocks, fetchPage } from "notionic/fetch"

fetchBlocks(client, blockId, options?)

Returns Promise<NotionBlock[]>: every block under blockId, with nested blocks as children, linked pages and subpages as linkedPage, and previews of the pages behind bookmarks, embeds and link previews as bookmarkPreview.

fetchPage(client, pageId, options?)

Returns Promise<{ page: NotionPage; blocks: NotionBlock[] }>. page has id, url, title, icon, cover, lastEditedTime and properties.

Options

OptionDefaultDescription
maxDepth5Levels of nested blocks to fetch below the top level.
concurrency3Requests in flight at once per level.
bookmarkPreviewstrueFetch the page behind each bookmark, embed and link preview for its title, description, image and favicon, so they render as cards. false makes no requests outside Notion.

The client

client is a Client from @notionhq/client, or anything with the same blocks.children.list and pages.retrieve methods. Without pages.retrieve, fetchBlocks still works, but link to page blocks get no titles and subpages no icons.