A nodeJS client for the Hetzner Robot API
Please note: I am in no way affiliated with Hetzner Online GmbH. I am just a developer trying to ease his work with a flexible API client.
Install using NPM:
npm i --save hetzner-api-client
First off, create a new API client instance:
var APIClient =robot =username: '<your Robot username>'password: '<your Robot password>';
The client is all ready now and you can start using its methods:
Sample response for a valid IP address:
Sample response for an invalid IP address:
IP_NOT_FOUND: ip not found
Error messages are structured like so:
<ERROR_CODE>: <error message>
Oh. Did I mention the client is completely promise-based? It will always return a promise to your requests.
Custom server proxies
Say you own one or two servers and want to execute multiple methods on them. Kind of enervating to have to specify the server IP each time, isn't it? Therefore, you can (since
0.0.5) create a proxy:
var thanos = robot;// see? no additional IP parameter necessary.thanosthanos
I'm still in the process of adding API methods. Currently, around 40% are implemented, some need a final naming scheme and if necessary, some more will be rewritten. So even if the current version works as is, you should not rely on this in production. Though of course you can speed this up by committing :)
A word on tests
To start the tests, simply use
Obviously many API methods are pretty destructive, so in order to be able to test everything thoroughly, I decided to implement a simple pseudo-Hetzner API webserver based on restify. You can find it in the
test folder as
apiServer.js. It starts on port 8080 and tries to behave as exactly as possible as the original Hetzner API. That way, I can test the client safely and you can test the scripts you'll use it for.
This is a freaking load of additional work though, so I'd appreciate some help here.
Official API docs can be found here.