{"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-11-23T04:03:26","modified_gmt":"2026-11-23T04:03:26","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\">The Hostinger CLI lets you manage Hostinger services from your terminal, including VPS, web hosting, DNS, and billing. Install it with Homebrew or a release archive, sign in through the browser or with an API token, and run commands such as <code>hostinger vps virtual-machines list<\/code> or <code>hostinger hosting cdn purge-cache<\/code>.<\/p>\n<h2 id=\"h_1ce7482489\"><b>Step 1 \u2013 Download &amp; install the CLI<\/b><code><\/code><\/h2>\n<p>macOS and Linux (recommended) install with Homebrew:<\/p>\n<pre>brew install hostinger\/tap\/hostinger<\/pre>\n<p dir=\"ltr\">This also installs bash, zsh, and fish shell completions automatically. Upgrade later with:<\/p>\n<div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>brew upgrade hostinger<\/code><\/pre>\n<\/div>\n<\/div>\n<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>\n<h3 dir=\"ltr\">Verify the installation:<\/h3>\n<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>\n<h2 id=\"h_2a9b8fdf08\"><b>Step 2 \u2013 Authenticate with your API token<\/b><\/h2>\n<p dir=\"ltr\">You have two ways to authenticate, depending on how you plan to use the CLI.<\/p>\n<h3 dir=\"ltr\">Option A \u2013 Browser sign-in (default, no token needed)<\/h3>\n<p dir=\"ltr\">Just run any command. If you&#8217;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>\n<h3 dir=\"ltr\">Option B \u2013 API token (recommended for CI\/CD and scripts)<\/h3>\n<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 \u2192 API<\/a>.<\/li>\n<li>Provide it to the CLI either through an environment variable or a config file:<\/li>\n<\/ol>\n<p dir=\"ltr\"><strong>Environment variable (current session only):<\/strong><\/p>\n<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>\n<p dir=\"ltr\"><strong>Config file (persistent):<\/strong> create <code>~\/.hostinger.yaml<\/code> with:<\/p>\n<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>\n<p dir=\"ltr\">Any command will automatically pick up the token from either source.<\/p>\n<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>\n<h2 id=\"h_8f63636a62\"><b>Step 3 \u2013 Command structure<\/b><\/h2>\n<p dir=\"ltr\">Most commands follow a three-level pattern:<\/p>\n<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>\n<p dir=\"ltr\">Examples:<\/p>\n<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>\n<p dir=\"ltr\">Three top-level commands sit outside this pattern: <code>hostinger up<\/code> deploys a website, and <code>hostinger link<\/code> and <code>hostinger unlink<\/code> save and remove a project\u2019s details. See <a data-click-id=\"hgr-post-content-link-how-to-deploy-a-website-with-the-hostinger-cli\" href=\"\/support\/how-to-deploy-a-website-with-the-hostinger-cli\/\">How to deploy a website with the Hostinger CLI<\/a>. To share a local project on a temporary URL for 24 hours, run <code dir=\"ltr\">hostinger preview<\/code>, as described in <a data-click-id=\"hgr-post-content-link-how-to-share-a-local-website-with-hostinger-preview\" href=\"https:\/\/www.hostinger.com\/support\/how-to-share-a-local-website-with-hostinger-preview\/\">How to share a local website with Hostinger Preview<\/a>.<\/p>\n<p dir=\"ltr\">Add <code>--help<\/code> at any level to see what a group or subgroup contains, e.g.:<\/p>\n<div role=\"group\" aria-label=\"Code\">\n<div>\n<pre><code>hostinger vps --help\r\nhostinger vps firewall --help<\/code><\/pre>\n<h2 id=\"h-step-4-output-formats\" dir=\"ltr\">Step 4 \u2013 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> \u2013 human-readable (default)<\/li>\n<li><code>json<\/code> \u2013 for piping into scripts, dashboards, or <code>jq<\/code><\/li>\n<li><code>tree<\/code> \u2013 nested data as a tree, useful for exploring a response&#8217;s structure<\/li>\n<\/ul>\n<div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">The CLI mirrors the <a data-click-id=\"hgr-post-content-link-hostinger-api\" href=\"https:\/\/www.hostinger.com\/support\/10840865-what-is-hostinger-api\/\">Hostinger API<\/a> 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>.<\/div>\n<h2 id=\"h-shell-completion\" dir=\"ltr\">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 id=\"h-official-documentation\" dir=\"ltr\">Official documentation<\/h2>\n<ul dir=\"ltr\">\n<li>CLI guide \u2013 <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) \u2013 <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) \u2013 <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 \u2013 <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>\n<p class=\"no-margin\">You can now automate routine VPS and web hosting tasks, deploy websites, integrate Hostinger operations into CI\/CD pipelines, or manage your services faster from your terminal.<\/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":{"_content_updated_date":"","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":12,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/292\/revisions"}],"predecessor-version":[{"id":25590,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/292\/revisions\/25590"}],"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}]}}