The Notion API allows developers to integrate with Notion workspaces programmatically. Build integrations that connect Notion with other tools, automate workflows, and manage workspace content including pages, databases, blocks, users, comments, and search. Notion is an all-in-one workspace that combines notes, tasks, wikis, and databases into a flexible, collaborative platform.
The SDK requires Go version 1.18 or above.
Resolve all the SDK dependencies, using the go get command.
The following section explains how to use the notion library in a new project.
- Add the following lines to your application's
go.modfile:
replace notion => ".\\notion-go_generic_lib" // local path to the SDK
require notion v0.0.0- Resolve the dependencies in the updated
go.modfile, using thego getcommand.
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
|---|---|---|
| httpConfiguration | HttpConfiguration |
Configurable http client options like timeout and retries. |
| loggerConfiguration | LoggerConfiguration |
Represents the logger configurations for API calls |
| bearerAuthCredentials | BearerAuthCredentials |
The Credentials Setter for OAuth 2 Bearer token |
The API client can be initialized as follows:
package main
import (
"notion"
)
func main() {
client := notion.NewClient(
notion.CreateConfiguration(
notion.WithHttpConfiguration(
notion.CreateHttpConfiguration(
notion.WithTimeout(30),
),
),
notion.WithBearerAuthCredentials(
notion.NewBearerAuthCredentials("AccessToken"),
),
notion.WithLoggerConfiguration(
notion.WithLevel("info"),
notion.WithRequestConfiguration(
notion.WithRequestBody(true),
),
notion.WithResponseConfiguration(
notion.WithResponseHeaders(true),
),
),
),
)
}This API uses the following authentication schemes.