详细分析 ▾
- 验证GitHub仓库并审查其代码(npm install/build运行任意JavaScript)。
- 优先使用--api-key选项进行一次性运行,而不是将密钥永久存储在shell rc文件中,并创建具有最小权限的作用域Notion集成。
- 如果您期望技能是自包含的,询问发布者为什么注册表元数据不声明NOTION_API_KEY。
- 如果您不能或不会审查仓库,考虑使用官方Notion SDK或明确声明所需凭证和安装机制的技能。
运行时依赖
版本
Notion API的生产级CLI,支持以多种输出格式(JSON、表格、CSV)搜索、创建和管理页面、数据库、块、用户和评论。基于 https://github.com/FroeMic/notion-cli
安装命令 点击复制
技能文档
notion-cli Interact with your Notion workspace via the notion-cli.
A production-grade CLI for the Notion API that supports searching, creating and managing pages, databases, blocks, users, and comments with multiple output formats (JSON, table, CSV).
Install Clone and install the CLI:
git clone https://github.com/FroeMic/notion-cli
cd notion-cli
npm install
npm run build
npm link
Set NOTION_API_KEY environment variable:
- 创建 integration 在 https://www.notion.所以/个人资料/integrations
- 复制 Internal Integration Secret (starts 带有
ntn_或secret_) - 分享 任何 pages/databases 您 want 到 access 带有 integration
- Recommended: 添加 到
~/.claude/.env对于 Claude Code - Alternative: 添加 到
~/.bashrc或~/.zshrc:导出 NOTION_API_KEY="-api-键"
Optional: Set NOTION_DEBUG=true for verbose request/response logging.
Repository: https://github.com/FroeMic/notion-cli
Commands Search across your workspace:
notion search [query] # Search pages, databases, and data sources
notion search [query] --filter page # Search only pages
notion search [query] --filter database # Search only databases
notion search [query] --sort ascending # Sort by last edited time
Work with pages:
notion pages get # Get page details
notion pages create --parent --title # Create a new page
notion pages update --properties # Update page properties
notion pages archive # Archive a page
notion pages restore # Restore an archived page
notion pages property # Get a specific property value
Work with databases:
notion databases get # Get database schema
notion databases create --parent --title # Create a database
notion databases update --title # Update database metadata
notion databases query # Query records in a data source
notion databases query --filter # Query with filters
notion databases query --sort # Query with sorting
Work with blocks (page content):
notion blocks get # Get a block
notion blocks children # List child blocks
notion blocks append --content # Append new blocks
notion blocks update --content # Update a block
notion blocks delete # Delete a block
Work with users:
notion users list # List workspace members
notion users get # Get user details
notion users me # Get the authenticated bot user
Work with comments:
notion comments list --block # List comments on a block
notion comments create --page --content # Add a comment to a page
Global options (available on all commands):
--api-key # Override NOTION_API_KEY env var
-f, --format # Output format: json (default), table, csv
--limit # Max results to return
--cursor # Pagination cursor
Key Concepts
| Concept | Purpose | Example |
|---|---|---|
| Pages | Individual Notion pages | A meeting note, a project brief |
| Databases | Structured collections of pages | A task tracker, a CRM table |
| Data Sources | Individual tables within a database | A specific view/table in a database |
| Blocks | Content elements within a page | Paragraphs, headings, lists, code blocks |
| Properties | Typed fields on database pages | Title, status, date, select, relation |
| Users | Workspace members and integrations | Team members, bot integrations |
| Comments | Discussion threads on pages/blocks | Feedback, review notes |
- Base URL:
https://api.notion.com/v1 - API Version:
2022-06-28 - Auth:
Authorization: Bearer $NOTION_API_KEY - Rate Limits: Automatic 重试 带有 exponential backoff (up 到 3 retries)
Common API Operations Search for a page:
curl -X POST https://api.notion.com/v1/search \
-H "Authorization: Bearer $NOTION_API_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"query": "Meeting Notes", "filter": {"value": "page", "property": "object"}}'
Query a database with filters:
curl -X POST https://api.notion.com/v1/databases//query \
-H "Authorization: Bearer $NOTION_API_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"filter": {"property": "Status", "status": {"equals": "In Progress"}}}'
Create a page in a database:
curl -X POST https://api.notion.com/v1/pages \
-H "Authorization: Bearer $NOTION_API_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"parent": {"database_id": ""}, "properties": {"Name": {"title": [{"text": {"content": "New Task"}}]}}}'
Append content to a page:
curl -X PATCH https://api.notion.com/v1/blocks//children \
-H "Authorization: Bearer $NOTION_API_KEY" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d '{"children": [{"object": "block", "type": "paragraph", "paragraph": {"rich_text": [{"type": "text", "text": {"content": "Hello world"}}]}}]}'
Notes
- integration 必须 explicitly shared 带有 每个 page 或 数据库 您 want 到 access (通过 Notion UI: ... 菜单 > Connections > 添加 integration).
- Pages 可以 accept IDs 作为 UUIDs 或 Notion URLs — CLI 将 解析 both formats.
- 所有 列表 endpoints support cursor-based 分页 通过
--limit和--cursor. - 输出 格式 可以 设置 到
json(默认),表, 或csv带有-f标志. - 属性 types include: title, rich_text, 数字, select, multi_select, status, 日期, people, files, checkbox, url, email, phone_number, relation, rollup, formula, 和 时间戳 fields.
Files 1 total
- SKILL.md ( file)
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制