Libraries

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