Skip to content

CLI Reference

Apiary includes a comprehensive command-line interface (CLI) for common maintenance and development tasks. All commands are accessed through a single apiary entry point with various subcommands.

Overview

The CLI is built with Click and provides a consistent interface for:

  • Starting the development server
  • Initializing and validating configuration
  • Backing up configuration and custom code
  • Testing application before deployment
  • Cleaning up generated files
  • Managing the Docker container (docker up, docker down, docker restart)

Installation

The CLI is automatically installed when you install Apiary:

uv sync

Usage

All commands follow this pattern:

uv run apiary [OPTIONS] COMMAND [ARGS]...

Getting Help

# Show all available commands
uv run apiary --help

# Show help for a specific command
uv run apiary serve --help
uv run apiary init --help

# Show version
uv run apiary --version

Commands

apiary

Apiary - Personal API service maintenance CLI.

Usage:

apiary [OPTIONS] COMMAND [ARGS]...

Options:

  --version  Show the version and exit.
  --help     Show this message and exit.

backup

Backup configuration files and optionally custom code.

Creates a timestamped backup of configuration files in backups/YYYYMMDD/. Use --include-custom to also backup services_custom/ and routers_custom/.

Usage:

apiary backup [OPTIONS]

Options:

  --config-dir TEXT  Configuration directory to backup  [default: config]
  --backup-dir TEXT  Backup directory path  [default: backups]
  --include-custom   Also backup services_custom/ and routers_custom/
                     directories
  --help             Show this message and exit.

clean

Clean up generated files and caches.

Usage:

apiary clean [OPTIONS]

Options:

  --help  Show this message and exit.

docker

Manage the application Docker container via docker compose.

Usage:

apiary docker [OPTIONS] COMMAND [ARGS]...

Options:

  --help  Show this message and exit.

down

Stop and remove the application container.

Usage:

apiary docker down [OPTIONS]

Options:

  --help  Show this message and exit.

restart

Restart the running application container.

Use this after editing files in the mounted config/ or services/ volumes so the application picks up the changes.

Usage:

apiary docker restart [OPTIONS]

Options:

  --help  Show this message and exit.

up

Start the application container in the background.

Pass --build to rebuild the image first (required after code changes outside of the mounted config/ and services/ volumes).

Usage:

apiary docker up [OPTIONS]

Options:

  --build  Rebuild images before starting
  --help   Show this message and exit.

init

Initialize configuration files and optional custom code directories.

Creates config from templates and, by default, services_custom/ and routers_custom/. Custom directories are gitignored so your code is never overwritten when you pull updates. Put custom services and routers there.

Usage:

apiary init [OPTIONS]

Options:

  -f, --force                     Overwrite existing config files
  --custom-dirs / --no-custom-dirs
                                  Create services_custom/ and routers_custom/
                                  for update-safe custom code  [default:
                                  custom-dirs]
  --help                          Show this message and exit.

serve

Start the API server.

Usage:

apiary serve [OPTIONS]

Options:

  -h, --host TEXT     Bind host  [default: 127.0.0.1]
  -p, --port INTEGER  Bind port  [default: 8000]
  --reload            Enable auto-reload
  --help              Show this message and exit.

test

Test application configuration and imports.

Validates configuration files and tests that the application can be imported and initialized successfully. Use this before deploying updates to catch errors early.

Usage:

apiary test [OPTIONS]

Options:

  --config-dir TEXT  Configuration directory path  [default: config]
  --skip-import      Skip application import test (only validate config)
  --help             Show this message and exit.

validate-config

Validate API key configuration files.

Usage:

apiary validate-config [OPTIONS]

Options:

  --config-dir TEXT  Configuration directory path  [default: config]
  --help             Show this message and exit.

Exit Codes

All commands return standard exit codes:

  • 0 - Success
  • Non-zero - Failure

This makes them suitable for use in scripts and CI/CD pipelines.

Output Formatting

The CLI uses colored output for better readability:

  • 🔧 Blue - Command running
  • ✅ Green - Success
  • ❌ Red - Failure
  • 📊 - Informational messages

Next Steps