Notion Wrapper
Overview
Notion Wrapper
Notion is an AI-powered connected workspace for docs, wikis, projects, and knowledge management. Teams use it to centralize information, run workflows, and collaborate — with AI built into the core of the experience.
The Notion Wrapper brings your workspace data into Postgres as queryable foreign tables. Query pages, databases, blocks, and users with plain SQL and join them against your application data. All objects are read-only, and the wrapper works with Supabase Vault for secure API key management and is built on WebAssembly (Wasm) for lightweight, sandboxed execution.
Preparation
Before you get started, make sure the wrappers extension is installed on your database:
_10create extension if not exists wrappers with schema extensions;
and then enable the Wasm foreign data wrapper:
_10create foreign data wrapper wasm_wrapper_10 handler wasm_fdw_handler_10 validator wasm_fdw_validator;
Get a Notion API key
- Visit Notion > Profile > Integrations
- Click "New integration"
- Add an integration name, select your workspace, and set the type to Internal
- Copy the Internal Integration Secret — it will look like
ntn_589513........
Secure your credentials (optional)
By default, Postgres stores FDW credentials inside pg_catalog.pg_foreign_server in plain text. Anyone with access to this table will be able to view these credentials. Wrappers is designed to work with Vault, which provides an additional level of security for storing credentials. We recommend using Vault to store your credentials.
_10select vault.create_secret(_10 '<Notion API key>',_10 'notion',_10 'Notion API key for Wrappers'_10);
Connecting to Notion
We need to provide Postgres with the credentials to access Notion, and any additional options. We can do this using the create server command:
With Vault:
_10create server notion_server_10 foreign data wrapper wasm_wrapper_10 options (_10 fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_notion_fdw_v0.2.0/notion_fdw.wasm',_10 fdw_package_name 'supabase:notion-fdw',_10 fdw_package_version '0.2.0',_10 fdw_package_checksum '719910b65a049f1d9b82dc4f5f1466457582bec855e1e487d5c3cc1e6f986dc6',_10 api_url 'https://api.notion.com/v1', -- optional_10 api_key_id '<key_ID>' -- The Key ID from above._10 );
Without Vault:
_10create server notion_server_10 foreign data wrapper wasm_wrapper_10 options (_10 fdw_package_url 'https://github.com/supabase/wrappers/releases/download/wasm_notion_fdw_v0.2.0/notion_fdw.wasm',_10 fdw_package_name 'supabase:notion-fdw',_10 fdw_package_version '0.2.0',_10 fdw_package_checksum '719910b65a049f1d9b82dc4f5f1466457582bec855e1e487d5c3cc1e6f986dc6',_10 api_url 'https://api.notion.com/v1', -- optional_10 api_key 'ntn_589513........' -- Notion API key_10 );
Note: the fdw_package_* options are required and specify the Wasm package metadata. See the Available Versions table above for the full list.
Resources
Details
Third-party integrations and docs are managed by Supabase partners.