1
0
mirror of https://github.com/dstotijn/go-notion.git synced 2025-06-15 00:05:04 +02:00

Update README

This commit is contained in:
David Stotijn
2022-09-07 22:16:39 +02:00
parent ce521c80bd
commit bf5c41b906

120
README.md
View File

@ -1,12 +1,15 @@
# go-notion # go-notion
[![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/dstotijn/go-notion?label=go%20module)](https://github.com/dstotijn/go-notion/tags) [![GitHub tag (latest
[![Go Reference](https://pkg.go.dev/badge/github.com/dstotijn/go-notion.svg)](https://pkg.go.dev/github.com/dstotijn/go-notion) SemVer)](https://img.shields.io/github/v/tag/dstotijn/go-notion?label=go%20module)](https://github.com/dstotijn/go-notion/tags)
[![Go
Reference](https://pkg.go.dev/badge/github.com/dstotijn/go-notion.svg)](https://pkg.go.dev/github.com/dstotijn/go-notion)
[![GitHub](https://img.shields.io/github/license/dstotijn/go-notion)](LICENSE) [![GitHub](https://img.shields.io/github/license/dstotijn/go-notion)](LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/dstotijn/go-notion)](https://goreportcard.com/report/github.com/dstotijn/go-notion) [![Go Report
Card](https://goreportcard.com/badge/github.com/dstotijn/go-notion)](https://goreportcard.com/report/github.com/dstotijn/go-notion)
**go-notion** is a client for the **go-notion** is a client for the [Notion
[Notion API](https://developers.notion.com/reference), written in API](https://developers.notion.com/reference), written in
[Go](https://golang.org/). [Go](https://golang.org/).
## Features ## Features
@ -14,42 +17,72 @@
The client supports all (non-deprecated) endpoints available in the Notion API, The client supports all (non-deprecated) endpoints available in the Notion API,
as of September 4, 2022: as of September 4, 2022:
### Databases <details>
<summary>Databases</summary>
- [x] [Query a database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.QueryDatabase) - [x] [Query a
- [x] [Create a database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.CreateDatabase) database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.QueryDatabase)
- [x] [Update database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.UpdateDatabase) - [x] [Create a
- [x] [Retrieve a database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindDatabaseByID) database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.CreateDatabase)
- [x] [Update
database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.UpdateDatabase)
- [x] [Retrieve a
database](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindDatabaseByID)
</details>
### Pages <details>
<summary>Pages</summary>
- [x] [Retrieve a page](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindPageByID) - [x] [Retrieve a
- [x] [Create a page](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.CreatePage) page](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindPageByID)
- [x] [Update page](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.UpdatePage) - [x] [Create a
- [x] [Retrieve a page property](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindPagePropertyByID) page](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.CreatePage)
- [x] [Update
page](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.UpdatePage)
- [x] [Retrieve a page
property](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindPagePropertyByID)
</details>
### Blocks <details>
<summary>Blocks</summary>
- [x] [Retrieve a block](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindBlockByID) - [x] [Retrieve a
- [x] [Update block](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.UpdateBlock) block](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindBlockByID)
- [x] [Retrieve block children](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindBlockChildrenByID) - [x] [Update
- [x] [Append block children](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.AppendBlockChildren) block](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.UpdateBlock)
- [x] [Delete block](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.DeleteBlock) - [x] [Retrieve block
children](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindBlockChildrenByID)
- [x] [Append block
children](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.AppendBlockChildren)
- [x] [Delete
block](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.DeleteBlock)
</details>
### Users <details>
<summary>Users</summary>
- [x] [Retrieve a user](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindUserByID) - [x] [Retrieve a
- [x] [List all users](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.ListUsers) user](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindUserByID)
- [x] [Retrieve your token's bot user](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindCurrentUser) - [x] [List all
users](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.ListUsers)
- [x] [Retrieve your token's bot
user](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindCurrentUser)
</details>
### Search <details>
<summary>Search</summary>
- [x] [Search](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.Search) - [x] [Search](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.Search)
</details>
### Comments <details>
<summary>Comments</summary>
- [x] [Retrieve comments](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindCommentsByBlockID) - [x] [Retrieve
- [x] [Create a comment](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.CreateComment) comments](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.FindCommentsByBlockID)
- [x] [Create a
comment](https://pkg.go.dev/github.com/dstotijn/go-notion#Client.CreateComment)
</details>
## Installation ## Installation
@ -57,13 +90,10 @@ as of September 4, 2022:
$ go get github.com/dstotijn/go-notion $ go get github.com/dstotijn/go-notion
``` ```
## Getting started ## Usage
To obtain an API key, follow Notion’s [getting started guide](https://developers.notion.com/docs/getting-started). To obtain an API key, follow Notion’s [getting started
guide](https://developers.notion.com/docs/getting-started).
### Code example
First, construct a new `Client`:
```go ```go
import "github.com/dstotijn/go-notion" import "github.com/dstotijn/go-notion"
@ -71,12 +101,7 @@ import "github.com/dstotijn/go-notion"
(...) (...)
client := notion.NewClient("secret-api-key") client := notion.NewClient("secret-api-key")
```
Then, use the methods defined on `Client` to make requests to the API. For
example:
```go
page, err := client.FindPageByID(context.Background(), "18d35eb5-91f1-4dcb-85b0-c340fd965015") page, err := client.FindPageByID(context.Background(), "18d35eb5-91f1-4dcb-85b0-c340fd965015")
if err != nil { if err != nil {
// Handle error... // Handle error...
@ -85,17 +110,22 @@ if err != nil {
👉 Check out the docs on 👉 Check out the docs on
[pkg.go.dev](https://pkg.go.dev/github.com/dstotijn/go-notion) for a complete [pkg.go.dev](https://pkg.go.dev/github.com/dstotijn/go-notion) for a complete
reference, and the [examples](/examples) directory for more example code. reference and the [examples](/examples) directory for more example code.
## Status ## Status
The Notion API is currently in _public beta_. The Notion API itself is out of beta. This library is updated periodically
following documented changes from the Notion
[changelog](https://developers.notion.com/changelog).
⚠️ Although the API itself is versioned, this client **will** make breaking **Note:** This library **will** make breaking changes in its code until
changes in its code until `v1.0` of the module is released. `v1.0` of the module is released. There are no immediate plans for a `v1.0`
release. I want the design choices to be solidified and battle-tested more
before committing to a stable release (and the possible burden of a "v2+" Go
module should I want to introduce breaking changes).
## License ## License
[MIT License](LICENSE) [MIT License](LICENSE)
© 2021 [David Stotijn](https://v0x.nl) © 2022 [David Stotijn](https://v0x.nl)