Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/splitbee/notion-api-worker
Notion as CMS with easy API access
https://github.com/splitbee/notion-api-worker
api cloudflare-workers cms notion
Last synced: about 19 hours ago
JSON representation
Notion as CMS with easy API access
- Host: GitHub
- URL: https://github.com/splitbee/notion-api-worker
- Owner: splitbee
- License: mit
- Created: 2020-04-21T11:56:44.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-30T07:37:30.000Z (5 months ago)
- Last Synced: 2024-12-05T14:02:55.324Z (8 days ago)
- Topics: api, cloudflare-workers, cms, notion
- Language: TypeScript
- Homepage:
- Size: 127 KB
- Stars: 1,564
- Watchers: 24
- Forks: 197
- Open Issues: 37
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-list - notion-api-worker
- awesome-notion - Notion API Worker - A serverless wrapper for the private Notion API. (APIs)
- awesome-starz - splitbee/notion-api-worker - Notion as CMS with easy API access (TypeScript)
README
![Notion API Worker](https://user-images.githubusercontent.com/1440854/79893752-cc448680-8404-11ea-8d19-e0308eb32028.png)
![API Version](https://badgen.net/badge/API%20Version/v1/green)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`](https://notion-api.splitbee.io/). You can also [host it yourself](https://workers.cloudflare.com/). 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._
## Features
🍭 **Easy to use** – Receive Notion data with a single GET request
🗄 **Table Access** – Get structured data from tables & databases
✨ **Blazing Fast** – Built-in [SWR](https://www.google.com/search?q=stale+while+revalidate) caching for instant results
🛫 **CORS Friendly** – Access your data where you need it
## Use Cases
- 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`](https://github.com/splitbee/react-notion)
## Endpoints
### Load page data
`/v1/page/`
Example ([Source Notion Page](https://www.notion.so/react-notion-example-2e22de6b770e4166be301490f6ffd420))
[`https://notion-api.splitbee.io/v1/page/2e22de6b770e4166be301490f6ffd420`](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`](https://github.com/splitbee/react-notion).### Load data from table
`/v1/table/`
Example ([Source Notion Page](https://www.notion.so/splitbee/20720198ca7a4e1b92af0a007d3b45a4?v=4206debfc84541d7b4503ebc838fdf1e))
[`https://notion-api.splitbee.io/v1/table/20720198ca7a4e1b92af0a007d3b45a4`](https://notion-api.splitbee.io/v1/table/20720198ca7a4e1b92af0a007d3b45a4)
## Authentication for private pages
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](https://developers.cloudflare.com/workers/reference/apis/environment-variables/).
- Alternatively you can set the `Authorization: Bearer ` header to authorize your requests.### Receiving the token
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.
## Credits
- [Timo Lins](https://twitter.com/timolins) – Idea, Documentation
- [Tobias Lins](https://twitter.com/linstobias) – Code
- [Travis Fischer](https://twitter.com/transitive_bs) – Code