notion-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNotion CLI
Notion CLI
notionnotionInstall
安装
bash
undefinedbash
undefinedHomebrew
Homebrew
brew install 4ier/tap/notion-cli
brew install 4ier/tap/notion-cli
Go
Go
go install github.com/4ier/notion-cli@latest
go install github.com/4ier/notion-cli@latest
npm
npm
npm install -g notion-cli-go
npm install -g notion-cli-go
Or download binary from GitHub Releases
或从GitHub Releases下载二进制文件
undefinedundefinedAuth
身份验证
bash
notion auth login --with-token <<< "ntn_xxxxxxxxxxxxx" # or interactive
notion auth login --with-token --profile work <<< "ntn_xxx" # save as named profile
export NOTION_TOKEN=ntn_xxxxxxxxxxxxx # env var alternative
notion auth status # show current profile
notion auth switch # interactive profile picker
notion auth switch work # switch to named profile
notion auth doctor # health checkbash
notion auth login --with-token <<< "ntn_xxxxxxxxxxxxx" # 或交互式登录
notion auth login --with-token --profile work <<< "ntn_xxx" # 保存为命名配置
export NOTION_TOKEN=ntn_xxxxxxxxxxxxx # 环境变量替代方案
notion auth status # 查看当前配置
notion auth switch # 交互式配置选择器
notion auth switch work # 切换到命名配置
notion auth doctor # 健康检查Command Reference
命令参考
Search
搜索
bash
notion search "query" # search everything
notion search "query" --type page # pages only
notion search "query" --type database # databases onlybash
notion search "query" # 搜索全部内容
notion search "query" --type page # 仅搜索页面
notion search "query" --type database # 仅搜索数据库Pages
页面
bash
notion page view <id|url> # render page content
notion page list # list workspace pages
notion page create <parent> --title "X" --body "content"
notion page create <db-id> --db "Name=Review" "Status=Todo" # database row
notion page delete <id> # archive page
notion page restore <id> # unarchive page
notion page move <id> --to <parent>
notion page open <id> # open in browser
notion page edit <id|url> # edit in $EDITOR (Markdown round-trip)
notion page edit <id> --editor nano # specify editor
notion page set <id> Key=Value ... # set properties (type-aware)
notion page props <id> # show all properties
notion page props <id> <prop-id> # get specific property
notion page link <id> --prop "Rel" --to <target-id> # add relation
notion page unlink <id> --prop "Rel" --from <target-id> # remove relationbash
notion page view <id|url> # 渲染页面内容
notion page list # 列出工作区页面
notion page create <parent> --title "X" --body "content"
notion page create <db-id> --db "Name=Review" "Status=Todo" # 创建数据库行
notion page delete <id> # 归档页面
notion page restore <id> # 取消归档页面
notion page move <id> --to <parent>
notion page open <id> # 在浏览器中打开
notion page edit <id|url> # 在$EDITOR中编辑(Markdown双向同步)
notion page edit <id> --editor nano # 指定编辑器
notion page set <id> Key=Value ... # 设置属性(类型感知)
notion page props <id> # 查看所有属性
notion page props <id> <prop-id> # 获取指定属性
notion page link <id> --prop "Rel" --to <target-id> # 添加关联
notion page unlink <id> --prop "Rel" --from <target-id> # 移除关联Databases
数据库
bash
notion db list # list databases
notion db view <id> # show schema
notion db query <id> # query all rows
notion db query <id> -F 'Status=Done' -s 'Date:desc' # filter + sort
notion db query <id> --filter-json '{"or":[...]}' # complex JSON filter
notion db query <id> --all # fetch all pages
notion db create <parent> --title "X" --props "Status:select,Date:date"
notion db update <id> --title "New Name" --add-prop "Priority:select"
notion db add <id> "Name=Task" "Status=Todo" "Priority=High"
notion db add-bulk <id> --file items.json # bulk create from JSON
notion db export <id> # export all rows as CSV (default)
notion db export <id> --format json # export as JSON
notion db export <id> --format md -o report.md # export as Markdown table to file
notion db open <id> # open in browserbash
notion db list # 列出数据库
notion db view <id> # 查看 schema
notion db query <id> # 查询所有行
notion db query <id> -F 'Status=Done' -s 'Date:desc' # 过滤 + 排序
notion db query <id> --filter-json '{"or":[...]}' # 复杂JSON过滤
notion db query <id> --all # 获取所有页面
notion db create <parent> --title "X" --props "Status:select,Date:date"
notion db update <id> --title "New Name" --add-prop "Priority:select"
notion db add <id> "Name=Task" "Status=Todo" "Priority=High"
notion db add-bulk <id> --file items.json # 从JSON批量创建
notion db export <id> # 导出所有行为CSV(默认格式)
notion db export <id> --format json # 导出为JSON
notion db export <id> --format md -o report.md # 导出为Markdown表格到文件
notion db open <id> # 在浏览器中打开Filter operators
过滤运算符
| Syntax | Meaning |
|---|---|
| equals |
| not equals |
| greater than (or equal) |
| less than (or equal) |
| contains |
Multiple flags combine with AND. Property types are auto-detected from schema.
-F| 语法 | 含义 |
|---|---|
| 等于 |
| 不等于 |
| 大于(或等于) |
| 小于(或等于) |
| 包含 |
多个标记通过AND逻辑组合。属性类型会从schema自动检测。
-FSort: -s 'Date:desc'
or -s 'Name:asc'
-s 'Date:desc'-s 'Name:asc'排序:-s 'Date:desc'
或 -s 'Name:asc'
-s 'Date:desc'-s 'Name:asc'Bulk add file format
批量添加文件格式
json
[{"Name": "Task A", "Status": "Todo"}, {"Name": "Task B", "Status": "Done"}]json
[{"Name": "Task A", "Status": "Todo"}, {"Name": "Task B", "Status": "Done"}]Blocks
块
bash
notion block list <parent-id> # list child blocks
notion block list <parent-id> --all # paginate through all
notion block list <parent-id> --depth 3 # recursive nested blocks
notion block list <parent-id> --md # output as Markdown
notion block get <id> # get single block
notion block append <parent> "text" # append paragraph
notion block append <parent> "text" -t bullet # bullet point
notion block append <parent> "text" -t code --lang go # code block
notion block append <parent> --file notes.md # from file
notion block insert <parent> "text" --after <block-id> # positional insert
notion block update <id> --text "new" # update content
notion block delete <id1> [id2] [id3] # delete one or more
notion block move <id> --after <target> # reposition after target block
notion block move <id> --before <target> # reposition before target block
notion block move <id> --parent <new-parent> # move to different parentBlock types: /, , , , , , , , , ,
paragraphph1h2h3bulletnumberedtodoquotecodecalloutdividerbash
notion block list <parent-id> # 列出子块
notion block list <parent-id> --all # 分页获取全部
notion block list <parent-id> --depth 3 # 递归获取嵌套块
notion block list <parent-id> --md # 输出为Markdown
notion block get <id> # 获取单个块
notion block append <parent> "text" # 添加段落
notion block append <parent> "text" -t bullet # 添加项目符号
notion block append <parent> "text" -t code --lang go # 添加代码块
notion block append <parent> --file notes.md # 从文件添加
notion block insert <parent> "text" --after <block-id> # 指定位置插入
notion block update <id> --text "new" # 更新内容
notion block delete <id1> [id2] [id3] # 删除一个或多个块
notion block move <id> --after <target> # 移动到目标块之后
notion block move <id> --before <target> # 移动到目标块之前
notion block move <id> --parent <new-parent> # 移动到新的父级块类型:/, , , , , , , , , ,
paragraphph1h2h3bulletnumberedtodoquotecodecalloutdividerComments
评论
bash
notion comment list <page-id>
notion comment add <page-id> "comment text"
notion comment get <comment-id>
notion comment reply <comment-id> "reply text" # reply in same threadbash
notion comment list <page-id>
notion comment add <page-id> "评论内容"
notion comment get <comment-id>
notion comment reply <comment-id> "回复内容" # 在同一线程回复Users
用户
bash
notion user me # current bot info
notion user list # all workspace users
notion user get <user-id>bash
notion user me # 当前机器人信息
notion user list # 所有工作区用户
notion user get <user-id>Files
文件
bash
notion file list # list uploads
notion file upload ./path/to/file # upload (auto MIME detection)bash
notion file list # 列出上传文件
notion file upload ./path/to/file # 上传(自动MIME检测)Raw API (escape hatch)
原始API(逃逸舱)
bash
notion api GET /v1/users/me
notion api POST /v1/search '{"query":"test"}'
notion api PATCH /v1/pages/<id> '{"archived":true}'bash
notion api GET /v1/users/me
notion api POST /v1/search '{"query":"test"}'
notion api PATCH /v1/pages/<id> '{"archived":true}'Output Modes
输出模式
- Terminal (TTY): colored tables, readable formatting
- Piped/scripted: JSON automatically
- Explicit: or
--format json--format table - : show HTTP request/response details
--debug
All output includes full Notion UUIDs. All commands accept Notion URLs or IDs.
- 终端(TTY):带颜色的表格,易读格式
- 管道/脚本:自动输出JSON
- 显式指定:或
--format json--format table - :显示HTTP请求/响应详情
--debug
所有输出包含完整的Notion UUID。所有命令支持Notion URL或ID。
Tips
提示
- and
notion db addauto-detect property types from schemanotion page set - Multi-select:
Tags=tag1,tag2,tag3 - Checkbox:
Done=true - Pipe to jq:
notion db query <id> -F 'Status=Done' --format json | jq '.results[].id'
- 和
notion db add会从schema自动检测属性类型notion page set - 多选:
Tags=tag1,tag2,tag3 - 复选框:
Done=true - 管道到jq:
notion db query <id> -F 'Status=Done' --format json | jq '.results[].id'