@andrzejchm/notion-cli 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,18 +1,23 @@
1
1
  # notion-cli
2
2
 
3
- > Read Notion pages and databases from your terminal — built for AI coding agents and developers.
3
+ > Read and write Notion pages from your terminal — built for AI coding agents and developers.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@andrzejchm/notion-cli.svg?style=flat&color=4B78E6)](https://www.npmjs.com/package/@andrzejchm/notion-cli)
6
+ [![homebrew tap](https://img.shields.io/badge/homebrew-andrzejchm%2Fnotion--cli-orange?style=flat&logo=homebrew)](https://github.com/andrzejchm/homebrew-notion-cli)
6
7
  [![Node.js >=22](https://img.shields.io/badge/node-%3E%3D22-brightgreen?style=flat)](https://nodejs.org)
7
8
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
8
9
 
9
10
  ```bash
11
+ # Homebrew (recommended)
12
+ brew tap andrzejchm/notion-cli
13
+ brew install notion-cli
14
+
15
+ # npm (alternative)
10
16
  npm install -g @andrzejchm/notion-cli
17
+
11
18
  notion init # paste your Notion integration token once
12
19
  ```
13
20
 
14
- ---
15
-
16
21
  ## For AI Agents
17
22
 
18
23
  ```
@@ -21,11 +26,18 @@ Fetch and follow instructions from https://raw.githubusercontent.com/andrzejchm/
21
26
 
22
27
  ---
23
28
 
29
+ ![notion-cli demo](docs/demo.gif)
30
+
31
+ ---
32
+
24
33
  ## Features
25
34
 
26
35
  - **`notion search`** — find any page or database by title
27
36
  - **`notion read`** — render any page as full-fidelity markdown
28
37
  - **`notion db query`** — filter, sort, and select columns from any database
38
+ - **`notion append`** — append markdown content to an existing page
39
+ - **`notion create-page`** — create a new page with markdown body, prints URL to stdout
40
+ - **`notion comment`** — add a comment to a page
29
41
  - **Agent-friendly** — plain text tables by default; `--json` for machine-readable output
30
42
  - **Flexible auth** — interactive setup or `NOTION_API_TOKEN` env var
31
43
  - **Accepts URLs** — pass full Notion URLs anywhere an ID is expected
@@ -45,8 +57,18 @@ notion db query "$DB_ID" --filter "Status=In Progress" --sort "Priority:asc"
45
57
  # Get JSON output for scripting / AI agents
46
58
  notion db query "$DB_ID" --filter "Status=Done" | jq '.[] | .properties.Title'
47
59
 
48
- # Inspect a database schema before querying
49
- notion db schema "$DB_ID"
60
+ # Append markdown blocks to an existing page
61
+ notion append "$PAGE_ID" -m "## Summary\nGenerated by AI agent."
62
+
63
+ # Create a new page and capture its URL
64
+ URL=$(notion create-page --parent "$PAGE_ID" --title "Meeting Notes" -m "# Agenda\n- Item 1")
65
+ echo "Created: $URL"
66
+
67
+ # Pipe content to a new page
68
+ my-summarize-command | notion create-page --parent "$PAGE_ID" --title "Auto Summary"
69
+
70
+ # Add a comment to a page
71
+ notion comment "$PAGE_ID" -m "Reviewed and approved."
50
72
 
51
73
  # List everything your integration can access
52
74
  notion ls
@@ -67,6 +89,9 @@ notion ls
67
89
  | `notion db query <id\|url>` | Query database entries with filtering and sorting |
68
90
  | `notion users` | List workspace members |
69
91
  | `notion comments <id\|url>` | Read page comments |
92
+ | `notion comment <id\|url> -m <text>` | Add a comment to a page |
93
+ | `notion append <id\|url> -m <markdown>` | Append markdown blocks to a page |
94
+ | `notion create-page --parent <id\|url> --title <title>` | Create a new page, prints URL |
70
95
  | `notion profile list\|use\|remove` | Manage multiple auth profiles |
71
96
  | `notion completion bash\|zsh\|fish` | Install shell tab completion |
72
97
 
@@ -96,6 +121,12 @@ The CLI auto-detects your context:
96
121
 
97
122
  ## Authentication
98
123
 
124
+ Two authentication methods are available. If both are configured, **OAuth takes precedence** for API calls.
125
+
126
+ ### Internal integration token
127
+
128
+ Run `notion init`. Suitable for read-only operations and automated agents. Write operations are attributed to the **integration bot** (not a real user).
129
+
99
130
  ```bash
100
131
  # Interactive setup (recommended for first-time use)
101
132
  notion init
@@ -112,6 +143,31 @@ notion profile use <name>
112
143
  Token format: starts with `ntn_` (new) or `secret_` (legacy integrations).
113
144
  Get a token: [notion.so/profile/integrations/internal](https://www.notion.so/profile/integrations/internal)
114
145
 
146
+ ### OAuth user login (recommended for write operations)
147
+
148
+ Run `notion auth login`. Notion opens in your browser. After approving, your comments and pages will be attributed to your **actual Notion account** — not the integration bot.
149
+
150
+ ```bash
151
+ notion auth login # Opens browser, authenticates
152
+ notion comment <id> -m "My comment" # Now attributed to your user
153
+ notion auth status # Check auth state
154
+ notion auth logout # Remove OAuth session
155
+ ```
156
+
157
+ **Headless / remote servers:** `notion auth login --manual` prints the auth URL for you to open in a local browser, then prompts you to paste the redirect URL back.
158
+
159
+ ### Integration capabilities
160
+
161
+ Read-only commands (`search`, `read`, `db query`, etc.) need **Read content** only.
162
+
163
+ Write commands require additional capabilities — enable in your integration settings ([notion.so/profile/integrations/internal](https://www.notion.so/profile/integrations/internal) → your integration → **Capabilities**):
164
+
165
+ | Command | Required capabilities |
166
+ |---------|----------------------|
167
+ | `notion append` | Read content, Insert content |
168
+ | `notion create-page` | Read content, Insert content |
169
+ | `notion comment` | Read content, Insert content, Read comments, Insert comments |
170
+
115
171
  ---
116
172
 
117
173
  ## Troubleshooting
@@ -124,8 +180,12 @@ Get a token: [notion.so/profile/integrations/internal](https://www.notion.so/pro
124
180
 
125
181
  **Empty database query:** Run `notion db schema <id>` first to see valid property names and values.
126
182
 
183
+ **`notion comment` returns "Insufficient permissions":** Enable **Read comments** and **Insert comments** in your integration capabilities: [notion.so/profile/integrations/internal](https://www.notion.so/profile/integrations/internal) → your integration → Capabilities.
184
+
185
+ **`notion append` / `notion create-page` returns "Insufficient permissions":** Enable **Insert content** in your integration capabilities.
186
+
127
187
  ---
128
188
 
129
189
  ## License
130
190
 
131
- MIT © [Andrzej Chm](https://github.com/andrzejchm)
191
+ MIT © [Andrzej Chmielewski](https://github.com/andrzejchm)