npm package: @quantumapi/cli
Description: QuantumAPI CLI - Quantum-safe encryption from your terminal
Author: QuantumAPI Team
Latest version: 1.2.0

# qapi - QuantumAPI CLI

The official command-line interface for [QuantumAPI](https://quantumapi.eu), a European quantum-safe encryption and identity platform.

## Features

- **Encryption Operations**: Encrypt and decrypt data using post-quantum cryptography
- **Key Management**: Create, rotate, and manage cryptographic keys
- **Secret Vault**: Store and retrieve secrets securely
- **User Management**: Manage users and permissions
- **Self-Update**: Keep the CLI up to date automatically
- **Shell Completions**: Tab completion for bash, zsh, fish, and PowerShell
- **CI/CD Ready**: Designed for automation and scripting

## Installation

### Homebrew (macOS/Linux)

```bash
brew install quantumapi/tap/qapi
```

### Direct Download (Recommended)

```bash
curl -sSL https://docs.quantumapi.eu/cli/install.sh | sh
```

### NPM

```bash
npm install -g @quantumapi/cli
```

### Chocolatey (Windows)

```powershell
choco install quantumapi-cli
```

### Docker

```bash
docker run --rm -it ghcr.io/quantumapi/qapi:latest version
```

### From Source

```bash
git clone https://github.com/quantumapi/qapi
cd qapi
make build
```

## Quick Start

```bash
# Configure your API key
qapi configure

# Check your identity
qapi whoami

# Check API health
qapi health

# List your keys
qapi keys list

# Encrypt data
qapi encrypt "secret message" --key my-key

# Manage secrets
qapi secrets create db_password "super_secret"
qapi secrets get db_password --show
```

## Configuration

Configuration is stored in `~/.quantumapi/config.toml`:

```toml
api_key = "qapi_xxx"
endpoint = "https://api.quantumapi.eu"
output = "table"
color = true
```

### Environment Variables

- `QAPI_API_KEY` - API key (overrides config file)
- `QAPI_ENDPOINT` - API endpoint (overrides config file)
- `NO_COLOR` - Disable colored output

### Profiles

```bash
# Create a staging profile
qapi configure --profile staging

# Use a specific profile
qapi --profile staging secrets list
```

### On-Premises / Custom Endpoint

For on-premises installations or custom endpoints:

```bash
# Use a custom endpoint
qapi --endpoint https://api.mycompany.local keys list

# Skip TLS verification (for self-signed certificates)
qapi --endpoint https://api.mycompany.local --insecure keys list

# Or configure permanently
qapi configure
# Enter your custom endpoint when prompted
```

## Output Formats

All commands support multiple output formats:

```bash
qapi keys list                    # Table (default)
qapi keys list --output json      # JSON
qapi keys list --output yaml      # YAML
qapi keys list --output csv       # CSV
```

## Commands

### Core Commands

| Command | Description |
|---------|-------------|
| `qapi configure` | Configure CLI settings |
| `qapi whoami` | Show current authentication info |
| `qapi health` | Check API connectivity |
| `qapi version` | Show CLI version |
| `qapi update` | Update to the latest version |
| `qapi completion` | Generate shell completions |

### Encryption

| Command | Description |
|---------|-------------|
| `qapi encrypt` | Encrypt data |
| `qapi decrypt` | Decrypt data |
| `qapi sign` | Sign data |
| `qapi verify` | Verify signatures |

### Key Management

| Command | Description |
|---------|-------------|
| `qapi keys list` | List all keys |
| `qapi keys get` | Get key details |
| `qapi keys generate` | Generate a new key |
| `qapi keys rotate` | Rotate a key |
| `qapi keys delete` | Delete a key |
| `qapi keys export` | Export public key |
| `qapi keys update` | Update key metadata |
| `qapi keys set-default` | Set default key |
| `qapi keys check` | Check key health |

### Secret Vault

| Command | Description |
|---------|-------------|
| `qapi secrets list` | List all secrets |
| `qapi secrets get` | Get a secret |
| `qapi secrets create` | Create a secret |
| `qapi secrets update` | Update a secret |
| `qapi secrets delete` | Delete a secret |
| `qapi secrets restore` | Restore deleted secret |
| `qapi secrets versions` | List secret versions |
| `qapi secrets rollback` | Rollback to version |
| `qapi secrets share` | Create share link |
| `qapi secrets insights` | Get secret insights |
| `qapi secrets export` | Export secrets |
| `qapi secrets import` | Import secrets |

### Administration

| Command | Description |
|---------|-------------|
| `qapi users` | User management |
| `qapi apps` | Application management |
| `qapi team` | Team management |
| `qapi audit` | Audit log queries |
| `qapi billing` | Billing and usage info |

## Shell Completions

Generate shell completion scripts:

```bash
# Bash
qapi completion bash > /etc/bash_completion.d/qapi

# Zsh
qapi completion zsh > "${fpath[1]}/_qapi"

# Fish
qapi completion fish > ~/.config/fish/completions/qapi.fish

# PowerShell
qapi completion powershell > qapi.ps1
```

## Self-Update

Keep the CLI up to date:

```bash
# Check for updates
qapi update --check

# Update to latest version
qapi update

# Force update even if on latest
qapi update --force
```

## CI/CD Integration

### GitHub Actions

```yaml
- name: Install qapi
  run: curl -sSL https://docs.quantumapi.eu/cli/install.sh | sh

- name: Encrypt secrets
  env:
    QAPI_API_KEY: ${{ secrets.QAPI_API_KEY }}
  run: |
    qapi encrypt "${{ secrets.DB_PASSWORD }}" --key prod-key > encrypted.txt
```

### GitLab CI

```yaml
deploy:
  script:
    - curl -sSL https://docs.quantumapi.eu/cli/install.sh | sh
    - qapi secrets get DB_PASSWORD --show > .env
  variables:
    QAPI_API_KEY: $QAPI_API_KEY
```

## Development

```bash
# Build
make build

# Run tests
make test

# Build for all platforms
make build-all

# Create a snapshot release (for testing)
make release-snapshot

# Create a release
make release
```

## License

MIT License - see [LICENSE](LICENSE) for details.

## Support

- Documentation: https://docs.quantumapi.eu/cli
- Issues: https://github.com/quantumapi/qapi/issues
- Email: support@quantumapi.eu