Compatibility layer between the official Notion API and unofficial private API.
npm install notion-compat

> A compatibility layer between the official Notion API and the unofficial Notion API
- fully compatible with react-notion-x
- backwards compatible with notion-client and the unofficial notion API
``ts
import { Client } from '@notionhq/client'
import { NotionCompatAPI } from 'notion-compat'
const notion = new NotionCompatAPI(
new Client({ auth: process.env.NOTION_TOKEN })
)
const recordMap = await notion.getPage(pageId)
`
The resulting recordMap is compatible with notion's unofficial API and react-notion-x.
You can preview react-notion-x using the official client and compatibility layer here: https://react-notion-x-official-api-demo.transitivebullsh.it/
Currently, ~20 blocks have full compatibility and 8 have partial compatibility (sometimes in subtle ways) due Notion's official API not returning enough info for us to faithfully render them in all cases. See the block-by-block compatibility notes below for more info.
I recommend checking out the notion-compat demo side-by-side with the normal react-notion-x demo (which uses the unofficial Notion API via notion-client) and the equivalent public notion page.
Note that using the official API with notion-compat is significantly slower than using the unofficial API via notion-client because of reasons.
The main feature missing from notion-compat right now is collection (database) support. PRs welcome 😃
- image, video, and embed blocks are missing format for proper sizing and layoutcaption
- 3492bd6dbaf44fe7a5cac62c5d402f06
- 5d4e290ca4604d8fb809af806a6c1749
- image, video, and embed blocks are missing alias
- 912379b0c54440a286619f76446cd753
- embed blocks don't contain enough info for proper embedding
- have to write custom embedding logic for iframe urls
- same with some video blocks
- 5d4e290ca4604d8fb809af806a6c1749
- blocks fail for links pointing to other workspacestoggleable
- this happens even if the linked page is publicly readable
- 034119d20132420abe8e9863bbe91e9d
- rich text mentions fail for links to pages and databases in other workspaces
- if API integration doesn't have access to the workspace
- this happens even if the linked page is publicly readable
- 52353862df0f48ba85648db7d0acd1dd
- format is missing
- no toggle headers
- 5995506f2c564d81956aa38711e12337
- paragraph (text block)header
- heading_1 ( block)sub_header
- heading_2 ( block)sub_sub_header
- heading_3 ( block)bulleted_list
- bulleted_list_item ( block)numbered_list
- numbered_list_item ( block)transclusion_container
- quote
- to_do
- toggle
- code
- callout
- file
- divider
- table_of_contents
- column_list
- column
- equation (block and inline)
- synced_block ( and transclusion_reference)
- audio
- tweet
- bookmark
- images and content are missing
- 0be6efce9daf42688f65c76b89f8eb27
- image
- missing caption
- missing format so sizing and layout aren't always handled properly
- 912379b0c54440a286619f76446cd753
- video
- missing caption
- missing format so sizing and layout aren't always handled properly
- missing embedding logic in some cases (original URL must be transformed for embedding in many cases)
- 5d4e290ca4604d8fb809af806a6c1749
- embed
- missing caption
- missing format so sizing and layout aren't always handled properly
- missing embedding logic
- original URL must be transformed for embedding in many cases
- missing embeding display size hints from embedly
- 5d4e290ca4604d8fb809af806a6c1749
- this goes for custom embed blocks as well
- maps
- figma
- typeform
- codepen
- excalidraw
- gist
- loom
- drive
- ...
- child_page (page block)page_cover_position
- page format missing entirely
- no full width, fonts, font size, etc
- 72c5d33ca46642feaee06852cc57c588
- 3702a5d6403d4d58b8a944a77ca26c70
- page cover missing alias
- 067dd719a912471ea9a3ac10710e7fdf
- link_to_page ( block)
- missing for links pointing to other workspaces, even if they're publicly readable
- 034119d20132420abe8e9863bbe91e9d
- pdf
- missing format so sizing and layout aren't handled properly
- table and table_row (simple table blocks)
- missing some formatting info
- child_database (collection_view and collection_view_page` blocks)
- external_object_instance
- breadcrumb
- template
- unsupported
MIT © Travis Fischer
Support my OSS work by following me on twitter