A serverless wrapper for the private Notion API. It provides fast and easy access to your Notion content. Ideal to make Notion your CMS.
We provide a hosted version of this project on https://notion-api.splitbee.io
. You can also host it yourself. Cloudflare offers a generous free plan with up to 100,000 request per day.
Use with caution. This is based on the private Notion API. We can not gurantee it will stay stable.
🍭 Easy to use – Receive Notion data with a single GET request
🗄 Table Access – Get structured data from tables & databases
✨ Blazing Fast – Built-in SWR caching for instant results
🛫 CORS Friendly – Access your data where you need it
-
Use it as data-source for blogs and documentation. Create a table with pages and additional metadata. Query the
/table
endpoints everytime you want to render a list of all pages. -
Get data of specific pages, which can be rendered with
react-notion
/v1/page/<PAGE_ID>
Example (Source Notion Page)
https://notion-api.splitbee.io/v1/page/2e22de6b770e4166be301490f6ffd420
Returns all block data for a given page.
For example, you can render this data with react-notion
.
/v1/table/<PAGE_ID>
Example (Source Notion Page)
https://notion-api.splitbee.io/v1/table/20720198ca7a4e1b92af0a007d3b45a4
All public pages can be accessed without authorization. If you want to fetch private pages there are two options.
- The recommended way is to host your own worker with the
NOTION_TOKEN
environment variable set. You can find more information in the Cloudflare Workers documentation. - Alternatively you can set the
Authorization: Bearer <NOTION_TOKEN>
header to authorize your requests.
To obtain your token, login to Notion and open your DevTools and find your cookies. There should be a cookie called token_v2
, which is used for the authorization.
You can control which API endpoints are available by configuring the wrangler.toml
file. This allows you to disable specific routes that you don't need or want to expose.
[vars]
# Set to true to enable, false to disable
PAGE_ENABLED = true # Controls /v1/page/:pageId endpoint
TABLE_ENABLED = true # Controls /v1/table/:pageId endpoint
SEARCH_ENABLED = true # Controls /v1/search endpoint
USER_ENABLED = true # Controls /v1/user/:userId endpoint
This way, you can expose only the specific endpoints you need for your application.
You can restrict access to only allow pages from your organization/workspace. This is useful for preventing access to pages outside your organization, even if a user has valid authentication.
[vars]
# For a single space/organization ID:
ALLOWED_SPACE_ID = "your-space-id"
# For multiple space IDs (comma-separated):
ALLOWED_SPACE_IDS = "space-id-1,space-id-2,space-id-3"
To find your workspace/space ID:
- Use the browser dev tools with a page from your workspace loaded
- Look for requests to the Notion API that contain a
space_id
field - Alternatively, inspect the response from
/v1/page/<PAGE_ID>
and look for thespace_id
property in the block data
You can define different configurations for different environments:
# Default environment
[vars]
PAGE_ENABLED = true
TABLE_ENABLED = true
SEARCH_ENABLED = true
USER_ENABLED = true
# Production environment
[env.production]
# Example: Only enable page and table routes in production
PAGE_ENABLED = true
TABLE_ENABLED = true
SEARCH_ENABLED = false
USER_ENABLED = false
ALLOWED_SPACE_ID = "your-production-space-id"
- Timo Lins – Idea, Documentation
- Tobias Lins – Code
- Travis Fischer – Code