@relayfile/adapter-notion
v0.3.5
Published
Notion adapter for relayfile — maps Notion databases, pages, blocks, and comments to relayfile VFS paths
Readme
@relayfile/adapter-notion
Relayfile adapter for Notion. It ingests databases, pages, blocks, markdown content, and comments into the relayfile VFS and supports writeback for page properties, markdown content, comments, and page creation inside databases.
Quick Start
npm install
npm test
npm run buildimport { RelayFileClient } from '@relayfile/sdk';
import { NotionAdapter } from '@relayfile/adapter-notion';
const relay = new RelayFileClient({
baseUrl: process.env.RELAYFILE_BASE_URL ?? 'https://api.relayfile.com',
token: process.env.RELAYFILE_TOKEN ?? '',
});
const adapter = new NotionAdapter(relay, undefined, {
token: process.env.NOTION_TOKEN ?? '',
databaseIds: ['database-id'],
pageIds: ['page-id'],
});
await adapter.bulkIngest('workspace-id');Create a Notion internal integration in the Notion developer dashboard, grant it access to the target databases/pages, and use the integration token as NOTION_TOKEN.
VFS Layout
/notion/databases/{database_id}/metadata.json
/notion/databases/{database_id}/pages/{page_id}.json
/notion/databases/{database_id}/pages/{page_id}/properties.json
/notion/databases/{database_id}/pages/{page_id}/content.md
/notion/databases/{database_id}/pages/{page_id}/blocks/{block_id}.json
/notion/databases/{database_id}/pages/{page_id}/comments.json
/notion/pages/{page_id}.json
/notion/pages/{page_id}/properties.json
/notion/pages/{page_id}/content.md
/notion/pages/{page_id}/comments.jsonSupported Property Types
Writeable property serializers are included for:
titlerich_textnumberselectmulti_selectstatusdatepeoplefilescheckboxurlemailphone_numberrelation
Read-only Notion properties such as formula, rollup, created_time, and last_edited_time are preserved in ingested JSON but rejected during writeback.
Markdown Content Support
The adapter uses the Notion markdown content endpoints when enabled and falls back to rendering block trees when those endpoints are unavailable. Notion’s current markdown endpoints are GET /v1/pages/{page_id}/markdown and PATCH /v1/pages/{page_id}/markdown, and the adapter defaults those calls to Notion-Version: 2026-03-11.
Classic database/page/block APIs still default to Notion-Version: 2022-06-28 because that version preserves the legacy database schema and POST /v1/databases/{id}/query behavior this package targets. Override either version through apiVersion and markdownApiVersion if your workspace needs a different combination.
Poll-Based Sync
Notion webhooks are not broadly available across all plans, so the adapter includes poll-based sync helpers:
- Database pages are queried with
last_edited_time > cursor. - Standalone pages are scanned through
POST /v1/search, sorted bylast_edited_time. - The sync cursor is an ISO timestamp watermark.
Writeback
- Editing
*.jsonpage files maps toPATCH /v1/pages/{page_id}. - Editing
properties.jsonnext to a page maps toPATCH /v1/pages/{page_id}. - Editing
content.mdmaps toPATCH /v1/pages/{page_id}/markdown. - Editing
comments.jsoncreates a new comment withPOST /v1/comments. - Writing to
/notion/databases/{database_id}/pagescreates a new page withPOST /v1/pages.
