Start using our API in 5 minutes.

Learn how to use our API with our quick API guide.

Follow the few easy steps below to make your first LeaseWeb API call.

Currently LeaseWeb offers two different API’s, each using a unique API key to verify your API requests.

In order to access our API, you will need to issue your requests against these URLs:
Each API request needs to be authenticated. At this moment each API provides a different method to authenticate your requests.

LeaseWeb API

To authenticate your call, add your API key to the request header ‘X-Lsw-Auth’.


LeaseWeb CDN API

To use this API you must use the secret key provided in LeaseWeb’s CDN Control Panel and authenticate at each call.

The algorithm used for authentication is the following:

  1. Get the URI you want to access
  2. Get the current timestamp (Must be in UTC timezone)
  3. sha1(key + timestamp + URI)
  4. Append timestamp to the URL
  5. Append signature to the URL
URI = https://api.leasewebcdn.com/rules/push/1234567890/
timestamp = 1364999235
key = mySecretKey
signature = sha1('mySecretKey'+'1364999235'+'/rules/push/1234567890')
URI = https://api.leasewebcdn.com/rules/push/1234567890/1364999235
Full URL: https://api.leasewebcdn.com/rules/push/1234567890/1364999235/a964f2ee0b04408df2e6ae561a27ed6ea481e2f7
      
<?php
$secret = 'mySecretKey';
$customer_number = '1234567890';
$zone_id = '100';
$path = '/zones/push/' . $customer_number . '/' . $zone_id;
$time = time();
$signature = sha1($secret.$time.$path);
$full_path = 'https://api.leasewebcdn.com'.$path.'/'.$time.'/'.$signature;
      
import hashlib
import time
secret = 'mySecretKey'
customer_number = '1234567890'
zone_id = '100'
uri = '/zones/push/' + customer_number + '/' + zone_id
timestamp = int(time.time())
hashed_signature = hashlib.sha1(secret + str(timestamp) + uri).hexdigest()
full_url = 'https://api.leasewebcdn.com{0}/{1}/{2}'.format(uri, timestamp, hashed_signature)
      

LeaseWeb Private Cloud API

LeaseWeb Private Cloud utilizes Apache CloudStack. Each call needs to be signed as described in the Apache CloudStack Documentation.

Now that you know enough about our API, is time to make your first test call. In this example, you will retrieve a list of Bare Metal Servers you currently have at LeaseWeb.

To begin, your first request may look like this:

key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx && \
curl -X GET -H "X-Lsw-Auth: $key" https://api.leaseweb.com/v1/bareMetals
<?php
$resource = '/bareMetals';
$apiKey   = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';

$apiUrl   = 'https://api.leaseweb.com/v1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Lsw-Auth: $apiKey"));
$output = curl_exec($ch);

echo $output;

<?php
$method   = "GET";
$resource = "/bareMetals";
$apiKey   = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

$apiUrl    = "https://api.leaseweb.com/v1";
$ctxParams = array("http" => array("method" => $method, "header" => "X-Lsw-Auth: $apiKey\r\n"));
$context   = stream_context_create($cparams);
$fp        = fopen($apiUrl . $resource, "rb", false, $context);
$result    = stream_get_contents($fp);

echo $result;

Now that you learned how to use our API, you may want to take a look to our complete API Reference.