cURL ExampleΒΆ

The API can be used easily with cURL or any other command line based HTTP client thanks to the REST interface.

The request URL is built using the following steps:

  • The base URL for the API:
  • The method name: i.e.
  • Optionally a name parameter: ie. myserver1.

According to the previous example, our request URL for the method (that requires just one name parameter) would be:

The API key required to authenticate can be provided in two ways:

  • Using the api_key GET parameter.
  • Using basic HTTP authentication mechanism with the api_key as the username and the password is ignored.

Following our previous example (substitute API_KEY_HEX with a valid API key), the cURL invocation including the API key in a GET parameter would be:

curl ''

Including the API key as part of the basic HTTP authentication mechanism, the cURL invocation would be:

curl --user API_KEY_HEX:x

Responses will be delivered as an HTTP document with JSON encoded data with content type application/json. An example of a valid response would be:

    "status": "LIVE",
    "renewal_price_currency": "GBP",
    "type": "miniserver",
    "name": "myserver1",
    "expiry_date": "2012-12-01",
    "renewal_price_amount": 21.60,
    "nickname": "www",
    "start_date": "2010-12-01",
    "renewal_price_vat": 4.34

Invalid responses will cause one of the HTTP status codes listed in Errors to be returned along with a JSON encoded dictionary with a bit more information in.

For example this request for a nonexistent server:

curl --user API_KEY_HEX:x

Returns this JSON dictionary with a 404 HTTP status code:

    "error_type": "ApiErrorDoesNotExist",
    "error_code": 3,
    "error": "Couldn't find service with name 'BADSERVERNAME'"

To pass more complicated parameters it is necessary to JSON encode them in the parameters argument:

curl --data-urlencode 'parameters={"name":"myserver","api_key":"API_HEX_KEY"}'

This supplies a JSON encoded dictionary with a name parameter and an api_key parameter. The parameters argument can be used to pass all the parameters and is the only way to pass complex data structures.

Previous topic

Go Example

This Page