A quick, step-by-step guide to install the Hostinger-API Command-Line Interface, connect it to your account, and run the most common VPS commands.
Step 1 – Download & Install the CLI
Please change the version inside this code provided below. You can check for the latest CLI releases and versions here.
cd ~
wget https://github.com/hostinger/api-cli/releases/download/<version>/hapi-<version>-linux-amd64.tar.gz
tar -xf hapi-<version>-linux-amd64.tar.gz
sudo mv hapi /usr/local/bin
On macOS download the file ending with darwin-amd64.tar.gz.
Step 2 – Authenticate with Your API Token
You can pass credentials either through a config file or environment variables.
Option A – Config file
wget https://raw.githubusercontent.com/hostinger/api-cli/main/hapi.yaml -O ~/.hapi.yaml
Edit the file and paste your token under api_token.
Run any command – the CLI will automatically read ~/.hapi.yaml.
Option B – Environment variable (quick method)
export HAPI_API_TOKEN=<paste_your_token_here>
Every key from the YAML file can be supplied the same way by prefixing it with HAPI_
and capitalising the key name.
Step 3 – Verify the Installation
hapi --help
Step 4 – Working with VPS Instances
The vps sub-command groups everything related to virtual machines:
hapi vps vm list # List all VPS
hapi vps vm get <vm_id> # Detailed info for one VPS
hapi vps vm start <vm_id> # Power-on
hapi vps vm stop <vm_id> # Graceful shutdown
Use --format json
to pipe data into scripts or dashboards.
Tip: The CLI mirrors Hostinger API endpoints, so everything you can do in developers.hostinger.com is possible via hapi.
Official documentation
API reference - https://developers.hostinger.com
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! 🎉