Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计异常

notion-sdkNotion SDK 搜索

Agent Skill

用于处理 Notion 页面、数据库、工作区内容和结构化记录。它适合让 Agent 查询知识库、整理页面内容、创建记录或把外部信息同步到 Notion。使用时需要确认集成是否已被授权到目标页面或数据库,并区分读取、追加和覆盖更新;涉及批量写入或修改数据库属性时,应先核对字段名称、属性类型和目标页面。

总安装

2,093

周安装

89

GitHub Stars

38

下载量

733
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:notion-sdk(Notion SDK 搜索)
来源仓库:https://github.com/terrylica/cc-skills
仓库路径:skills/notion-sdk
安装命令:
npx skills add https://github.com/terrylica/cc-skills --skill notion-sdk
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/terrylica/cc-skills --skill notion-sdk

简介

用于处理 Notion 页面、数据库、工作区内容和结构化记录。

  • 适合让 Agent 查询知识库、整理页面内容、创建记录或把外部信息同步到 Notion。
  • 使用时需要确认集成是否已被授权到目标页面或数据库,并区分读取、追加和覆盖更新。
  • 安装命令:npx skills add https://github.com/terrylica/cc-skills --skill notion-sdk。
  • 涉及批量写入或修改数据库属性时,应先核对字段名称、属性类型和目标页面。

SKILL.md

Notion SDK Skill

Control Notion programmatically using the official notion-client Python SDK. See PyPI for current version.

Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

When to Use This Skill

Use this skill when:

  • Creating pages or databases in Notion via API
  • Querying Notion databases programmatically
  • Adding blocks (text, code, headings) to Notion pages
  • Automating Notion workflows with Python
  • Integrating external data sources with Notion

Preflight: Token Collection

Before any Notion API operation, collect the integration token:

AskUserQuestion(questions=[{
    "question": "Please provide your Notion Integration Token (starts with ntn_ or secret_)",
    "header": "Notion Token",
    "options": [
        {"label": "I have a token ready", "description": "Token from notion.so/my-integrations"},
        {"label": "Need to create one", "description": "Go to notion.so/my-integrations → New integration"}
    ],
    "multiSelect": false
}])

After user provides token:

  1. Validate format (must start with ntn_ or secret_)
  2. Test with validate_token() from scripts/notion_wrapper.py
  3. Remind user: Each page/database must be shared with the integration

Quick Start

1. Create a Page in Database

from notion_client import Client
from scripts.create_page import (
    create_database_page,
    title_property,
    status_property,
    date_property,
)

client = Client(auth="ntn_...")
page = create_database_page(
    client,
    data_source_id="abc123...",  # Database ID
    properties={
        "Name": title_property("My New Task"),
        "Status": status_property("In Progress"),
        "Due Date": date_property("2025-12-31"),
    }
)
print(f"Created: {page['url']}")

2. Add Content Blocks

from scripts.add_blocks import (
    append_blocks,
    heading,
    paragraph,
    bullet,
    code_block,
    callout,
)

blocks = [
    heading("Overview", level=2),
    paragraph("This page was created via the Notion API."),
    callout("Remember to share the page with your integration!", emoji="⚠️"),
    heading("Tasks", level=3),
    bullet("First task"),
    bullet("Second task"),
    code_block("print('Hello, Notion!')", language="python"),
]
append_blocks(client, page["id"], blocks)

3. Query Database

from scripts.query_database import (
    query_data_source,
    checkbox_filter,
    status_filter,
    and_filter,
    sort_by_property,
)

# Find incomplete high-priority items
results = query_data_source(
    client,
    data_source_id="abc123...",
    filter_obj=and_filter(
        checkbox_filter("Done", False),
        status_filter("Priority", "High")
    ),
    sorts=[sort_by_property("Due Date", "ascending")]
)
for page in results:
    title = page["properties"]["Name"]["title"][0]["plain_text"]
    print(f"- {title}")

Available Scripts

ScriptPurpose
notion_wrapper.pyClient setup, token validation, retry wrapper
create_page.pyCreate pages, property builders
add_blocks.pyAppend blocks, block type builders
query_database.pyQuery, filter, sort, search

References

Important Constraints

Rate Limits

  • 3 requests/second average (burst tolerated briefly)
  • Use api_call_with_retry() for automatic rate limit handling
  • 429 responses include Retry-After header

Authentication Model

  • Page-level sharing required (not workspace-wide)
  • User must explicitly add integration to each page/database:

- Page →... menu → Connections → Add connection → Select integration

API Version (v2.6.0+)

  • Uses data_source_id instead of database_id for multi-source databases
  • Legacy database_id still works for simple databases
  • Scripts handle both patterns automatically

Operations NOT Supported

  • Workspace settings modification
  • User permissions management
  • Template creation/management
  • Billing/subscription access

API Behavior Patterns

Insights discovered through integration testing (test citations for verification).

Rate Limiting & Retry Logic

api_call_with_retry() handles transient failures automatically:

Error TypeBehaviorWait Strategy
429 Rate LimitedRetriesRespects Retry-After header (default 1s)
500 Server ErrorRetriesExponential backoff: 1s, 2s, 4s
Auth/ValidationFails immediatelyNo retry

*Citation: test_client.py::TestRetryLogic (lines 146-193)*

Read-After-Write Consistency

Newly created blocks may not be immediately queryable. Add 0.5s minimum delay:

append_blocks(client, page_id, blocks)
time.sleep(0.5)  # Eventual consistency delay
children = client.blocks.children.list(page_id)

*Citation: test_integration.py::TestBlockAppend::test_retrieve_appended_blocks (line 298)*

v2.6.0 API Migration

Old PatternNew Pattern (v2.6.0+)
client.databases.query()client.data_sources.query()
filter: {"value": "database"}filter: {"value": "data_source"}

*Citation: test_integration.py::TestDatabaseQuery (line 110)*

Archive-Only Deletion

Pages cannot be permanently deleted via API - only archived (moved to trash):

client.pages.update(page_id, archived=True)  # Trash, not delete

*Citation: test_integration.py cleanup fixture (lines 72-76)*

Edge Cases & Validation

Property Builder Edge Cases

InputBehaviorValid?
Empty string ""Creates empty contentYes
Empty array []Clears multi-select/relationsYes
None for numberClears property valueYes
Zero 0Valid number (not falsy)Yes
Negative -42Valid numberYes
Unicode/emojiFully preservedYes

*Citation: test_property_builders.py::TestPropertyBuildersEdgeCases (lines 302-341)*

Input Validation Responsibility

Builders are intentionally permissive - validation happens at API level:

PropertyBuilder AcceptsAPI Validates
DateAny stringISO 8601 only
URLAny stringValid URL format
CheckboxTruthy valuesBoolean expected

Best Practice: Validate in your application before building properties.

*Citation: test_property_builders.py::TestPropertyBuildersInvalidInputs (lines 347-376)*

Token Validation

  • Case-sensitive: Only lowercase ntn_ and secret_ valid
  • Format check happens before API call (saves unnecessary requests)
  • Empty/whitespace tokens rejected immediately

*Citation: test_client.py::TestClientEdgeCases (lines 196-224)*

Query & Filter Patterns

Compound Filter Composition

# Empty compound (matches all)
and_filter()  # {"and": []}

# Deep nesting supported
and_filter(
    or_filter(filter_a, filter_b),
    and_filter(filter_c, filter_d)
)

*Citation: test_filter_builders.py::TestFilterEdgeCases (lines 323-360)*

Filter Limitations

Filters don't exclude NULL properties - check in Python:

if row["properties"]["Rating"]["number"] is not None:
    # Process non-null values

*Citation: test_integration.py::TestDatabaseQuery::test_query_database_with_filter (lines 120-135)*

Pagination Invariants

Conditionhas_morenext_cursor
More results existTruePresent, non-None
No more resultsFalseMay be absent/None

Always check has_more before using next_cursor.

*Citation: test_integration.py::TestDatabaseQuery::test_query_database_with_pagination (lines 137-151)*

Error Handling

from notion_client import APIResponseError, APIErrorCode

try:
    result = client.pages.create(...)
except APIResponseError as e:
    if e.code == APIErrorCode.ObjectNotFound:
        print("Page/database not found or not shared with integration")
    elif e.code == APIErrorCode.Unauthorized:
        print("Token invalid or expired")
    elif e.code == APIErrorCode.RateLimited:
        print(f"Rate limited. Retry after {e.additional_data.get('retry_after')}s")
    else:
        raise

Installation

uv pip install notion-client  # v2.6+ required for data_source support

Or use PEP 723 inline dependencies (scripts include them).


Troubleshooting

IssueCauseSolution
Object not foundPage not shared with integrationShare page:... menu → Connections → Add integration
UnauthorizedToken invalid or expiredGenerate new token at notion.so/my-integrations
Rate limited (429)Too many requestsUse api_call_with_retry() for automatic handling
Empty results from queryFilter matches nothingVerify filter syntax and property names
Block not found after createEventual consistency delayAdd 0.5s delay after write before read
Invalid property typeWrong builder usedCheck property type in database schema
Token format rejectedWrong prefix (case-sensitive)Token must start with ntn_ or secret_ (lowercase)
Data source ID not workingOld API versionUpgrade notion-client to latest version

Post-Execution Reflection

After this skill completes, check before closing:

  1. Did the command succeed? — If not, fix the instruction or error table that caused the failure.
  2. Did parameters or output change? — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
  3. Was a workaround needed? — If you had to improvise (different flags, extra steps), update this SKILL.md so the next invocation doesn't need the same workaround.

Only update if the issue is real and reproducible — not speculative.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.84%
按下载量换算219

OpenCode

21.86%
按下载量换算160

Antigravity

17.1%
按下载量换算125

Gemini CLI

12.69%
按下载量换算93

trae

7.98%
按下载量换算58

Cursor

3.15%
按下载量换算23

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills