# README
go-notion
About
This repository contains an OpenAPI definition of Notion's API based on their documentation as well as a go library to use the API.
Usage
package main
import (
"context"
"fmt"
"log"
"github.com/faetools/go-notion/pkg/notion"
)
func main() {
ctx := context.Background()
cl, err := notion.NewDefaultClient("[bearer token]")
if err != nil {
log.Fatal(err)
}
p, err := cl.GetNotionPage(ctx, "[page ID]")
if err != nil {
log.Fatal(err)
}
...
}
Expansions
There are several expansions (work in progress):
- go-notion-codegen: Generates go code for your databases.
- notion-to-goldmark: Transforms notion blocks into goldmark nodes.
- notion-to-md: Transforms notion blocks into markdown.
Contribution
We use a code generator to generate go code based on the OpenAPI. In addition to the auto generated code, we added a number of convenience methods.
Feel free to contribute to this repo by making a PR that changes the OpenAPI. We will then run the code generator to generate respective go code.
Alternatively, feel free to add to the manually written convenience methods.