notion-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Notion CLI Skill

Notion CLI Skill

Use the
notion
binary from this repo to operate Notion. Prefer the local build when developing.
使用本仓库中的
notion
二进制文件来操作Notion。开发时优先选择本地构建版本。

Install

安装

  • Homebrew:
    brew install inforix/tap/notion-cli
  • Release binary: download from GitHub releases and place on PATH
  • Local build:
    go build -o ./bin/notion ./src/cmd/notion
  • Homebrew:
    brew install inforix/tap/notion-cli
  • 发布版二进制文件:从GitHub Releases下载并添加到PATH中
  • 本地构建:
    go build -o ./bin/notion ./src/cmd/notion

Auth

身份验证

Set a Notion integration token in the environment:
export NOTION_TOKEN=YOUR_TOKEN
Optional: store the token with the CLI (if supported):
notion auth set --token YOUR_TOKEN
在环境变量中设置Notion集成令牌:
export NOTION_TOKEN=YOUR_TOKEN
可选:将令牌存储在CLI中(若支持):
notion auth set --token YOUR_TOKEN

Commands

命令

Auth

身份验证

notion auth set --token YOUR_TOKEN
notion auth status
notion auth clear
notion auth set --token YOUR_TOKEN
notion auth status
notion auth clear

Pages

页面

notion pages list --query "Project" --all
notion pages get <page_id>
notion pages create --body @page.json
notion pages update <page_id> --body @update.json
notion pages archive <page_id>
notion pages export <page_id> --assets=download -o page.md
notion pages list --query "Project" --all
notion pages get <page_id>
notion pages create --body @page.json
notion pages update <page_id> --body @update.json
notion pages archive <page_id>
notion pages export <page_id> --assets=download -o page.md

Databases

数据库

notion databases get <db_id>
notion databases query <db_id> --body @query.json
notion databases create --body @database.json
notion databases update <db_id> --body @update.json
notion databases get <db_id>
notion databases query <db_id> --body @query.json
notion databases create --body @database.json
notion databases update <db_id> --body @update.json

Blocks

区块

notion blocks get <block_id>
notion blocks update <block_id> --body @block.json
notion blocks children append <block_id> --body @children.json
notion blocks get <block_id>
notion blocks update <block_id> --body @block.json
notion blocks children append <block_id> --body @children.json

Users

用户

notion users list --all
notion users get <user_id>
notion users list --all
notion users get <user_id>

Comments

评论

notion comments list --page-id <page_id>
notion comments list --block-id <block_id>
notion comments create --body @comment.json
notion comments list --page-id <page_id>
notion comments list --block-id <block_id>
notion comments create --body @comment.json

Search

搜索

notion search --body @query.json
notion search --body @query.json

Examples

示例

notion --version
notion pages list --query "Project"
notion pages export <page_id>
notion pages get <page_id>
notion pages create --body @page.json
notion pages update <page_id> --body @update.json
notion pages archive <page_id>
notion databases query <db_id> --body @query.json
notion blocks children append <block_id> --body @children.json
notion users list --all
notion comments list --page-id <page_id>
notion search --body @query.json
notion --version
notion pages list --query "Project"
notion pages export <page_id>
notion pages get <page_id>
notion pages create --body @page.json
notion pages update <page_id> --body @update.json
notion pages archive <page_id>
notion databases query <db_id> --body @query.json
notion blocks children append <block_id> --body @children.json
notion users list --all
notion comments list --page-id <page_id>
notion search --body @query.json

Notes

注意事项

  • The CLI uses the Notion API and includes a
    Notion-Version
    header by default.
  • Use
    --notion-version
    to override when testing a specific API version.
  • Use
    --page-size
    ,
    --cursor
    , and
    --all
    for list pagination.
  • Use
    --format
    to render Go templates from JSON output.
  • Use
    --version
    or
    -V
    to print the CLI version and exit.
  • 该CLI使用Notion API,默认包含
    Notion-Version
    请求头。
  • 测试特定API版本时,使用
    --notion-version
    参数覆盖默认值。
  • 使用
    --page-size
    --cursor
    --all
    参数处理列表分页。
  • 使用
    --format
    参数通过JSON输出渲染Go模板。
  • 使用
    --version
    -V
    参数打印CLI版本并退出。