← 返回
开发者工具 Key 中文

Notion CLI – Command Line Interface based access to Notion for your agent

Access and manage your Notion workspace via a CLI to search, create, update, and delete pages, databases, blocks, users, and comments with multiple output fo...
{ "answer": "通过命令行访问和管理 Notion 工作区,支持搜索、创建、更新和删除页面、数据库、块、用户及评论,并提供多种输出格式。" }
froemic
开发者工具 clawhub v1.0.0 1 版本 99396.2 Key: 需要
★ 2
Stars
📥 3,417
下载
💾 148
安装
1
版本
#latest

概述

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:

  1. Create an integration at https://www.notion.so/profile/integrations
  2. Copy the Internal Integration Secret (starts with ntn_ or secret_)
  3. Share any pages/databases you want to access with the integration
    • Recommended: Add to ~/.claude/.env for Claude Code
    • Alternative: Add to ~/.bashrc or ~/.zshrc: export NOTION_API_KEY="your-api-key"

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 <page-id>                             # Get page details
notion pages create --parent <id> --title <text>       # Create a new page
notion pages update <page-id> --properties <json>      # Update page properties
notion pages archive <page-id>                         # Archive a page
notion pages restore <page-id>                         # Restore an archived page
notion pages property <page-id> <property-id>          # Get a specific property value

Work with databases:

notion databases get <database-id>                     # Get database schema
notion databases create --parent <id> --title <text>   # Create a database
notion databases update <database-id> --title <text>   # Update database metadata
notion databases query <data-source-id>                # Query records in a data source
notion databases query <id> --filter <json>            # Query with filters
notion databases query <id> --sort <json>              # Query with sorting

Work with blocks (page content):

notion blocks get <block-id>                           # Get a block
notion blocks children <block-id>                      # List child blocks
notion blocks append <block-id> --content <json>       # Append new blocks
notion blocks update <block-id> --content <json>       # Update a block
notion blocks delete <block-id>                        # Delete a block

Work with users:

notion users list                                      # List workspace members
notion users get <user-id>                             # Get user details
notion users me                                        # Get the authenticated bot user

Work with comments:

notion comments list --block <block-id>                # List comments on a block
notion comments create --page <page-id> --content <text>  # Add a comment to a page

Global options (available on all commands):

--api-key <key>                                        # Override NOTION_API_KEY env var
-f, --format <fmt>                                     # Output format: json (default), table, csv
--limit <n>                                            # Max results to return
--cursor <cursor>                                      # Pagination cursor

Key Concepts

ConceptPurposeExample
---------------------------------------------------------------------------------------------
PagesIndividual Notion pagesA meeting note, a project brief
DatabasesStructured collections of pagesA task tracker, a CRM table
Data SourcesIndividual tables within a databaseA specific view/table in a database
BlocksContent elements within a pageParagraphs, headings, lists, code blocks
PropertiesTyped fields on database pagesTitle, status, date, select, relation
UsersWorkspace members and integrationsTeam members, bot integrations
CommentsDiscussion threads on pages/blocksFeedback, review notes

API Reference

  • Base URL: https://api.notion.com/v1
  • API Version: 2022-06-28
  • Auth: Authorization: Bearer $NOTION_API_KEY
  • Rate Limits: Automatic retry with exponential backoff (up to 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/<database-id>/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": "<database-id>"}, "properties": {"Name": {"title": [{"text": {"content": "New Task"}}]}}}'

Append content to a page:

curl -X PATCH https://api.notion.com/v1/blocks/<block-id>/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

  • The integration must be explicitly shared with each page or database you want to access (via Notion UI: ... menu > Connections > Add your integration).
  • Pages can accept IDs as UUIDs or Notion URLs — the CLI will parse both formats.
  • All list endpoints support cursor-based pagination via --limit and --cursor.
  • Output format can be set to json (default), table, or csv with the -f flag.
  • Property types include: title, rich_text, number, select, multi_select, status, date, people, files, checkbox, url, email, phone_number, relation, rollup, formula, and timestamp fields.

Files

1 total

  • SKILL.md (this file)

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-28 13:26 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 666 📥 323,797
developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 920 📥 185,727
developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 65 📥 179,847