本日、Notion APIのβ版がリリースされたので早速Getting Startedを試してみました。

Start building with the Notion API
Connect Notion pages and databases to the tools you use every day, creating powerful workflows.
動画も使った丁寧な説明ページとなっているで特に難しいところなく、実行できました。シークレットトークンつけてJSONで送受信する単純でわかりやすい仕様。
ac-mini notionAPI % curl -X POST https://api.notion.com/v1/pages \
# 送信データ
-H "Authorization: Bearer **************************" \
-H "Content-Type: application/json" \
-H "Notion-Version: 2021-05-13" \
--data '{
"parent": { "database_id": "****************************" },
"properties": {
"Name": {
"title": [
{
"text": {
"content": "Yurts in Big Sur, California"
}
}
]
}
}
}'
# 受信データ
{
"object": "page",
"id": "a87defc7-49b7-49a4-b882-934dbe98ae4d",
"created_time": "2021-05-14T12:15:27.315Z",
"last_edited_time": "2021-05-14T12:15:27.315Z",
"parent": {
"type": "database_id",
"database_id": "31f642ac-4509-428a-b1d1-9074dfc3c8c1"
},
"archived": false,
"properties": {
"Name": {
"id": "title",
"type": "title",
"title": [
{
"type": "text",
"text": {
"content": "Yurts in Big Sur, California",
"link": null
},
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "Yurts in Big Sur, California",
"href": null
}
]
}
}
}
API Referenceも丁寧で、各APIのCurlサンプルコードがついているのですぐ試せます。
(例)Retrieve a database
curl 'https://api.notion.com/v1/databases/668d797c-76fa-4934-9b05-ad288df2d136' \
-H 'Authorization: Bearer '"$NOTION_API_KEY"'' \
-H 'Notion-Version: 2021-05-13'
データベース代わりに使えることを期待してしばらく色々と触ってみるつもりです。
※追記
バックエンドにNotionAPI+Notionを使ったアプリをリリースしました。
コメント