Learn how to use our API with our quick API guide
You can generate your API key at the Customer Portal.
For more information regarding API keys you can visit our Knowledge Base.
In order to access our API, you will need to issue your requests against https://api.leaseweb.com
To authenticate your call, add your API key to the request header `X-Lsw-Auth`
.
Now that you know how to authenticate an API call, it 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:
<?php
$resource = '/bareMetals/v2/servers';
$apiKey = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$apiUrl = 'https://api.leaseweb.com';
$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;
Now that you learned how to use our API, you may want to take a look to our complete API References.