Skip to main content

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:


curl -u "api_user:api_password" \ -H "Accept: application/json" \ https://robot-ws.your-server.de/server

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:


curl -s -u "api_user:api_password" \ https://robot-ws.your-server.de/server | jq .

curl -sS -u "api_user:api_password" \ https://robot-ws.your-server.de/server | jq .

4. Extracting specific fields with jq

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


curl -sS -u "api_user:api_password" \ https://robot-ws.your-server.de/server \ | jq '.[] | .server | {name: .server_name, ip: .server_ip}'

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