{"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":"2026-09-15T10:17:16","modified_gmt":"2026-09-15T10:17:16","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 CLI, connect it to your account, and run the most common VPS commands.<\/p><h2 id=\"h_1ce7482489\"><b>Step 1 &ndash; Download &amp; install the CLI<\/b><code><\/code><\/h2><p>macOS and Linux (recommended) install with Homebrew:<\/p><pre>brew install hostinger\/tap\/hostinger<\/pre><p dir=\"ltr\">This also installs bash, zsh, and fish shell completions automatically. Upgrade later with:<\/p><div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>brew upgrade hostinger<\/code><\/pre>\n<\/div>\n<\/div><p><strong>Windows, or without Homebrew:<\/strong> download the archive for your platform from the <a data-click-id=\"hgr-post-content-link-releases-page\" href=\"https:\/\/github.com\/hostinger\/api-cli\/releases\" target=\"_blank\" rel=\"noopener\">releases page<\/a> and put the <code>hostinger<\/code> binary on your <code>PATH<\/code>. Each archive also bundles the shell completion files.<\/p><h3 dir=\"ltr\">Verify the installation:<\/h3><div role=\"group\" aria-label=\"Code\">\n<div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>hostinger version<\/code><\/pre>\n<\/div>\n<\/div>\n<p dir=\"ltr\">If this returns a version number, the CLI is installed correctly.<\/p>\n<\/div><h2 id=\"h_2a9b8fdf08\"><b>Step 2 &ndash; Authenticate with your API token<\/b><\/h2><p dir=\"ltr\">You have two ways to authenticate, depending on how you plan to use the CLI.<\/p><h3 dir=\"ltr\">Option A &ndash; Browser sign-in (default, no token needed)<\/h3><p dir=\"ltr\">Just run any command. If you&rsquo;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.<\/p><h3 dir=\"ltr\">Option B &ndash; API token (recommended for CI\/CD and scripts)<\/h3><ol dir=\"ltr\">\n<li>Generate a token in <a data-click-id=\"hgr-post-content-link-hpanel-hostinger-com-api\" href=\"https:\/\/hpanel.hostinger.com\/api\" target=\"_blank\" rel=\"noopener\">Hostinger dashboard &rarr; API<\/a>.<\/li>\n<li>Provide it to the CLI either through an environment variable or a config file:<\/li>\n<\/ol><p dir=\"ltr\"><strong>Environment variable (current session only):<\/strong><\/p><div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>export HOSTINGER_API_TOKEN=&lt;paste_your_token_here&gt;<\/code><\/pre>\n<\/div>\n<\/div><p dir=\"ltr\"><strong>Config file (persistent):<\/strong> create <code>~\/.hostinger.yaml<\/code> with:<\/p><div role=\"group\" aria-label=\"yaml code\">\n<div>\n<pre><code class=\"language-yaml\">api_token: &lt;your API token&gt;<\/code><\/pre>\n<\/div>\n<\/div><p dir=\"ltr\">Any command will automatically pick up the token from either source.<\/p><p dir=\"ltr\"><strong>Note:<\/strong> a configured token always takes precedence over browser sign-in. If commands suddenly fail to authorize after working before, check for a stale <code>api_token<\/code> in your config file or environment first.<\/p><h2 id=\"h_8f63636a62\"><b>Step 3 &ndash; Command structure<\/b><\/h2><p dir=\"ltr\">Commands follow a three-level pattern:<\/p><div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>hostinger &lt;group&gt; &lt;subgroup&gt; &lt;verb&gt; [args] [flags]<\/code><\/pre>\n<\/div>\n<\/div><p dir=\"ltr\">Examples:<\/p><div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>hostinger vps virtual-machines list\r\nhostinger vps virtual-machines get &lt;vm_id&gt;\r\nhostinger vps vm start &lt;vm_id&gt;        # \"vm\" is a short alias for \"virtual-machines\"\r\nhostinger vps vm stop &lt;vm_id&gt;\r\nhostinger dns records list example.com\r\nhostinger billing catalog list<\/code><\/pre>\n<\/div>\n<\/div><p dir=\"ltr\">Add <code>--help<\/code> at any level to see what a group or subgroup contains, e.g.:<\/p><div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>hostinger vps --help\r\nhostinger vps firewall --help<\/code><\/pre>\n<h2 dir=\"ltr\" id=\"h-step-4-output-formats\">Step 4 &ndash; Output formats<\/h2>\n<p dir=\"ltr\">Results print as a table by default. Use <code>--format<\/code> to change that:<\/p>\n<div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>hostinger vps virtual-machines list --format json | jq\r\nhostinger vps virtual-machines list --format tree<\/code><\/pre>\n<\/div>\n<\/div>\n<ul dir=\"ltr\">\n<li><code>table<\/code> &ndash; human-readable (default)<\/li>\n<li><code>json<\/code> &ndash; for piping into scripts, dashboards, or <code>jq<\/code><\/li>\n<li><code>tree<\/code> &ndash; nested data as a tree, useful for exploring a response&rsquo;s structure<\/li>\n<\/ul>\n<p dir=\"ltr\"><strong>Tip:<\/strong> The CLI mirrors the Hostinger API endpoints, so everything you can do at <a data-click-id=\"hgr-post-content-link-developers-hostinger-com\" href=\"https:\/\/developers.hostinger.com\" target=\"_blank\" rel=\"noopener\">developers.hostinger.com<\/a> is possible via <code>hostinger<\/code>.<\/p>\n<h2 dir=\"ltr\" id=\"h-shell-completion\">Shell completion<\/h2>\n<p dir=\"ltr\">Tab-completion is available for bash, zsh, fish, and PowerShell. Homebrew installs the bash\/zsh\/fish completions automatically. For a manual install, see <a data-click-id=\"hgr-post-content-link-autocomplete-md\" href=\"https:\/\/github.com\/hostinger\/api-cli\/blob\/main\/AUTOCOMPLETE.md\" target=\"_blank\" rel=\"noopener\">AUTOCOMPLETE.md<\/a> in the CLI repository.<\/p>\n<h2 dir=\"ltr\" id=\"h-official-documentation\">Official documentation<\/h2>\n<ul dir=\"ltr\">\n<li>CLI guide &ndash; <a data-click-id=\"hgr-post-content-link-https-docs-hostinger-com-api-reference-cli\" href=\"https:\/\/docs.hostinger.com\/api-reference\/cli\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.hostinger.com\/api-reference\/cli<\/a><\/li>\n<li>Full command reference (every command, generated from the API spec) &ndash; <a data-click-id=\"hgr-post-content-link-https-github-com-hostinger-api-cli-blob-main-docs-hostinger\" href=\"https:\/\/github.com\/hostinger\/api-cli\/blob\/main\/docs\/hostinger.md\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/hostinger\/api-cli\/blob\/main\/docs\/hostinger.md<\/a><\/li>\n<li>Scripting with the CLI (exit codes, passing JSON to flags) &ndash; <a data-click-id=\"hgr-post-content-link-https-docs-hostinger-com-api-reference-cli-scripting\" href=\"https:\/\/docs.hostinger.com\/api-reference\/cli-scripting\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.hostinger.com\/api-reference\/cli-scripting<\/a><\/li>\n<li>API reference &ndash; <a data-click-id=\"hgr-post-content-link-https-developers-hostinger-com\" href=\"https:\/\/developers.hostinger.com\" target=\"_blank\" rel=\"noopener\">https:\/\/developers.hostinger.com<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div><h2 id=\"h_718b898cd2\">You&rsquo;re all set!<\/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":8,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/292\/revisions"}],"predecessor-version":[{"id":16842,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/292\/revisions\/16842"}],"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}]}}