notion-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNotion CLI
Notion CLI
Look things up before answering
作答前先查询相关信息
The CLI is self-documenting. Always prefer running these commands over guessing
syntax or relying on memorized knowledge:
- — list every public API endpoint.
ntn api ls - — show methods, doc links, and usage for an endpoint.
ntn api <path> --help - — print the full official docs for an endpoint.
ntn api <path> --docs - — print a reduced OpenAPI fragment (useful for understanding request/response schemas).
ntn api <path> --spec - — help for any command or subcommand.
ntn <command> --help
该CLI具备自文档功能。请始终优先运行以下命令,而非猜测语法或依赖记忆的知识:
- — 列出所有公开的API端点。
ntn api ls - — 显示某个端点的可用方法、文档链接及使用方式。
ntn api <path> --help - — 打印该端点的完整官方文档。
ntn api <path> --docs - — 打印简化版OpenAPI片段(有助于理解请求/响应 schema)。
ntn api <path> --spec - — 获取任意命令或子命令的帮助信息。
ntn <command> --help
Install
安装
bash
npm i -g ntn@latestbash
npm i -g ntn@latestAuthentication
认证
- — required for
NOTION_API_TOKENandntn api. Set this env var to a Notion integration token.ntn files - /
ntn login— session auth forntn logoutandntn workers. This does not authenticatentn tokensorntn apitoday.ntn files
- — 使用
NOTION_API_TOKEN和ntn api时必填。请将此环境变量设置为Notion集成令牌。ntn files - /
ntn login— 针对ntn logout和ntn workers的会话认证。目前该认证方式不支持ntn tokens或ntn api。ntn files
ntn api
ntn apintn api
ntn apiRun for full syntax. Quick summary:
ntn api --helpbash
undefined运行查看完整语法。快速摘要:
ntn api --helpbash
undefinedGET with query param
带查询参数的GET请求
ntn api v1/users page_size==100
ntn api v1/users page_size==100
POST with inline body fields
带内联请求体字段的POST请求
ntn api v1/pages parent[page_id]=abc123
ntn api v1/pages parent[page_id]=abc123
POST with JSON body
带JSON请求体的POST请求
ntn api v1/pages -d '{"parent":{"page_id":"abc123"}}'
The method is inferred (GET by default, POST when a body is present). Override
with `-X METHOD`.ntn api v1/pages -d '{"parent":{"page_id":"abc123"}}'
请求方法会自动推断(默认GET,当存在请求体时为POST)。可通过`-X METHOD`手动指定方法。ntn files
ntn filesntn files
ntn filesConvenience wrapper around the File Uploads API.
bash
ntn files create < image.png
ntn files create --external-url https://example.com/photo.png
ntn files list
ntn files get <upload-id>文件上传API的便捷封装。
bash
ntn files create < image.png
ntn files create --external-url https://example.com/photo.png
ntn files list
ntn files get <upload-id>ntn workers
ntn workersntn workers
ntn workersManage Notion workers (deploy, list, execute, etc.). Run
for subcommands.
ntn workers --helpbash
ntn workers new my-worker # scaffold a new project
ntn workers deploy # deploy from current directory
ntn workers ls # list workers
ntn workers exec <capability> # execute a capability管理Notion workers(部署、列出、执行等)。运行查看子命令。
ntn workers --helpbash
ntn workers new my-worker # 快速搭建新项目脚手架
ntn workers deploy # 从当前目录部署
ntn workers ls # 列出所有workers
ntn workers exec <capability> # 执行某一功能ntn tokens
ntn tokensntn tokens
ntn tokensManage tokens used by . Requires . These are separate
from integration tokens.
ntn workersntn loginNOTION_API_TOKENbash
ntn tokens create
ntn tokens ls
ntn tokens revoke <token-id>管理使用的令牌。需要先执行。这些令牌与集成令牌相互独立。
ntn workersntn loginNOTION_API_TOKENbash
ntn tokens create
ntn tokens ls
ntn tokens revoke <token-id>