# Hetzner API calls (CLI)

## Using the Hetzner Robot API from the Linux Command Line

Hetzner’s **Robot API** lets you access server information programmatically, such as your server list, IPs, and status. While it’s easy to view this data in the web interface, calling the same API from the command line requires a small but important setup.

This article shows how to authenticate correctly and get clean JSON output using `curl` and `jq`.

---

### 1. Robot API authentication (important!)

The Hetzner **Robot API does not use your normal web login password**.

Instead, you must create **separate API credentials**:

1. Log in to the Hetzner **Robot** interface
2. Go to **Settings → Webservice / API**
3. Create a **Webservice user**
4. Save the generated **username and password** (shown only once)

These credentials are used for all API calls.

---

### 2. Calling the API with curl

Once you have API credentials, you can query the server list:

<div class="contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary" id="bkmrk-curl--u-%22api_user%3Aap"><div class="sticky top-[calc(--spacing(9)+var(--header-height))] @w-xl/main:top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`curl -u <span class="hljs-string">"api_user:api_password"</span> \     -H <span class="hljs-string">"Accept: application/json"</span> \     https://robot-ws.your-server.de/server`</div></div>This returns a JSON array containing your servers and their metadata.

---

### 3. Removing curl’s progress output

If you pipe the output to `jq`, you may see extra lines like transfer statistics.  
This is **curl’s progress meter**, not HTTP headers.

To suppress it, use **silent mode**:

<div class="contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary" id="bkmrk-curl--s--u-%22api_user"><div class="sticky top-[calc(--spacing(9)+var(--header-height))] @w-xl/main:top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`curl -s -u <span class="hljs-string">"api_user:api_password"</span> \     https://robot-ws.your-server.de/server | jq .`</div></div>Recommended for scripts (silent, but still shows errors):

<div class="contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary" id="bkmrk-curl--ss--u-%22api_use"><div class="sticky top-[calc(--spacing(9)+var(--header-height))] @w-xl/main:top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`curl -sS -u <span class="hljs-string">"api_user:api_password"</span> \     https://robot-ws.your-server.de/server | jq .`</div></div>---

### 4. Extracting specific fields with jq

For example, to show only the server name and IP address:

<div class="contain-inline-size rounded-2xl corner-superellipse/1.1 relative bg-token-sidebar-surface-primary" id="bkmrk-curl--ss--u-%22api_use-1"><div class="sticky top-[calc(--spacing(9)+var(--header-height))] @w-xl/main:top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`curl -sS -u <span class="hljs-string">"api_user:api_password"</span> \     https://robot-ws.your-server.de/server \| jq <span class="hljs-string">'.[] | .server | {name: .server_name, ip: .server_ip}'</span>`</div></div>This produces clean, minimal JSON suitable for automation or monitoring.

---

### Conclusion

- Use **Robot API credentials**, not your Hetzner web login
- Add `-s` or `-sS` to remove curl’s progress output
- Pipe responses into `jq` for clean parsing
- Perfect for scripts, cron jobs, and infrastructure tooling

That’s all you need to start working with the Hetzner Robot API from the command line   
  
**More documentation:**  
  
https://robot.hetzner.com/doc/webservice/en.html#server