

GitHub - kjk/notionapi: Unofficial Go API for https://notion.so
source link: https://github.com/kjk/notionapi
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
About notionapi
This is an unofficial, read-only Go API for https://notion.so
It allows you to retrieve content of a public Notion page in structured format.
You can then convert that format to HTML.
API docs: https://godoc.org/github.com/kjk/notionapi
You can learn how I reverse-engineered the API.
Real-life usage
I use this API to publish my blog. Notion is my CMS where I write and edit all content and I use a custom Go script which uses this library to convert Notion pages to HTML and publish the result to Netlify.
You can see the code at https://github.com/kjk/blog
Usage
This API only support public pages i.e. you have to share the page in Notion UI.
This is becacuse I didn't bother figuring out how to authenticate.
Then you have to know id of the page. It's the last part in Notion URL e.g. https://www.notion.so/Test-page-all-c969c9455d7c4dd79c7f860f3ace6429 has id c969c9455d7c4dd79c7f860f3ace6429
.
Then you can retrive the page content:
import ( "log" "github.com/kjk/notionapi" ) client := ¬ionapi.Client{} pageID := "c969c9455d7c4dd79c7f860f3ace6429" page, err := client.DownloadPage(pageID) if err != nil { log.Fatalf("DownloadPage() failed with %s\n", err) } // look at page.Page to see structured content
You can see a full example that adds recursive downloading of pages, caching etc. at https://github.com/kjk/blog/blob/master/notion_import.go
A page in notion is a tree of blocks of different types. See https://github.com/kjk/notionapi/blob/master/get_record_values.go#L31 for the definition.
To convert Notion page to HTML you can use https://github.com/kjk/blog/blob/master/notion_to_html.go as a template.
Recommend
-
13
teams-api An unofficial wrapper for the unofficial Microsoft Teams API Description This library (still work in progress) was created with the goal of helping the creation of alternative (and open source) Microsoft Tea...
-
17
Speakeasy JS – Reverse-engineering Notion's API (Travis Fischer) Back Search
-
5
Start building with the Notion API Connect Notion pages and databases to the tools you use every day, creating powerful workflows.
-
17
Notion 的 API 開放了 Hacker News Daily 上看到的:「Start building with the Notion API」,翻了一下
-
5
Matrix 首页推荐Matrix 是少数派的写作社区,我们主张分享真实的产品体验,有实用价值的经验与思考。我们会不定期挑选 Matrix 最优质的文章,展示来自用户的最真实的体验和观点。文章...
-
5
go-notion go-notion is a client for the Notion API, written in Go. Features The client supports all (non-depreca...
-
100
Unofficial TikTok API in Python This is an unofficial api wrapper for TikTok.com in python. With this api you are able to call most trending and fetch specific user information as well as much more. Sponsors (TikTokApi is fre...
-
5
Matrix 首页推荐Matrix 是少数派的写作社区,我们主张分享真实的产品体验,有实用价值的经验与思考。我们会不定期挑选 Matrix 最优质的文章,展示来自用户的最真实的体验和观点。文章代...
-
13
 PHP version of the official NOTION API. It works the same way as the reference JavaScript SDK 🎉
-
6
IntroductionNotion is a great tool for note-taking and managing your projects. After the introduction of Notion API, it becomes very easy for developers to make custom integration. Custom integration solves specific issu...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK