@andrzejchm/notion-cli 0.2.0 → 0.3.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 +45 -23
- package/dist/cli.js +2269 -1946
- package/dist/cli.js.map +1 -1
- package/docs/README.agents.md +10 -6
- package/docs/skills/using-notion-cli/SKILL.md +16 -26
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ brew install notion-cli
|
|
|
15
15
|
# npm (alternative)
|
|
16
16
|
npm install -g @andrzejchm/notion-cli
|
|
17
17
|
|
|
18
|
-
notion
|
|
18
|
+
notion auth login # choose your auth method
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## For AI Agents
|
|
@@ -80,7 +80,11 @@ notion ls
|
|
|
80
80
|
|
|
81
81
|
| Command | Description |
|
|
82
82
|
|---------|-------------|
|
|
83
|
-
| `notion
|
|
83
|
+
| `notion auth login` | Interactive auth setup — choose OAuth or integration token |
|
|
84
|
+
| `notion auth logout` | Remove a profile and all its credentials |
|
|
85
|
+
| `notion auth status` | Show current auth state |
|
|
86
|
+
| `notion auth list` | List all saved profiles |
|
|
87
|
+
| `notion auth use <name>` | Switch the active profile |
|
|
84
88
|
| `notion search <query>` | Search pages and databases by title |
|
|
85
89
|
| `notion ls` | List all accessible pages and databases |
|
|
86
90
|
| `notion open <id\|url>` | Open a page in your browser |
|
|
@@ -92,7 +96,6 @@ notion ls
|
|
|
92
96
|
| `notion comment <id\|url> -m <text>` | Add a comment to a page |
|
|
93
97
|
| `notion append <id\|url> -m <markdown>` | Append markdown blocks to a page |
|
|
94
98
|
| `notion create-page --parent <id\|url> --title <title>` | Create a new page, prints URL |
|
|
95
|
-
| `notion profile list\|use\|remove` | Manage multiple auth profiles |
|
|
96
99
|
| `notion completion bash\|zsh\|fish` | Install shell tab completion |
|
|
97
100
|
|
|
98
101
|
### `notion db query` flags
|
|
@@ -123,39 +126,58 @@ The CLI auto-detects your context:
|
|
|
123
126
|
|
|
124
127
|
Two authentication methods are available. If both are configured, **OAuth takes precedence** for API calls.
|
|
125
128
|
|
|
126
|
-
|
|
129
|
+
Start with the interactive setup:
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
```bash
|
|
132
|
+
notion auth login # choose OAuth or integration token
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Tradeoff comparison
|
|
136
|
+
|
|
137
|
+
| Method | Best for | Write attribution | Requires |
|
|
138
|
+
|--------|----------|-------------------|----------|
|
|
139
|
+
| **OAuth user login** | Write-heavy workflows, personal use | Your Notion account | Browser (or `--manual` for headless) |
|
|
140
|
+
| **Integration token** | CI, Docker, automated agents | Integration bot | Token from notion.so/profile/integrations |
|
|
141
|
+
| `NOTION_API_TOKEN` env var | CI/Docker without config files | Integration bot | Token set in environment |
|
|
142
|
+
|
|
143
|
+
**Priority:** `NOTION_API_TOKEN` env var → OAuth token → integration token (first found wins)
|
|
144
|
+
|
|
145
|
+
### OAuth user login
|
|
129
146
|
|
|
130
147
|
```bash
|
|
131
|
-
#
|
|
132
|
-
notion
|
|
148
|
+
notion auth login # interactive selector — choose OAuth
|
|
149
|
+
notion auth login --manual # headless: prints URL, prompts to paste redirect
|
|
150
|
+
notion auth status # show current auth state
|
|
151
|
+
notion auth logout # remove profile and credentials
|
|
152
|
+
```
|
|
133
153
|
|
|
134
|
-
|
|
135
|
-
|
|
154
|
+
Comments and pages are attributed to your **actual Notion account**.
|
|
155
|
+
Access tokens expire after ~1 hour and are refreshed automatically.
|
|
136
156
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
notion
|
|
157
|
+
### Integration token
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
notion auth login # interactive selector — choose "Integration token"
|
|
161
|
+
|
|
162
|
+
# or: environment variable (CI, Docker, agents — no profile needed)
|
|
163
|
+
export NOTION_API_TOKEN=ntn_your_token_here
|
|
141
164
|
```
|
|
142
165
|
|
|
166
|
+
Works everywhere (CI, headless, agents). Write operations are attributed to the **integration bot**.
|
|
167
|
+
You must manually connect the integration to each page (`⋯` → Add connections).
|
|
168
|
+
|
|
143
169
|
Token format: starts with `ntn_` (new) or `secret_` (legacy integrations).
|
|
144
170
|
Get a token: [notion.so/profile/integrations/internal](https://www.notion.so/profile/integrations/internal)
|
|
145
171
|
|
|
146
|
-
###
|
|
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.
|
|
172
|
+
### Profile management
|
|
149
173
|
|
|
150
174
|
```bash
|
|
151
|
-
notion auth
|
|
152
|
-
notion
|
|
153
|
-
notion auth
|
|
154
|
-
notion auth logout
|
|
175
|
+
notion auth list # list all profiles
|
|
176
|
+
notion auth use <name> # switch active profile
|
|
177
|
+
notion auth logout # remove a profile (interactive selector)
|
|
178
|
+
notion auth logout --profile <name> # remove specific profile directly
|
|
155
179
|
```
|
|
156
180
|
|
|
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
181
|
### Integration capabilities
|
|
160
182
|
|
|
161
183
|
Read-only commands (`search`, `read`, `db query`, etc.) need **Read content** only.
|
|
@@ -174,7 +196,7 @@ Write commands require additional capabilities — enable in your integration se
|
|
|
174
196
|
|
|
175
197
|
**Page not found (404):** Share the page with your integration — open the page → `⋯` → **Add connections**.
|
|
176
198
|
|
|
177
|
-
**Unauthorized (401):** Run `notion
|
|
199
|
+
**Unauthorized (401):** Run `notion auth login` to reconfigure, or check your `NOTION_API_TOKEN`.
|
|
178
200
|
|
|
179
201
|
**Search returns nothing:** Search is title-only. The page must also be shared with your integration.
|
|
180
202
|
|