notion
notion copied to clipboard
Go client for official Notion API.
notion
notion is a Go client for the Notion API.
Features
The client supports all (non-deprecated) endpoints available in the Notion API, as of May 15, 2021:
- [x] Get database info, example
- [x] Query a database, example
- [x] Retrieve page info. example
- [x] Retrieve children of a block, example
- [x] Create a page, example
- [x] Update page properties
- [x] Append block children
- [x] Get user info, example
- [x] List all users, example
- [x] Search, example
Getting started
To obtain an API key (required for API calls), follow Notion’s getting started guide.
Code example
First, construct a new Client:
import "github.com/kjk/notion"
(...)
client := notion.NewClient("secret-api-key")
Then, use the methods defined on Client to make requests to the API. For
example:
page, err := client.GetPage(context.Background(), "18d35eb5-91f1-4dcb-85b0-c340fd965015")
if err != nil {
// Handle error...
}
👉 Check out the docs on pkg.go.dev for further reference and examples.
Status
The Notion API is currently in public beta.
⚠️ Although the API itself is versioned, this client will make breaking
changes in its code until v1.0 of the module is released.
Official Notion API is still limited:
- not all block types are supported
- no way to avoid re-downloading data we already have
Other clients
- https://github.com/kjk/notionapi : another Go client I wrote, this one uses unofficial API
- https://github.com/makenotion/notion-sdk-js : official node SDK from Notion
- https://github.com/dstotijn/go-notion : another Go client
- https://github.com/jomei/notionapi : another Go client
License
MIT License
I based this code on https://github.com/dstotijn/go-notion (as of https://github.com/dstotijn/go-notion/commit/55aa9db5c7a72af2a57ac953ebbbdbdec3e1efa1, May 19 2021). I made API changes so it's not compatible with go-notion.