返回顶部
n

notionNotion API

Notion API for creating and managing pages, databases, and blocks.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
104
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

notion

notion

使用Notion API创建/读取/更新页面、数据源(数据库)和块。

设置

  1. 1. 在 https://notion.so/my-integrations 创建一个集成
  2. 复制API密钥(以ntn或secret开头)
  3. 存储密钥:
bash mkdir -p ~/.config/notion echo ntnyourkeyhere > ~/.config/notion/apikey
  1. 4. 将目标页面/数据库与您的集成共享(点击... → 连接到 → 您的集成名称)

API基础

所有请求都需要:
bash
NOTIONKEY=$(cat ~/.config/notion/apikey)
curl -X GET https://api.notion.com/v1/... \
-H Authorization: Bearer $NOTION_KEY \
-H Notion-Version: 2025-09-03 \
-H Content-Type: application/json

注意: Notion-Version头部是必需的。本技能使用2025-09-03(最新版本)。在此版本中,数据库在API中被称为数据源。

常用操作

搜索页面和数据源:
bash
curl -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: page title}

获取页面:
bash
curl https://api.notion.com/v1/pages/{page_id} \
-H Authorization: Bearer $NOTION_KEY \
-H Notion-Version: 2025-09-03

获取页面内容(块):
bash
curl https://api.notion.com/v1/blocks/{page_id}/children \
-H Authorization: Bearer $NOTION_KEY \
-H Notion-Version: 2025-09-03

在数据源中创建页面:
bash
curl -X POST https://api.notion.com/v1/pages \
-H Authorization: Bearer $NOTION_KEY \
-H Notion-Version: 2025-09-03 \
-H Content-Type: application/json \
-d {
parent: {database_id: xxx},
properties: {
Name: {title: [{text: {content: New Item}}]},
Status: {select: {name: Todo}}
}
}

查询数据源(数据库):
bash
curl -X POST https://api.notion.com/v1/datasources/{datasource_id}/query \
-H Authorization: Bearer $NOTION_KEY \
-H Notion-Version: 2025-09-03 \
-H Content-Type: application/json \
-d {
filter: {property: Status, select: {equals: Active}},
sorts: [{property: Date, direction: descending}]
}

创建数据源(数据库):
bash
curl -X POST https://api.notion.com/v1/data_sources \
-H Authorization: Bearer $NOTION_KEY \
-H Notion-Version: 2025-09-03 \
-H Content-Type: application/json \
-d {
parent: {page_id: xxx},
title: [{text: {content: My Database}}],
properties: {
Name: {title: {}},
Status: {select: {options: [{name: Todo}, {name: Done}]}},
Date: {date: {}}
}
}

更新页面属性:
bash
curl -X PATCH https://api.notion.com/v1/pages/{page_id} \
-H Authorization: Bearer $NOTION_KEY \
-H Notion-Version: 2025-09-03 \
-H Content-Type: application/json \
-d {properties: {Status: {select: {name: Done}}}}

向页面添加块:
bash
curl -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: Hello}}]}}
]
}

属性类型

数据库项的常见属性格式:

  • - 标题: {title: [{text: {content: ...}}]}
  • 富文本: {richtext: [{text: {content: ...}}]}
  • 选择: {select: {name: Option}}
  • 多选: {multiselect: [{name: A}, {name: B}]}
  • 日期: {date: {start: 2024-01-15, end: 2024-01-16}}
  • 复选框: {checkbox: true}
  • 数字: {number: 42}
  • URL: {url: https://...}
  • 邮箱: {email: a@b.com}
  • 关联: {relation: [{id: page_id}]}

2025-09-03版本的主要区别

  • - 数据库 → 数据源: 使用/datasources/端点进行查询和检索
  • 两个ID: 每个数据库现在同时拥有databaseid和datasourceid
- 创建页面时使用databaseid(parent: {databaseid: ...}) - 查询时使用datasourceid(POST /v1/data_sources/{id}/query)
  • - 搜索结果: 数据库以object: datasource形式返回,附带其datasourceid
  • 响应中的父级: 页面显示parent.datasourceid以及parent.databaseid
  • 查找datasourceid: 搜索数据库,或调用GET /v1/datasources/{datasource_id}

备注

  • - 页面/数据库ID是UUID(带或不带连字符)
  • API无法设置数据库视图过滤器——这仅限UI操作
  • 速率限制:约3个请求/秒的平均值
  • 创建数据源时使用is_inline: true可将其嵌入页面中

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 korta-notion-1775705832 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 korta-notion-1775705832 技能

通过命令行安装

skillhub install korta-notion-1775705832

下载

⬇ 下载 notion v1.0.0(免费)

文件大小: 2.23 KB | 发布时间: 2026-4-11 22:57

v1.0.0 最新 2026-4-11 22:57
Initial release of Notion API skill.

- Provides setup instructions to connect Notion integrations using API keys.
- Supports creating, reading, and updating pages, data sources (databases), and blocks.
- Documents examples for searching, querying, and manipulating Notion content via cURL.
- Explains changes in the 2025-09-03 Notion API: "databases" are now called "data sources".
- Lists supported property types and outlines key API usage notes.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部