Skip to main content

CLI for coding agents to interact with a BookStack wiki via its REST API

Project description

bookstack-cli

Python License: MIT

CLI for coding agents to interact with a BookStack wiki via its REST API. All output is JSON — built for LLM pipelines, not humans.

bookstack books list | jq '. | length'
bookstack pages get 42 | jq '.html[:200]'
bookstack search query "api docs" | jq '.[] | {name, type, score}'
bookstack test

Install

# One-liner (no clone needed)
uv tool install bookstack-cli          # from PyPI, once published
# or from source:
# uv tool install git+https://github.com/mzehrer/bookstack-cli.git

# Or clone for development
cd bookstack-cli
make init          # or: uv sync

Setup

bookstack auth           # interactive — prompts for URL, token, secret

# If public web URL differs from API (e.g. behind OAuth proxy):
bookstack auth --resolve-url https://wiki.public.example.com

Config File

Saved to ~/.config/bookstack-cli/config.toml:

[connection]
url = "http://10.0.0.1:8080"                    # API endpoint (internal)
resolve_url = "https://wiki.public.example.com"  # public web URL (optional)
token_id = "<your-token-id>"
token_secret = "<your-token-secret>"

resolve_url is optional — defaults to url if not set.

Env Vars (override file)

export BOOKSTACK_URL=http://10.0.0.1:8080
export BOOKSTACK_RESOLVE_URL=https://wiki.example.com
export BOOKSTACK_TOKEN_ID=<your-token-id>
export BOOKSTACK_TOKEN_SECRET=<your-token-secret>

Precedence: env vars > config file > error.

See auth docs →

Usage

$ bookstack --help

╭─ Commands ───────────────────────────────────────╮
│ auth         Save connection credentials.         │
│ config       Manage connection config.            │
│ test         Test connection to BookStack.        │
│ shelves      Manage bookshelves.                  │
│ books        Manage books.                        │
│ chapters     Manage chapters.                     │
│ pages        Manage pages.                        │
│ attachments  Manage attachments.                  │
│ users        Manage users (admin).                │
│ roles        Manage roles (admin).                │
│ search       Search content.                      │
╰───────────────────────────────────────────────────╯

Common Workflows

# Test connection
bookstack test

# List all books
bookstack books list

# Get a specific page
bookstack pages get 42

# Create a page from file
bookstack pages create "My Page" --book-id 1 --markdown-file content.md

# Pipe multi-line content
cat content.md | bookstack pages create "Piped Page" --book-id 1

# Append text to existing page
bookstack pages update 42 --append "New section at the end"

# Resolve web URL to page
bookstack pages resolve-url "https://wiki/books/my-book/page/my-page"

# Import markdown with images
bookstack pages import --file article.md --book-id 1 --name "Article"

# Search across all content
bookstack search query "installation guide"

# List attachments on a page
bookstack attachments list --page-id 10

# Upload a file attachment
bookstack attachments upload --name "Report" --page-id 42 --file report.pdf

# Create a shelf and assign books
bookstack shelves create "Dev Docs"
bookstack shelves update 1 "Dev Docs" --books "10,20,30"

# Update entity
bookstack books update 1 "New Title"

Features

Feature Status
Shelves CRUD (+ book assignment)
Books CRUD
Chapters CRUD
Pages CRUD (partial update, append, move)
Markdown import with image handling
Web URL → API ID resolution
Attachments (link + file upload)
Search across content
Users/Roles (admin)
Async HTTP with retry/backoff
Auto-pagination (client-side filtering)
Config test / connection check
JSON-only output

Project Layout

bookstack-cli/
├── bookstack_cli/
│   ├── client.py        # HTTP client, auth, rate-limit, pagination
│   ├── config.py        # Env vars → ~/.config/bookstack-cli/config.toml
│   ├── exceptions.py    # Typed error hierarchy
│   ├── models.py        # Pydantic models for all entities
│   ├── main.py          # Typer CLI entry point
│   └── resources/       # One module per entity
│       ├── books.py
│       ├── chapters.py
│       ├── pages.py
│       ├── shelves.py
│       ├── attachments.py
│       ├── search.py
│       ├── users.py
│       ├── roles.py
│       ├── revisions.py
│       └── tags.py
├── tests/               # 130+ tests
├── docs/                # Detailed docs
├── skill/               # Pi agent skill
├── Makefile             # init/test/lint/format/run
└── pyproject.toml

Documentation

File What
docs/overview.md Architecture, goals, scope
docs/authentication.md Token setup, env config, security
docs/api-reference.md All endpoints, schemas, pagination
docs/integration-guide.md Hacking BookStack, injections, webhooks
docs/research.md Raw API research findings
skill/SKILL.md Agent skill for pi/coding agents
AGENT.md TDD protocol for this project

Design

  • Async from day onehttpx.AsyncClient with retry + exponential backoff on 429s
  • Pydantic v2 — typed models for every entity, validated responses
  • Agent-friendly output — everything is JSON via stdout, no interactive prompts
  • Resource-per-file — one module per entity, consistent list/get/create/update/delete signatures
  • Config cascade — env vars > ~/.config/bookstack-cli/config.toml > error
  • TDD — 130 tests, red/green/refactor cycle (see AGENT.md)

License

MIT

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

bookstack_cli-0.1.0.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

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

bookstack_cli-0.1.0-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file bookstack_cli-0.1.0.tar.gz.

File metadata

  • Download URL: bookstack_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bookstack_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9b08ca74bf671961a7ad8f9a98d3c6e29cb28b972336e2362ee6acfda75c2367
MD5 f4e39922e6d498b230379d6e336c19e1
BLAKE2b-256 ef8dc3334221f6ddbab59c9a5033395538c16f501a077c9362eb50c9ccd714b9

See more details on using hashes here.

File details

Details for the file bookstack_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bookstack_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for bookstack_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a844cec75784c3ee6befd99209a9233882d906d6d04ee51c60a7b57c7bcf3fa0
MD5 efafa98fe5df076cf592a09676353ea4
BLAKE2b-256 2b11487af0902e78992144e396e0cb31bc97b3b24f7c7477353636a78577a818

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