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:
- Get database info, example
- Query a database, example
- Retrieve page info. example
- Retrieve children of a block, example
- Create a page, example
- Update page properties
- Append block children
- Get user info, example
- List all users, example
- 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.
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
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
.