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
- Install Go and clone the repository:
apt install golang-go git clone --depth 1 https://github.com/hostinger/api-cli /tmp/api-cli
- Navigate into the project folder:
cd /tmp/api-cli
- Build the binary and move it to your system path:
go build -o /usr/local/bin/hapi chmod 0755 /usr/local/bin/hapi
- Return to your home directory and verify the installation:
cd ~ hapi --help
- If `hapi –help` returns the command list, the CLI is installed correctly.
Step 2 – Authenticate with Your API Token
Generate your API token at https://hpanel.hostinger.com/api.
You can pass credentials either through a config file or environment variables.
Option A – Config file (persistent)
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 (current session only)
export HAPI_API_TOKEN=<paste_your_token_here>
Step 3 – 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 shutdownUse --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! 🎉