How to use Hostinger API CLI

Quick guide on how to install and use Hostinger API CLI.

Updated 1 week ago

A quick, step-by-step guide to install the Hostinger CLI, connect it to your account, and run the most common VPS commands.

Step 1 – Download & install the CLI

macOS and Linux (recommended) install with Homebrew:

brew install hostinger/tap/hostinger

This also installs bash, zsh, and fish shell completions automatically. Upgrade later with:

brew upgrade hostinger

Windows, or without Homebrew: download the archive for your platform from the releases page and put the hostinger binary on your PATH. Each archive also bundles the shell completion files.

Verify the installation:

hostinger version

If this returns a version number, the CLI is installed correctly.

Step 2 – Authenticate with your API token

You have two ways to authenticate, depending on how you plan to use the CLI.

Option A – Browser sign-in (default, no token needed)

Just run any command. If you’re not authenticated yet, the CLI opens a browser window for you to sign in, then caches and automatically refreshes your credentials. This is the fastest way to get started interactively.

Option B – API token (recommended for CI/CD and scripts)

  1. Generate a token in hPanel → API.
  2. Provide it to the CLI either through an environment variable or a config file:

Environment variable (current session only):

export HOSTINGER_API_TOKEN=<paste_your_token_here>

Config file (persistent): create ~/.hostinger.yaml with:

api_token: <your API token>

Any command will automatically pick up the token from either source.

Note: a configured token always takes precedence over browser sign-in. If commands suddenly fail to authorize after working before, check for a stale api_token in your config file or environment first.

Step 3 – Command structure

Commands follow a three-level pattern:

hostinger <group> <subgroup> <verb> [args] [flags]

Examples:

hostinger vps virtual-machines list
hostinger vps virtual-machines get <vm_id>
hostinger vps vm start <vm_id>        # "vm" is a short alias for "virtual-machines"
hostinger vps vm stop <vm_id>
hostinger dns records list example.com
hostinger billing catalog list

Add --help at any level to see what a group or subgroup contains, e.g.:

hostinger vps --help
hostinger vps firewall --help

Step 4 – Output formats

Results print as a table by default. Use --format to change that:

hostinger vps virtual-machines list --format json | jq
hostinger vps virtual-machines list --format tree
  • table – human-readable (default)
  • json – for piping into scripts, dashboards, or jq
  • tree – nested data as a tree, useful for exploring a response’s structure

Tip: The CLI mirrors the Hostinger API endpoints, so everything you can do at developers.hostinger.com is possible via hostinger.

Shell completion

Tab-completion is available for bash, zsh, fish, and PowerShell. Homebrew installs the bash/zsh/fish completions automatically. For a manual install, see AUTOCOMPLETE.md in the CLI repository.

Official documentation

You’re all set!

You can now automate routine VPS tasks, integrate Hostinger operations into CI/CD pipelines, or simply manage servers faster from your terminal. Happy scripting! 🎉