WebSoftSolus API
Language: | English |
---|
Contents
Introduction
What is WebSoftSolus API ?
WebSoftSolus API is a Web service allowing WebSoftSolus customers to buy, manage, upgrade and configure WebSoftSolus products without using the graphical customer interface.
Based on the RESTful API, you will be able to manage, in the future, nearly anything by using simple API functions and small code samples developed in your favorite language.
How to use the API
Creating API Key
To create your API Key please visit the API section on your WebSoftSolus Customer Area.
API URL
The API uses the HTTPS protocol. The API URL is :
https://api.websoftsolus.com/
For test environment simply add "test" at the end of the url, like this :
https://api.websoftsolus.com/test/
Parameters can be passed using standard HTTP techniques:
- via the URL
- using 'x-www-form-urlencoded' content-type for PUT and POST request.
Authentification
WebSoftSolus API uses a Token Based Authentication. All request to the API need to include that token inside the HTTP header. We usually call the API Key a 'secret'.
The following examples use the 'curl' command line tool.
Example: get a new token
# curl -k -d 'login=user@domain.com&secret=5355d07c0d23f24de2d1d61a2c3e32090548b0df7' https://api.websoftsolus.com/access/token { "access_token":"1fe322a09e1fe29feb2dbe6730241945c918d5b9", "expires_in":3600, "token_type":"Bearer" }
You need construct an Authorization headers and pass the returned "token_type" and "access_token" inside the HTTP header to any further request:
# curl -k -XGET -H 'Authorization: Bearer 1fe322a09e1fe29feb2dbe6730241945c918d5b9' https://api.websoftsolus.com/license/plesk
Example PHP Code
Get a new token
<?php $path = 'access/token'; $postfields['login'] = 'user@domain.com'; $postfields['secret'] = '5355d07c0d23f24de2d1d61a2c3e32090548b0df7'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.websoftsolus.com/$path"); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields)); $result = curl_exec($ch); if (curl_error($ch)) { die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); } curl_close($ch); $result = json_decode($result, true); print_r($result); ?>
Example Output :
Array ( [access_token] => 1fe322a09e1fe29feb2dbe6730241945c918d5b9 [expires_in] => 3600 [token_type] => Bearer )
Get Plesk licences list
<?php $path = 'license/plesk'; $access_token = '1fe322a09e1fe29feb2dbe6730241945c918d5b9'; $token_type = 'Bearer'; $method = 'GET'; $postfields = array(); $header = array(); $header[] = "Authorization: $token_type $access_token"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.websoftsolus.com/$path"); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); switch ($method) { case 'GET': break; case 'PUT': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields)); break; case 'POST': curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields)); break; case 'DELETE': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); break; default: echo 'Error: Invalid HTTP Method specified'; break; } $result = curl_exec($ch); if (curl_error($ch)) { die("Connection Error: ".curl_errno($ch).' - '.curl_error($ch)); } curl_close($ch); $result = json_decode($result, true); print_r($result); ?>
Example Output :
Array ( [0] => PLSK.0298xxxx [1] => PLSK.0292xxxx [2] => PLSK.0293xxxx [3] => PLSK.0297xxxx [4] => PLSK.0290xxxx [5] => PLSK.0294xxxx )
API documentation
Get Access Token
Path /access/token Method POST Parameters login (required|string) : your API Login. secret (required|string) : your API Key.
Plesk Licenses
Get all licenses
Path /license/plesk Method GET
Get license properties
Path /license/plesk/{keyNumber} Method GET
Edit license Title and Comment
Path /license/plesk/{keyNumber} Method PUT Parameters title (required|string) : Desired license title comment (required|can be empty) : Desired license comment
Terminate license
Path /license/plesk/{keyNumber} Method DELETE
Order license
Get the orderable versions
Path /license/plesk/order Method GET
Create order
Path /license/plesk/order Method POST Parameters product (required|string) : The product Name title (required|string) : Desired license title comment (required|can be empty) : Desired license comment period (required|string) [1|3|6|12|24|36] : Renew period in months os (required|string) [LINUX|WINDOWS] {Plesk 10 Only Option} WPBSites (required|string) [0|10|30|100|1000] {10 and 30 is Plesk 12 Only Option} WPBOptions (required|string) [0|MLS_SUPPORT] {Plesk 12 Only Option} applications (required|string) [0|POWER_PACK] CBMClients (required|string) [0|UNLIMITED] {Plesk 10 Only Option} languagePack (required|string) [0|1|2|3|4|5|UNLIMITED] {UNLIMITED is Plesk 12 Only Option} antivirus (required|string) [0|PREMIUM_ANTIVIRUS|PREMIUM_ANTIVIRUS_FOR_WIN] {PREMIUM_ANTIVIRUS_FOR_WIN is Plesk 12 Only Option}
cPanel & WHM Licenses
Get all licenses
Path /license/cpanel Method GET
Get license properties
Path /license/cpanel/{keyNumber} Method GET
Edit license Title and Comment
Path /license/cpanel/{keyNumber} Method PUT Parameters title (required|string) : Desired license title comment (required|can be empty) : Desired license comment
Terminate license
Path /license/cpanel/{keyNumber} Method DELETE
Order license
Get the orderable versions
Path /license/cpanel/order Method GET
Create order
Path /license/cpanel/order Method POST Parameters product (required|string) : The product Name title (required|string) : Desired license title comment (required|can be empty) : Desired license comment serverIP (required|string) : Server IP Address period (required|string) [1|3|6|12|24|36] : Renew period in months addons (optional|array|can be empty) [FANTASTICO|INSTALLATRON|SOFTACULOUS|WHMXTRA|WHMSONIC|CLOUDLINUX|KERNELCARE]
Virtuozzo Licenses
Get all licenses
Path /license/virtuozzo Method GET
Get license properties
Path /license/virtuozzo/{keyNumber} Method GET
Edit license Title and Comment
Path /license/virtuozzo/{keyNumber} Method PUT Parameters title (required|string) : Desired license title comment (required|can be empty) : Desired license comment
Terminate license
Path /license/virtuozzo/{keyNumber} Method DELETE
Order license
Get the orderable versions
Path /license/virtuozzo/order Method GET
Create order
Path /license/virtuozzo/order Method POST Parameters product (required|string) : The product Name title (required|string) : Desired license title comment (required|can be empty) : Desired license comment period (required|string) [1|3|6|12|24|36] : Renew period in months os (required|string) [LINUX|WINDOWS]