{"id":292,"date":"2025-06-30T09:28:50","date_gmt":"2025-06-30T09:28:50","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2025\/06\/30\/11679133-how-to-use-hostinger-api-cli\/"},"modified":"2025-06-30T09:28:50","modified_gmt":"2025-06-30T09:28:50","slug":"11679133-how-to-use-hostinger-api-cli","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/11679133-how-to-use-hostinger-api-cli\/","title":{"rendered":"How to Use Hostinger API CLI"},"content":{"rendered":"<p class=\"no-margin\">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.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_1ce7482489\"><b>Step 1 &ndash; Download &amp; Install the CLI<\/b><\/h2><p class=\"no-margin\">Please change the version inside this code provided below. You can check for the latest CLI releases and versions <a href=\"https:\/\/github.com\/hostinger\/api-cli\/releases\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">here<\/a>.<\/p><p class=\"no-margin\">\n<\/p><pre><code>cd ~<br>wget https:\/\/github.com\/hostinger\/api-cli\/releases\/download\/&lt;version&gt;\/hapi-&lt;version&gt;-linux-amd64.tar.gz<br>tar -xf hapi-&lt;version&gt;-linux-amd64.tar.gz<br>sudo mv hapi \/usr\/local\/bin<\/code><\/pre><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">On <b>macOS<\/b> download the file ending with darwin-amd64.tar.gz.<\/p>\n<\/div><p class=\"no-margin\">\n<\/p><h2 id=\"h_2a9b8fdf08\"><b>Step 2 &ndash; Authenticate with Your API Token<\/b><\/h2><p class=\"no-margin\">You can pass credentials either through a config file <i>or<\/i> environment variables.<\/p><p class=\"no-margin\">\n<\/p><h3 id=\"h_44a924cf64\"><b>Option A &ndash; Config file<\/b><\/h3><pre><code>wget https:\/\/raw.githubusercontent.com\/hostinger\/api-cli\/main\/hapi.yaml -O ~\/.hapi.yaml<\/code><\/pre><ol>\n<li>\n<p class=\"no-margin\">Edit the file and paste your token under api_token.<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\">Run any command &ndash; the CLI will automatically read ~\/.hapi.yaml.<\/p>\n<\/li>\n<\/ol><h3 id=\"h_c17ff53c18\"><b>Option B &ndash; Environment variable (quick method)<\/b><\/h3><pre><code>export HAPI_API_TOKEN=&lt;paste_your_token_here&gt;<\/code><\/pre><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">Every key from the YAML file can be supplied the same way by prefixing it with <code>HAPI_<\/code> and capitalising the key name.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_ec372e930f\"><b>Step 3 &ndash; Verify the Installation<\/b><\/h2><pre><code>hapi --help<\/code><\/pre><p class=\"no-margin\">\n<\/p><h2 id=\"h_8f63636a62\"><b>Step 4 &ndash; Working with VPS Instances<\/b><\/h2><p class=\"no-margin\">The vps sub-command groups everything related to virtual machines:<\/p><p class=\"no-margin\">\n<\/p><pre><code>hapi vps vm list                 # List all VPS<br>hapi vps vm get    &lt;vm_id&gt;       # Detailed info for one VPS<br>hapi vps vm start  &lt;vm_id&gt;       # Power-on<br>hapi vps vm stop   &lt;vm_id&gt;       # Graceful shutdown<\/code><\/pre><p class=\"no-margin\">Use <code>--format json<\/code> to pipe data into scripts or dashboards.<\/p><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\"><b>Tip:<\/b> The CLI mirrors Hostinger API endpoints, so everything you can do in <i>developers.hostinger.com<\/i> is possible via hapi.<\/p>\n<\/div><p class=\"no-margin\">\n<\/p><h2 id=\"h_3860f2e3ca\"><b>Official documentation<\/b><\/h2><p class=\"no-margin\">API reference &ndash; <a href=\"https:\/\/developers.hostinger.com\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\">https:\/\/developers.hostinger.com<\/a><br>&#8203;<\/p><h2 id=\"h_718b898cd2\"><b>You&rsquo;re all set!<\/b><\/h2><p class=\"no-margin\">You can now automate routine VPS tasks, integrate Hostinger operations into CI\/CD pipelines, or simply manage servers faster from your terminal. Happy scripting! &#127881;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick guide on how to install and use Hostinger API CLI.<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[295],"tags":[],"class_list":["post-292","post","type-post","status-publish","format-standard","hentry","category-api"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/11679133-how-to-use-hostinger-api-cli\/","default":1}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=292"}],"version-history":[{"count":0,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/292\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}