@4ier/notion-cli

中文文档
0.7.0发布于 2026/04/30MIT零依赖近 30 天下载 1818

Full-featured CLI for Notion. Like gh for GitHub, but for Notion. 44 commands, one binary.

原始使用文档
文档目录24 节
  1. Install
  2. Homebrew (macOS/Linux)
  3. Go
  4. npm
  5. Scoop (Windows)
  6. Docker
  7. Binary
  8. Quick Start
  9. Commands
  10. Features
  11. Human-Friendly Filters
  12. Schema-Aware Properties
  13. Smart Output
  14. Markdown I/O
  15. External Images
  16. Recursive Block Reading
  17. URL or ID — Your Choice
  18. Actionable Error Messages
  19. For AI Agents
  20. Configuration
  21. Troubleshooting
  22. Windows: MSYS / Git Bash path mangling
  23. Contributing
  24. License

notion-cli

Like gh for GitHub, but for Notion. 39 commands. One binary.

demo

Release Tests License Go Report Card


A full-featured command-line interface for Notion. Manage pages, databases, blocks, comments, users, and files — all from your terminal. Built for developers and AI agents who need programmatic access without the browser.

Install

Homebrew (macOS/Linux)

brew install 4ier/tap/notion-cli

Go

go install github.com/4ier/notion-cli@latest

npm

npm install -g @4ier/notion-cli

Scoop (Windows)

scoop bucket add 4ier https://github.com/4ier/scoop-bucket
scoop install notion-cli

Docker

docker run --rm -e NOTION_TOKEN ghcr.io/4ier/notion-cli search "meeting"

Binary

Download from GitHub Releases — available for Linux, macOS, and Windows (amd64/arm64).

Quick Start

# Authenticate
echo "ntn_xxxxx" | notion auth login --with-token

# Search your workspace
notion search "meeting notes"

# Query a database with filters
notion db query <db-id> --filter 'Status=Done' --sort 'Date:desc'

# Create a page in a database
notion page create <db-id> --db "Name=Weekly Review" "Status=Todo"

# Read page content as Markdown
notion block list <page-id> --depth 3 --md

# Append blocks from a Markdown file
notion block append <page-id> --file notes.md

# Raw API escape hatch
notion api GET /v1/users/me

Commands

GroupCommandsDescription
authlogin logout status switch doctorAuthentication & diagnostics
searchsearchSearch pages and databases
pageview list create delete restore move open set props link unlinkFull page lifecycle
dblist view query create update add add-bulk openDatabase CRUD + query
blocklist get append insert update deleteContent block operations
commentlist add getDiscussion threads
userme list getWorkspace members
filelist uploadFile management
api<METHOD> <path>Raw API escape hatch

39 subcommands covering 100% of the Notion API.

Features

Human-Friendly Filters

No JSON needed for 90% of queries:

notion db query <id> --filter 'Status=Done' --filter 'Priority=High' --sort 'Date:desc'

For complex queries (OR, nesting), use the JSON escape hatch:

notion db query <id> --filter-json '{"or":[{"property":"Status","status":{"equals":"Done"}},{"property":"Status","status":{"equals":"Cancelled"}}]}'

Schema-Aware Properties

Property types are auto-detected from the database schema:

notion page create <db-id> --db "Name=Sprint Review" "Date=2026-03-01" "Points=8" "Done=true"

Smart Output

  • Terminal: Colored tables, formatted text
  • Pipe/Script: Clean JSON for jq, scripts, and AI agents
# Pretty table in terminal
notion db query <id>

# JSON when piped
notion db query <id> | jq '.results[].properties.Name'

Markdown I/O

# Read blocks as Markdown
notion block list <page-id> --md --depth 3

# Write Markdown to Notion
notion block append <page-id> --file document.md

Supports headings, bullets, numbered lists, todos, quotes, code blocks, and dividers.

External Images

Insert or append an image block by URL (no upload — points to externally hosted image):

# Insert after a specific block (e.g. next to a "TODO: add figure" placeholder)
notion block insert <page-id> --after <block-id> \
  --image-url https://example.com/diagram.png \
  --caption "Figure 1 — architecture"

# Append to end of page
notion block append <page-id> --image-url https://example.com/diagram.png

Recursive Block Reading

notion block list <page-id> --depth 5 --all

URL or ID — Your Choice

# Both work
notion page view abc123def
notion page view https://notion.so/My-Page-abc123def456

Actionable Error Messages

object_not_found: Could not find page with ID abc123
  → Check the ID is correct and the page/database is shared with your integration

For AI Agents

This CLI is designed to be agent-friendly:

  • JSON output when piped — no parsing needed
  • Schema-aware — agents don't need to know property types
  • URL resolution — paste Notion URLs directly
  • Single binary — no runtime dependencies
  • Exit codes — 0 for success, non-zero for errors

Install as an agent skill:

npx skills add 4ier/notion-cli

Configuration

# Token is stored in ~/.config/notion-cli/config.json (mode 0600)
echo "ntn_xxxxx" | notion auth login --with-token

# Or use environment variable
export NOTION_TOKEN=ntn_xxxxx

# Check authentication
notion auth status
notion auth doctor

Troubleshooting

Windows: MSYS / Git Bash path mangling

In MSYS-based shells (Git Bash, MSYS2), arguments starting with / are silently rewritten to Windows paths. This breaks API path arguments:

# ✗ /v1/users/me becomes C:/Program Files/Git/v1/users/me
notion api GET /v1/users/me

Fix: disable MSYS path conversion:

MSYS_NO_PATHCONV=1 notion api GET /v1/users/me

Or export it for the session: export MSYS_NO_PATHCONV=1

This is a shell-level issue, not a bug in notion-cli. PowerShell and cmd.exe are not affected.

Contributing

Issues and PRs welcome at github.com/4ier/notion-cli.

License

MIT

版本与发布记录

@4ier/notion-cli 共发布 8 个版本,首次发布于 2026/02/24;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.7.0latest2026/04/306 个月前
0.6.02026/04/306 个月前
0.5.02026/04/216 个月前
0.4.02026/04/186 个月前
0.3.22026/04/077 个月前
0.3.12026/04/067 个月前

关于 @4ier/notion-cli 的常见问题

@4ier/notion-cli 是什么?

Full-featured CLI for Notion. Like gh for GitHub, but for Notion. 44 commands, one binary.

如何安装 @4ier/notion-cli?

在项目目录运行 npm install @4ier/notion-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 notion,可以用 npx notion 直接运行。

@4ier/notion-cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/4ier__notion-cli 是否存在。

@4ier/notion-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@4ier/notion-cli 可以商用吗?

@4ier/notion-cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@4ier/notion-cli 的下载量有多少?

根据 npm 官方下载统计,@4ier/notion-cli 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,818 次,日均约 61 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@4ier/notion-cli 还在维护吗?

最新版本 0.7.0 发布于 2026/04/30(6 个月前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/02/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。