Notion DB Skill
Notion APIのquery database/query data sourceでページを複数件取得し、update pageでitem更新、get markdownでページコンテンツをMarkdown取得する。
認証
| 環境変数 | 用途 |
|---|---|
CLAUDE_NOTION_TOKEN | Notion Integration Token |
NOTION_VERSION | 任意。未指定時は 2022-06-28 |
使用方法
取得(既存挙動)
基本(最大50件取得)
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py \
--database-id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
--max-items 50
最新API(Data Source)を使う場合
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py \
--data-source-id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
--max-items 50
フィルター指定(JSON文字列)
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py \
--database-id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
--filter '{"property":"Status","status":{"equals":"Done"}}' \
--max-items 100
フィルター指定(JSONファイル)
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py \
--database-id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
--filter-file ./filter.json \
--sorts-file ./sorts.json
途中カーソルから再開
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py \
--database-id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
--start-cursor "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
更新(itemのプロパティ更新)
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py update-page \
--page-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
--properties '{"Status":{"status":{"name":"In progress"}}}'
更新(JSONファイルで更新)
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py update-page \
--page-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
--properties-file ./properties.json
Markdown取得(ページコンテンツをMarkdownで取得)
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py get-markdown \
--page-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Markdown取得(会議ノートのトランスクリプト込み)
python3 ${CLAUDE_PLUGIN_ROOT}/skills/notion-db/scripts/notion_db.py get-markdown \
--page-id "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
--include-transcript
注意:
get-markdownは Notion API2025-09-03を自動的に使用します(--notion-versionの指定は不要)。
出力
JSONを標準出力する。主なキー:
action:queryまたはupdate-pagecount: 取得件数has_more: 続きがあるかnext_cursor: 次ページ取得に使うカーソルtarget_type:databaseまたはdata-sourcetarget_id: クエリ対象IDresults: Notionページ配列page: 更新後ページ(update-pageの場合)markdown: ページコンテンツのMarkdown文字列(get-markdownの場合)truncated: コンテンツが切り詰められたか(get-markdownの場合)unknown_block_ids: 未知ブロックID配列(get-markdownの場合)
--compact を使うと id/url/created_time/last_edited_time/properties のみを返す。
参考
- 公式(Database): https://developers.notion.com/reference/post-database-query
- 公式(Data Source): https://developers.notion.com/reference/query-a-data-source
- 公式(Update Page): https://developers.notion.com/reference/patch-page
- 公式(Retrieve Page Markdown): https://developers.notion.com/reference/retrieve-page-markdown
- フィルター例: references/filter_examples.md
- 更新例: references/update_examples.md