Libraries

PHP

Installation using composer

In the composer.json file in your project add:

{
    "require" : {
        "websupport/api_php" : "~1.0"
    }
}

And then run:

composer install

Note: Requires PHP version 5.3 or higher and PHP cURL extension

Quick Start Example

$api = new \websupport\RestConnection('https://rest.websupport.sk/v1/', 'login', 'pass');
 
// load user info
try {
    $userInfo = $api->get('user/self'); 
    var_dump($userInfo);
} catch (\websupport\RestException $e) {
    var_dump($e); // error via exception
}
 
// order domain
try {
    $orderInfo = $api->post('user/self/order', array('services' => array(
        array('type'=>'domain', 'domain'=>'newdomain.com')
    )));
    var_dump($orderInfo);
} catch (\websupport\RestException $e) {
    var_dump($e); // error via exception
}

Python

Install requirements

pip install requests

Quick Start Example

import requests
import json
 
AUTH = 'login', 'pass'
 
def api(path, data={}, method=requests.get):
    result = method(
        'https://rest.websupport.sk/v1/%s' % path,
        headers={'Content-type': 'application/json', 'Accept': 'application/json'},
        auth=AUTH, data=json.dumps(data)
    )
    try:
        if result.status_code >= 400:
            raise Exception(result.json()['message'])
        return result.json()
    except (ValueError, KeyError): # catch json() or ['message']
        raise Exception(result.text)
 
 
# load user info
try:
    print api('user/self')
except Exception as e:
    print e.message
 
 
# order domain
try:
    print api('user/self/order', {
        "services": [
            {'type': 'domain', 'domain': 'newdomain.com'}
        ]
    }, method=requests.post)
except Exception as e:
    print e.message
raw