Skip to content

calljacob/kinsta-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kinsta Platform CLI

A premium, high-performance Rust-based command-line interface (CLI) to interact with the Kinsta Platform API v2. This tool supports all 90 spec-compliant endpoints, providing a secure, robust, and beautiful terminal experience for managing WordPress sites, environments, DNS records, analytics, logs, and connection access.


✨ Features

  • Nested Subcommand Tree: Clean organization using modern Clap command-line parser.
  • Secure Credentials Handling: API keys and default company IDs are securely stored in your local configuration directory (~/.config/kinsta/config.json) with strict Unix file permissions (0700 directories, 0600 files).
  • Rich Terminal UI & Interactive Fallback: Elegant success/warning/error alerts, progress spinners (indicatif), and formatted outputs. Running the CLI without subcommands launches a step-by-step interactive selection menu (dialoguer).
  • Global --json Output Flag: Easily bypass UI formatting and tables to retrieve raw structured JSON directly, perfect for automation scripting or piping into jq.
  • Autocomplete Scripts: Out-of-the-box autocomplete generation for bash, elvish, fish, powershell, and zsh shells.
  • Asynchronous Operation Watcher: Option to watch long-running operations in real-time until they finish (streams JSON status objects when running in --json mode).
  • Log Follow/Tail Mode: Keep polling and tailing environment logs in real time (--follow or -f).
  • Complete Suite: Full command support for SFTP, SSH status/allowlists/credentials, WordPress plugins & themes, DNS zones/records, backups, analytics, and raw log streaming.

🚀 Installation & Building

To compile the binary, ensure you have Rust and Cargo installed:

# Clone the repository
git clone https://github.com/bhubbard/kinsta-cli.git
cd kinsta-cli

# Compile in release mode
cargo build --release

# The compiled binary is located at target/release/kinsta-cli
./target/release/kinsta-cli --help

🔑 Authentication

Before running commands, initialize the CLI with your Kinsta API Key:

# Initialize and validate your Kinsta API credentials
kinsta auth init

# Check connection status
kinsta auth status

📖 Command Reference

Top-Level Commands

Commands:
  auth       Authentication commands
  company    Manage company details
  site       Manage WordPress sites
  env        Manage site environments
  backup     Manage environment backups
  domain     Manage environment domains
  dns        Manage custom domain DNS records
  op         Inspect long-running operation statuses
  analytics  Retrieve environment analytics
  sftp       Manage SFTP accounts
  ssh        Manage SSH access and configuration
  cache      Manage Cache & CDN settings
  ip         Manage IP Deny List
  plugin     Manage WordPress plugins
  theme      Manage WordPress themes
  log        Retrieve environment logs

Usage Examples

Sites & Environments

# List all sites for the default company
kinsta site list

# Show detailed site info & environments
kinsta site show <SITE_ID>

# Clear cache on an environment and watch for completion
kinsta env clear-cache <ENV_ID> --wait

# Change the PHP version on an environment
kinsta env modify-php <ENV_ID> 8.2 --wait

# Run a WP-CLI command directly
kinsta env wp-cli <ENV_ID> "plugin list"

SSH & SFTP Access

# View SSH / SFTP access status
kinsta ssh get-status <ENV_ID>

# Add allowed IP address to SSH allowlist
kinsta ssh set-ips <ENV_ID> 192.168.1.100 --wait

# List additional SFTP accounts
kinsta sftp list <ENV_ID>

# Add a new additional SFTP account
kinsta sftp add <ENV_ID> <USERNAME> --path "public/wp-content" --wait

Analytics & Logs

# View site visits for the last 30 days
kinsta analytics visits <ENV_ID> --timeframe 30_days

# View CDN bandwidth usage
kinsta analytics cdn-bandwidth <ENV_ID>

# Fetch the last 150 lines of PHP error logs
kinsta log get <ENV_ID> --file-name php-error --lines 150

# Follow/tail logs in real-time
kinsta log get <ENV_ID> --file-name error --lines 50 --follow

DNS & Domains

# List custom domains on an environment
kinsta domain list <ENV_ID>

# Fetch pointing and verification records for custom domain
kinsta domain verify <SITE_DOMAIN_ID>

# List DNS records for a domain
kinsta dns list <DOMAIN_ID>

# Add a new TXT record to domain
kinsta dns create <DOMAIN_ID> --type TXT --name "@" --value "v=spf1 include:servers.mcsv.net ?all" --wait

🚀 Shell Autocomplete & Advanced Flags

# Generate zsh completion script and save it
kinsta completion zsh > ~/.zsh/completion/_kinsta

# Generate bash completion script
kinsta completion bash > /etc/bash_completion.d/kinsta

# Use global json flag to get raw API output
kinsta --json site list

# Watch a long running operation returning raw JSON updates
kinsta --json op watch <OP_ID>

# Fall back to interactive terminal select prompts (TUI)
kinsta

🧪 Development & Testing

Run unit tests to verify JSON deserialization schemas and helper functions:

cargo test

📄 License

This project is licensed under the MIT License.

About

A cli for working with Kinsta Hosting.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors