当前位置: 首页 > Skill >

MH notion

MH notion

MH notion

用于创建和管理页面、数据库及块的 Notion API。

1.0.0 2026.11.21 734
获取Skill文件查看使用说明
作 者:许安 许可证: 更新时间:2026.11.21
本文目录收起

notion

Use the Notion API to create/read/update pages, data sources (databases), and blocks.

Setup

  1. Create an integration at https://notion.so/my-integrations
  2. Copy the API key (starts with ntn_ or secret_)
  3. Store it:
mkdir -p ~/.config/notion
echo "ntn_your_key_here" > ~/.config/notion/api_key
  1. Share target pages/databases with your integration (click "..." → "Connect to" → your integration name)

API Basics

All requests need:

NOTION_KEY=$(cat ~/.config/notion/api_key)
curl -X GET "https://api.notion.com/v1/..." 
  -H "Authorization: Bearer $NOTION_KEY" 
  -H "Notion-Version: 2025-09-03" 
  -H "Content-Type: application/json"

Note: The Notion-Version header is required. This skill uses 2025-09-03 (latest). In this version, databases are called "data sources" in the API.

Common Operations

Search for pages and data sources:

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"}'

Get page:

curl "https://api.notion.com/v1/pages/{page_id}" 
  -H "Authorization: Bearer $NOTION_KEY" 
  -H "Notion-Version: 2025-09-03"

Get page content (blocks):

curl "https://api.notion.com/v1/blocks/{page_id}/children" 
  -H "Authorization: Bearer $NOTION_KEY" 
  -H "Notion-Version: 2025-09-03"

Create page in a data source:

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"}}
    }
  }'

Query a data source (database):

curl -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 '{
    "filter": {"property": "Status", "select": {"equals": "Active"}},
    "sorts": [{"property": "Date", "direction": "descending"}]
  }'

Create a data source (database):

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": {}}
    }
  }'

Update page properties:

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"}}}}'

Add blocks to page:

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"}}]}}
    ]
  }'

Property Types

Common property formats for database items:

  • 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", "end": "2024-01-16"}}
  • Checkbox: {"checkbox": true}
  • Number: {"number": 42}
  • URL: {"url": "https://..."}
  • Email: {"email": "a@b.com"}
  • Relation: {"relation": [{"id": "page_id"}]}

Key Differences in 2025-09-03

  • Databases → Data Sources: Use /data_sources/ endpoints for queries and retrieval
  • Two IDs: Each database now has both a database_id and a data_source_id
    • Use database_id when creating pages (parent: {"database_id": "..."})
    • Use data_source_id when querying (POST /v1/data_sources/{id}/query)
  • Search results: Databases return as "object": "data_source" with their data_source_id
  • Parent in responses: Pages show parent.data_source_id alongside parent.database_id
  • Finding the data_source_id: Search for the database, or call GET /v1/data_sources/{data_source_id}

Notes

  • Page/database IDs are UUIDs (with or without dashes)
  • The API cannot set database view filters — that's UI-only
  • Rate limit: ~3 requests/second average
  • Use is_inline: true when creating data sources to embed them in pages

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,016
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,004
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,002
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,001
PHP集成RabbitMQ实现消息队列的完整步骤

使用 php-amqplib 库,通过建立连接、声明交换机与队列并绑定,即可在 PHP 中实现消息的发送与消费。

2026.05.24 1,001
Apache开启.htaccess及使用方法详解

本文介绍如何在本地Apache环境中启用.htaccess文件,主要涉及修改httpd.conf中的AllowOverride参数。同时详细解析.htaccess的多种实用功能,包括自定义错误页面、目录密码保护、IP访问限制、URL自动转向、默认首页设置以及防止图片盗链等配置方法,并分析了使用.htaccess对服务器性能和安全性的潜在影响。

2026.05.09 1,001
Skill 文件

相关 Skill

更多
Korta Notion Korta Notion Notion API,用于创建和管理页面、数据库和区块
Notion 工作区同步代理 Notion 工作区同步代理 使用 Notion API v2022-06-28 在 Notion 数据库和外部工具之间双向同步项目数据。连接 Jira(REST API)、Linear(GraphQL)和 GitHub Issues 以实现统一的项目跟踪。
Notion 工作区同步引擎 Notion 工作区同步引擎 通过 Notion API 和 webhooks 将 Notion 数据库与外部工具双向同步。实时将页面属性映射到 Jira 问题、GitHub PR 和 Linear 工单。
Notion 协作管理 Notion 协作管理 Notion API 集成技能。创建和管理 Notion 页面、数据库和内容块。触发词:Notion、笔记管理、知识库、数据库管理。
Notion任务同步桥接器 Notion任务同步桥接器 使用 Notion API v2022-06-28 在 Notion 数据库和外部项目管理工具之间双向同步任务。处理属性映射、状态更新和关系字段。