ntion-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesention CLI
ntion CLI
Notion CLI. Run via (or if installed globally).
npx ntionntionNotion命令行工具。可通过运行(若全局安装则直接使用)。
npx ntionntionAuthentication
认证
Authentication is a one-time setup stored in . If a command fails with exit code 6 (auth error), prompt the user to run .
~/.config/ntion/config.jsonntion authbash
ntion auth --token "secret_xxx"认证设置为一次性操作,配置信息将存储在中。若命令因退出码6(认证错误)失败,请提示用户运行。
~/.config/ntion/config.jsonntion authbash
ntion auth --token "secret_xxx"Or interactive: ntion auth
Or interactive: ntion auth
Verify: ntion doctor
Verify: ntion doctor
Token is created at https://www.notion.so/profile/integrations.
Token可在https://www.notion.so/profile/integrations创建。Commands
命令
search
search
bash
ntion search --query "meeting notes"
ntion search --query "tasks" --object page --limit 10
ntion search --query "Q1" --created-after 2026-01-01T00:00:00ZOptions: (required), , , , , , , , , , .
--query--scope <id>--object page|data_source--created-after/--created-before--edited-after/--edited-before--created-by <user_id>--limit--cursor--scan-limit--view compact|full--prettybash
ntion search --query "meeting notes"
ntion search --query "tasks" --object page --limit 10
ntion search --query "Q1" --created-after 2026-01-01T00:00:00Z选项:(必填)、、、、、、、、、、。
--query--scope <id>--object page|data_source--created-after/--created-before--edited-after/--edited-before--created-by <user_id>--limit--cursor--scan-limit--view compact|full--prettydata-sources (databases)
数据源(数据库)
bash
ntion data-sources list --query "tasks"
ntion data-sources get --id <id> --view full
ntion data-sources schema --id <id>
ntion data-sources query --id <id> \
--filter-json '{"property":"Status","status":{"equals":"In Progress"}}' \
--sort-json '{"property":"Created","direction":"descending"}' \
--limit 50Use to discover property names and types before querying or creating pages. Filter/sort JSON follows the Notion API filter format.
schemabash
ntion data-sources list --query "tasks"
ntion data-sources get --id <id> --view full
ntion data-sources schema --id <id>
ntion data-sources query --id <id> \
--filter-json '{"property":"Status","status":{"equals":"In Progress"}}' \
--sort-json '{"property":"Created","direction":"descending"}' \
--limit 50使用命令可在查询或创建页面之前了解属性名称和类型。过滤/排序JSON需遵循Notion API的过滤格式。
schemapages
页面
bash
undefinedbash
undefinedRead
读取
ntion pages get --id <id>
ntion pages get --id <id> --include-content --content-format markdown
ntion pages get --id <id>
ntion pages get --id <id> --include-content --content-format markdown
Create
创建
ntion pages create
--parent-data-source-id <ds_id>
--properties-json '{"Name":"New task","Status":"Not started"}'
--parent-data-source-id <ds_id>
--properties-json '{"Name":"New task","Status":"Not started"}'
ntion pages create
--parent-data-source-id <ds_id>
--properties-json '{"Name":"New task","Status":"Not started"}'
--parent-data-source-id <ds_id>
--properties-json '{"Name":"New task","Status":"Not started"}'
Bulk create (up to 100)
批量创建(最多100个)
ntion pages create-bulk
--parent-data-source-id <ds_id>
--items-json '[{"properties":{"Name":"A"}},{"properties":{"Name":"B"}}]'
--parent-data-source-id <ds_id>
--items-json '[{"properties":{"Name":"A"}},{"properties":{"Name":"B"}}]'
ntion pages create-bulk
--parent-data-source-id <ds_id>
--items-json '[{"properties":{"Name":"A"}},{"properties":{"Name":"B"}}]'
--parent-data-source-id <ds_id>
--items-json '[{"properties":{"Name":"A"}},{"properties":{"Name":"B"}}]'
Update
更新
ntion pages update --id <id> --patch-json '{"Status":"Done"}'
ntion pages update --id <id> --patch-json '{"Status":"Done"}'
Archive / restore
归档 / 恢复
ntion pages archive --id <id>
ntion pages unarchive --id <id>
ntion pages archive --id <id>
ntion pages unarchive --id <id>
Relations
关联
ntion pages relate --from-id <id> --property "Project" --to-id <target_id>
ntion pages unrelate --from-id <id> --property "Project" --to-id <target_id>
undefinedntion pages relate --from-id <id> --property "Project" --to-id <target_id>
ntion pages unrelate --from-id <id> --property "Project" --to-id <target_id>
undefinedblocks (page content)
块(页面内容)
bash
undefinedbash
undefinedRead content as markdown
以Markdown格式读取内容
ntion blocks get --id <page_or_block_id>
ntion blocks get --id <id> --depth 2 --format compact
ntion blocks get --id <page_or_block_id>
ntion blocks get --id <id> --depth 2 --format compact
Append to end
追加至末尾
ntion blocks append --id <id> --markdown $'## Section\n\nContent here'
ntion blocks append --id <id> --markdown-file ./notes.md
ntion blocks append --id <id> --markdown $'## Section\n\nContent here'
ntion blocks append --id <id> --markdown-file ./notes.md
Insert at position
插入到指定位置
ntion blocks insert --parent-id <id> --markdown "Intro text" --position start
ntion blocks insert --parent-id <id> --markdown "Middle" --after-id <block_id>
ntion blocks insert --parent-id <id> --markdown "Intro text" --position start
ntion blocks insert --parent-id <id> --markdown "Middle" --after-id <block_id>
Find blocks
查找块
ntion blocks select
--scope-id <id>
--selector-json '{"where":{"type":"paragraph","text_contains":"TODO"}}'
--scope-id <id>
--selector-json '{"where":{"type":"paragraph","text_contains":"TODO"}}'
ntion blocks select
--scope-id <id>
--selector-json '{"where":{"type":"paragraph","text_contains":"TODO"}}'
--scope-id <id>
--selector-json '{"where":{"type":"paragraph","text_contains":"TODO"}}'
Replace block range
替换块范围
ntion blocks replace-range
--scope-id <id>
--start-selector-json '{"where":{"text_contains":"## Old Section"}}'
--end-selector-json '{"where":{"text_contains":"## Next Section"}}'
--markdown "## New Section\n\nUpdated content"
--scope-id <id>
--start-selector-json '{"where":{"text_contains":"## Old Section"}}'
--end-selector-json '{"where":{"text_contains":"## Next Section"}}'
--markdown "## New Section\n\nUpdated content"
ntion blocks replace-range
--scope-id <id>
--start-selector-json '{"where":{"text_contains":"## Old Section"}}'
--end-selector-json '{"where":{"text_contains":"## Next Section"}}'
--markdown "## New Section\n\nUpdated content"
--scope-id <id>
--start-selector-json '{"where":{"text_contains":"## Old Section"}}'
--end-selector-json '{"where":{"text_contains":"## Next Section"}}'
--markdown "## New Section\n\nUpdated content"
Delete blocks
删除块
ntion blocks delete --ids <block_id>
ntion blocks delete --ids <id1> <id2> <id3>
undefinedntion blocks delete --ids <block_id>
ntion blocks delete --ids <id1> <id2> <id3>
undefinedWorkflow patterns
工作流模式
Discover → Query → Act
发现 → 查询 → 操作
- Find the database:
ntion data-sources list --query "tasks" - Get its schema:
ntion data-sources schema --id <id> - Query with filters:
ntion data-sources query --id <id> --filter-json '...' - Create/update pages using the discovered property names
- 查找数据库:
ntion data-sources list --query "tasks" - 获取其结构:
ntion data-sources schema --id <id> - 带过滤条件查询:
ntion data-sources query --id <id> --filter-json '...' - 使用已获取的属性名称创建/更新页面
Read → Edit page content
读取 → 编辑页面内容
- Read current content:
ntion blocks get --id <page_id> - Append new content:
ntion blocks append --id <page_id> --markdown "..." - Or replace a section: use with selectors
blocks replace-range - Delete specific blocks:
ntion blocks delete --ids <id1> <id2>
- 读取当前内容:
ntion blocks get --id <page_id> - 追加新内容:
ntion blocks append --id <page_id> --markdown "..." - 或替换某个章节:使用命令配合选择器
blocks replace-range - 删除特定块:
ntion blocks delete --ids <id1> <id2>
Output format
输出格式
All commands return JSON envelopes:
json
{"ok": true, "data": {...}, "meta": {"request_id": "..."}}
{"ok": false, "error": {"code": "not_found", "message": "...", "retryable": false}, "meta": {...}}Exit codes: 0=success, 1=failure, 2=invalid input, 3=not found, 4=conflict, 5=retryable, 6=auth error.
所有命令均返回JSON格式结果:
json
{"ok": true, "data": {...}, "meta": {"request_id": "..."}}
{"ok": false, "error": {"code": "not_found", "message": "...", "retryable": false}, "meta": {...}}退出码:0=成功,1=失败,2=输入无效,3=未找到,4=冲突,5=可重试,6=认证错误。
Notes
注意事项
- (default) returns minimal data. Use
--view compactwhen complete details are needed.--view full - Mutations are idempotent with verify-first recovery on ambiguous outcomes. Re-read before retrying when the CLI reports uncertainty.
- Bulk create supports (default 5) for parallel operations.
--concurrency - Use on any command for human-readable JSON output.
--pretty
- (默认)返回精简数据。当需要完整详情时,请使用
--view compact。--view full - 变更操作具有幂等性,在结果不明确时会先验证再恢复。当CLI报告不确定结果时,请重新读取后再重试。
- 批量创建支持参数(默认值为5)以实现并行操作。
--concurrency - 任何命令都可添加参数以获得人类可读的JSON输出。
--pretty