name: notion description: Notion API for creating and managing pages, databases, and blocks. Also includes 想法點子庫(💡)持久化 workflow,當用戶說"入庫"、"記錄這個想法"、"這個先記下來"、"持久化這個"時觸發。 homepage: https://developers.notion.com metadata: {"clawdbot":{"emoji":"📝"}}
Use the Notion API to create/read/update pages, databases, and blocks.
mkdir -p ~/.config/notion
echo "ntn_your_key_here" > ~/.config/notion/api_key
Integration API key starts with ntn_ or secret_. Share target pages/databases with your integration (click "..." → "Connect to" → your integration name).
Critical: Wrong version = silent failures.
| Operation | Version | Why |
|---|---|---|
| Query data source | 2025-09-03 |
Newer endpoint |
| Search / Get page | 2025-09-03 |
Read operations |
| Create/update pages | 2022-06-28 |
More reliable for property writes |
| Create database | 2022-06-28 |
2025-09-03 silently drops custom properties |
| Update database schema | 2022-06-28 |
Same reason |
Always include Notion-Version header. Default in this skill: 2025-09-03.
NOTION_KEY=$(cat ~/.config/notion/api_key)
# Search
curl -s -X POST "https://api.notion.com/v1/search" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03" \
-H "Content-Type: application/json" \
-d '{"query": "keywords"}'
# Get page
curl -s "https://api.notion.com/v1/pages/{page_id}" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03"
# Query database (newer endpoint, use data_source_id)
curl -s -X POST "https://api.notion.com/v1/data_sources/{data_source_id}/query" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03" \
-H "Content-Type: application/json" \
-d '{"sorts": [{"property": "建立時間", "direction": "descending"}], "page_size": 20}'
# Create page (use database_id as parent, version 2022-06-28)
curl -s -X POST "https://api.notion.com/v1/pages" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"parent": {"database_id": "xxx"}, "properties": {"Name": {"title": [{"text": {"content": "Title"}}]}}}'
# Update page properties
curl -s -X PATCH "https://api.notion.com/v1/pages/{page_id}" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"properties": {"Status": {"select": {"name": "Done"}}}}'
Parse response (Python):
import subprocess, json
result = subprocess.run(['curl', '-s', ...], capture_output=True, text=True)
data = json.loads(result.stdout)
page_id = data.get('id')
error = data.get('message') # if 'object' == 'error'
資料庫 ID: 339d8e39-9e68-814b-8fc9-c06adfb3ae00
里程碑資料庫 ID: 339d8e39-9e68-8130-932c-ecf46af154b5
父頁面: Winnie (321d8e39-9e68-8037-9c2f-d55fd4e9a54c)
| 欄位 | 型別 | 說明 |
|---|---|---|
| 名稱 | title | 提純後的標題,≤20字 |
| 想法摘要 | rich_text | 核心內容摘要 |
| 決策結論 | rich_text | 最終結論或後續行動(暫無填"待定") |
| 來源 | select | 臨時想法 / 專案相關 / 系統討論 |
| 相關專案 | rich_text | 關聯專案,可空 |
| 標籤 | multi_select | 自由標籤 |
| 狀態 | select | 待實現 / 進行中 / 已規劃 / 執行中 / 已實現 / 已歸檔 |
| 規劃內容 | rich_text | 想法→計劃的推導過程(轉為"已規劃"時填寫) |
| 相關里程碑 | relation | 反向關聯里程碑條目 |
| 里程碑數 | number | 關聯里程碑計數 |
| 重要性 | select | 高 / 中 / 低 |
| 建立時間 | date | 訊息時間戳(ISO 格式) |
| 欄位 | 型別 |
|---|---|
| 里程碑標題 | title |
| 所屬想法 | relation → 想法點子庫 |
| 處理過程 | rich_text |
| 決策記錄 | rich_text |
| 產物連結 | url |
| 狀態 | select(進行中 / 已完成) |
| 建立時間 | date |
python3 ~/.openclaw/skills/notion/scripts/notion-write-idea.py create < idea.jsony 確認 → 才寫入 Notion不直接調 curl,統一走指令碼確保確認環節:
cat > /tmp/idea.json << 'EOF'
{
"名稱": "無頭伺服器網站登入解法",
"想法摘要": "agent-browser在無頭伺服器無法登入需驗證碼網站。解法:Cookie匯入、Xvfb虛擬顯示器、本地登入匯出session。",
"決策結論": "優先試方案1(Cookie匯入),最可行。",
"來源": "臨時想法",
"相關專案": "agent-browser",
"標籤": ["伺服器部署", "Cookie匯入"],
"狀態": "待實現",
"重要性": "中",
"建立時間": "2026-04-04T22:38:00+08:00"
}
EOF
python3 ~/.openclaw/skills/notion/scripts/notion-write-idea.py create < /tmp/idea.json
觸發詞: "轉計劃"、"開始規劃"、"這是個好想法"
page_id規劃內容欄位填入推導)cat > /tmp/milestone.json << 'EOF' { "里程碑標題": "方案1測試:Cookie匯入", "所屬想法ID": "想法頁面的page_id", "處理過程": "測試EditThisCookie匯出Chrome Cookie,匯入agent-browser", "決策記錄": "Cookie匯入可行,但B站登入態有效期僅24h,需定期重新整理", "產物連結": "https://github.com/...", "狀態": "進行中", "建立時間": "2026-04-05T13:00:00+08:00" } EOF python3 ~/.openclaw/skills/notion/scripts/notion-write-milestone.py create < /tmp/milestone.json7w4.net小蔥技能站,你的AI助手技能庫。
| 觸發詞 | 操作 |
|---|---|
| "已完成"/"已實現" | 狀態→已實現 |
| "歸檔"/"不要了" | 狀態→已歸檔 |
| "進行中" | 狀態→進行中 |
| "轉計劃"/"開始規劃" | 狀態→已規劃 + 填寫規劃內容 |
| "添加里程碑" | 在里程碑庫建立條目 |
curl -s -X POST "https://api.notion.com/v1/data_sources/339d8e39-9e68-814b-8fc9-c06adfb3ae00/query" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03" \
-H "Content-Type: application/json" \
-d '{"sorts": [{"property": "建立時間", "direction": "descending"}], "page_size": 20}'
curl -s -X POST "https://api.notion.com/v1/data_sources/339d8e39-9e68-8130-932c-ecf46af154b5/query" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03" \
-H "Content-Type: application/json" \
-d '{"filter": {"property": "所屬想法", "relation": {"contains": "想法page_id"}}}'
curl -s -X POST "https://api.notion.com/v1/search" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03" \
-H "Content-Type: application/json" \
-d '{"query": "keywords", "filter": {"value": "page", "property": "object"}}'
curl -s "https://api.notion.com/v1/pages/{page_id}" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03"
curl -s "https://api.notion.com/v1/blocks/{page_id}/children" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03"
curl -s -X POST "https://api.notion.com/v1/databases" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{
"parent": {"type": "page_id", "page_id": "xxx"},
"title": [{"text": {"content": "Database Title"}}],
"properties": {
"Name": {"title": {}},
"Status": {"select": {"options": [{"name": "Todo"}, {"name": "Done"}]}},
"Date": {"date": {}}
}
}'
curl -s -X PATCH "https://api.notion.com/v1/blocks/{page_id}/children" \
-H "Authorization: Bearer $NOTION_KEY" \
-H "Notion-Version: 2025-09-03" \
-H "Content-Type: application/json" \
-d '{"children": [{"object": "block", "type": "paragraph", "paragraph": {"rich_text": [{"text": {"content": "Text"}}]}}]}'
| Type | Format |
|---|---|
| Title | {"title": [{"text": {"content": "..."}}]} |
| Rich text | {"rich_text": [{"text": {"content": "..."}}]} |
| Select | {"select": {"name": "Option"}} |
| Multi-select | {"multi_select": [{"name": "A"}, {"name": "B"}]} |
| Date | {"date": {"start": "2024-01-15"}} |
| Checkbox | {"checkbox": true} |
| Number | {"number": 42} |
| URL | {"url": "https://..."} |
| Relation | {"relation": [{"id": "page_id"}]} |
/data_sources/ endpoint; create uses /databasesdatabase_id (for creating pages) and data_source_id (for querying)2022-06-28 works reliably — 2025-09-03 silently drops custom properties2022-06-28 is more predictableimport subprocess, json
def notion_req(method, endpoint, body=None, version="2025-09-03"):
key = open("/root/.config/notion/api_key").read().strip()
cmd = ["curl", "-s", "-X", method,
f"https://api.notion.com/v1/{endpoint}",
"-H", f"Authorization: Bearer {key}",
"-H", f"Notion-Version: {version}",
"-H", "Content-Type: application/json"]
if body:
import json
cmd += ["-d", json.dumps(body)]
r = subprocess.run(cmd, capture_output=True, text=True)
data = json.loads(r.stdout)
if data.get("object") == "error":
raise Exception(f"Notion API error {data.get('code')}: {data.get('message')}")
return data
Common error codes:
- object_not_found: 頁面/資料庫 ID 不存在或無權訪問
- validation_error: 屬性格式錯誤,檢查 property type 是否匹配
- restricted_resource: 頁面未分享給 integration
- rate_limited: 限速,等 1 秒重試
is_inline: true 可嵌入頁面這個 Notion 技能整體質量不錯,能夠幫助使用者將零散的想法和靈感系統化地記錄到 Notion 中。它的工作流設計很貼心——寫入前會先展示內容讓你確認,避免誤操作。主要缺點是配置不夠靈活,資料庫 ID 寫死在程式碼裡,改動起來比較麻煩;另外當操作失敗時,提示資訊有時不夠清晰。總體來說,這是一個上手簡單、功能實用的 Skill,適合經常需要整理創意的使用者使用。