All Projects → sorcererxw → go-notion

sorcererxw / go-notion

Licence: MIT license
Notion Official API Go Client.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-notion

shellbear.me
Source code of my personal website and blog ✨
Stars: ✭ 177 (+1164.29%)
Mutual labels:  notion, notion-api
Notion-GCal-Sync
A Python script to automate the syncing of tasks between Google Calendar and the all-in-one productivity workspace, Notion. It utilizes API and is customizable for your own needs. Free to use.
Stars: ✭ 120 (+757.14%)
Mutual labels:  notion, notion-api
Notion-and-Google-Calendar-2-Way-Sync
2 Way Sync Between Notion Database and Google Calendar
Stars: ✭ 205 (+1364.29%)
Mutual labels:  notion, notion-api
notionproxy
Notion as a web site, inspired by react-notion-x.
Stars: ✭ 24 (+71.43%)
Mutual labels:  notion, notion-api
notionapi
A Notion API SDK, written in Golang
Stars: ✭ 351 (+2407.14%)
Mutual labels:  notion, notion-api
go-notion
Go client for the Notion API.
Stars: ✭ 261 (+1764.29%)
Mutual labels:  notion, notion-api
notion-nextjs-blog
A starter blog template powered by Next.js, Notion and Tailwind CSS.
Stars: ✭ 25 (+78.57%)
Mutual labels:  notion, notion-api
notion-sdk-net
A Notion SDK for .Net
Stars: ✭ 71 (+407.14%)
Mutual labels:  notion, notion-api
notion-sdk-php
A complete Notion SDK for PHP developers.
Stars: ✭ 60 (+328.57%)
Mutual labels:  notion, notion-api
cards
Turn your Notion database into a deck of cards
Stars: ✭ 37 (+164.29%)
Mutual labels:  notion, notion-api
notion-sdk-py
Official Notion SDK rewritten in Python (sync + async)
Stars: ✭ 753 (+5278.57%)
Mutual labels:  notion, notion-api
open-source-notionapi-apps
Collection of Apps, Integrations und Libraries that utilize the Notion API
Stars: ✭ 82 (+485.71%)
Mutual labels:  notion, notion-api
memegentino
Meme generator for Notion
Stars: ✭ 18 (+28.57%)
Mutual labels:  notion, notion-api
notion-scholar
Reference management solution using Python and Notion.
Stars: ✭ 77 (+450%)
Mutual labels:  notion, notion-api
jahir.dev
My personal website 💎 – Built using Next.js, TypeScript, MDX, contentlayer, Notion and Stitches styled components
Stars: ✭ 119 (+750%)
Mutual labels:  notion, notion-api
NotionSwift
Unofficial Notion API SDK for iOS & macOS
Stars: ✭ 49 (+250%)
Mutual labels:  notion, notion-api
notion-avatar
🪄 An online tool for making notion-style avatars.
Stars: ✭ 1,687 (+11950%)
Mutual labels:  notion
Potion
A Personalized Notion
Stars: ✭ 13 (-7.14%)
Mutual labels:  notion
nobelium
A static blog build on top of Notion and NextJS, deployed on Vercel.
Stars: ✭ 1,790 (+12685.71%)
Mutual labels:  notion
notion-rtl
ARCHIVED - A Chrome extension to enable RTL support in https://notion.so
Stars: ✭ 58 (+314.29%)
Mutual labels:  notion

go-notion

tests Go Reference Go Report Card codecov

Go SDK for Notion Official API.

go get github.com/sorcererxw/go-notion

Overview

go-notion is the Golang binding for Notion official API. This package provides:

  • Easy-to-use and well-testing API wrappers.

  • Complete type definition.

You can easily and quickly build notion integrations with this package.

⚠️ Notion official API is still in public beta, it's hard to guarantee forward compatibility in the future. This package will be continuously updated according to the official documentation.

Getting Started

At the beginning, you should follow the official document to create your workspace and integrations.

package main

import (
	"context"

	"github.com/sorcererxw/go-notion"
)

func main() {
	client := notion.NewClient(notion.Settings{Token: "token"})

	database, err := client.RetrieveDatabase(context.Background(), "database_id")
}

Pagination

package main

func main() {
	var cursor string
	for {
		data, nextCursor, hasMore, err := client.ListAllUsers(context.Background(), 30, cursor)
		if err != nil {
			break
		}
		if !hasMore {
			break
		}
		cursor = nextCursor
	}
}

Error Handling

go-notion declares error codes . You can compare error code to confirm which error occurred.

package main

import (
	"context"
	"fmt"

	"github.com/sorcererxw/go-notion"
)

func main() {
	user, err := client.RetrieveUser(context.Background(), "user_id")
	if err, ok := notion.AsError(err); ok {
		switch err.Code {
		case notion.ErrCodeRateLimited:
			fmt.Println("rate limited")
		}
	}
}

Reverse Proxy

If you cannot access Notion server in your region(e.g. China) directly, you can use reverse proxy to solve the problem:

package main

import "github.com/sorcererxw/go-notion"

const proxyEndpoint = "https://1.1.1.1/notion"

func main() {
  client := notion.NewClient(notion.Settings{
      Token: "token",
      Endpoint: proxyEndpoint,
  })
}

OAuth

package main

import "net/http"

func main() {
  client := notion.NewOAuthClient("client_id", "client_secret", "redirect_uri")

  mux := http.NewServeMux()
  mux.HandleFunc("/oauth", func(w http.ResponseWriter, r *http.Request) {
    code := r.URL.Query().Get("code")
    token, _ := client.ExchangeAccessToken(r.Context(), code)
    
    // store token to db ...
    
    w.WriteHeader(http.StatusOK)
  })
}

License

go-notion is distributed under MIT.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].