Skip to main content

Notion CLI built for coding agents. Compact JSON, structured errors, meaningful exit codes.

Project description

notionctl

CI codecov PyPI version Ruff License: MIT

Notion CLI built for coding agents. Compact JSON to stdout, structured errors to stderr, meaningful exit codes. Works with Claude Code, Codex, Mistral Vibe or standalone.

# Agent reads a spec from Notion, implements it, writes results back
SPEC=$(notion block get "$PAGE_ID" --markdown)
# ... agent does work ...
notion page create -p "$PAGE_ID" -t "Implementation Notes" -c @results.md
notion page update "$ROW_ID" --properties '{"Status":{"select":{"name":"Done"}}}'

Install

# Run without installing
uvx --from notionctl notion search "my page"

# Or install permanently
uv tool install notionctl
pip install notionctl

Authentication

OAuth (recommended)

notion auth login     # opens browser, stores token locally
notion auth status    # check current auth
notion auth logout    # revoke and delete token

When prompted, select all pages for full workspace access. Credentials are stored in ~/.config/notion-cli/ and persist across uvx runs.

API token (for CI or headless environments)

Get a token from https://www.notion.so/my-integrations:

export NOTION_API_KEY="secret_..."

Or pass per command with --token.

Commands

notion search <query>              Search pages and databases by title
notion page get <id>               Get page metadata (properties, parent, URL)
notion page create                 Create a page with markdown content
notion page update <id>            Update title, properties, icon, archive status
notion page move <id>              Move a page to a different parent
notion page duplicate <id>         Duplicate a page
notion db get <id>                 Get database schema
notion db query <id>               Query database rows with filter and sort
notion db create                   Create a database
notion db update <id>              Update database title or schema
notion block get <id>              Get page content as blocks or markdown
notion block append <id>           Append block objects (JSON) to a page
notion comment add <id>            Add a comment to a page
notion comment list <id>           List comments on a page
notion user list                   List workspace users
notion user get <id>               Get a specific user
notion user me                     Get the current bot user
notion team list                   List teamspaces
notion auth login/logout/status    OAuth authentication

All IDs accept Notion URLs or raw UUIDs.

Examples

# Search
notion search "meeting notes"
notion search "roadmap" --type page --limit 5

# Read page content as markdown
notion block get <page-id> --markdown

# Create a page with markdown (inline, from file, or stdin)
notion page create -p <parent-id> -t "New Page" -c $'# Hello\nWorld'
notion page create -p <parent-id> -t "Notes" -c @notes.md
cat notes.md | notion page create -p <parent-id> -t "Notes" -c -

# Query a database
notion db query <db-id> --filter '{"property":"Status","select":{"equals":"Done"}}'

# Update a row
notion page update <row-id> --properties '{"Status":{"select":{"name":"Done"}}}'

Output

Compact JSON to stdout. Errors to stderr:

{"error_type":"not_found","message":"...","suggestion":"..."}

Exit codes: 0 ok · 1 error · 2 bad args · 3 not found · 4 permission denied · 5 rate limited

Global options

  • --token — Notion API token (defaults to NOTION_API_KEY env var)
  • --timeout — Timeout per API request in seconds (paginated commands make multiple requests)
  • --help — Show help for any command

Development

git clone https://github.com/jjovalle99/notion-cli.git
cd notion-cli
uv sync
uv run pytest
uv run ruff check src/ tests/
uv run ty check src/

See CONTRIBUTING.md for architecture, conventions, and how to add commands.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notionctl-0.2.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

notionctl-0.2.0-py3-none-any.whl (28.0 kB view details)

Uploaded Python 3

File details

Details for the file notionctl-0.2.0.tar.gz.

File metadata

  • Download URL: notionctl-0.2.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for notionctl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a5d0e9b63e23614fb9ac51974a5a45d09cf4e1fe9346cbae7cca41b3a2bfa116
MD5 9b807be015f18e1c6e7cc65b24f9f3f4
BLAKE2b-256 e73229a5438809c04e9c1a0d3bb51bd32a7eb47b17e679c65238945a634dc19c

See more details on using hashes here.

File details

Details for the file notionctl-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: notionctl-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for notionctl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 290e9f7aea676a7cb51f18c8917e443c5f42b44080f2f33b8be177d38e2d2f7f
MD5 0090d02321b600d10bec6c0faab514f4
BLAKE2b-256 c504886a31464770f917bf44f4e1815d253605501de905f1c55dda73517abfe8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page