NAV
PrimeXM DMCC
bash php python

Introduction

Our HTTP REST API allows you to manage vital details of your account and services in client portal. JSON is used for all API returns

Use left menu to browse trough available methods, use right menu to check required parameters, data to post and code samples in various languages.

Swagger Doc: You can download or display the JSON to generate documentation in Swagger.

Authentication

JSON Web Token Authentication

curl 'https://hosting.primexm.com/api/login' \
    -d username="username"\
    -d password="password"

# grab authentication token from the response and pass it in Authorization header
curl 'https://hosting.primexm.com/api/details' \
    -H "Authorization: Bearer $token"
$resp = $client->post('login', [
    'form_params' => [
        'username' => 'username',
        'password' => 'password'
    ]
]);

$token = $resp->json()['token'];

$resp = $client->get('details', [
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);

echo $resp->getBody();
payload = username
resp = requests.post('https://hosting.primexm.com/api/login', data=payload)

headers = {
    'Authorization': 'Bearer ' + req.json().token
}
resp = requests.get('https://hosting.primexm.com/api/details', headers=headers)
print(resp)

Make sure to replace username and password with your client area details.

To authenticate, you need to send a JSON Web Token (JWT) in the authorization header of the HTTP request.

To obtain the authorization token you need to submit a request with your username and password to POST https://hosting.primexm.com/api/login API method

All API calls that require authentication expect HTTP header in the form of Authorization: Bearer <token>.

For example:
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc...

Clientarea

Login

Generate new authorization token

POST_DATA="{
    \"username\": \"user@example.com\",
    \"password\": \"secret\"
}"

curl -X POST "https://hosting.primexm.com/api/login" \
   -H "Content-Type: application/json" \
   -d "${POST_DATA}"
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
]);

$options = [
    'json' => [
        "username" => "user@example.com",
        "password" => "secret"
    ]
]
$resp = $client->post('login', $options);
echo $resp->getBody();
payload = {
    'username': "user@example.com",
    'password': "secret"
}


req = requests.post('https://hosting.primexm.com/api/login', json=payload)
print(req.json())
Example Response:
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRw(...)5lZ9T79ft9uwOkqRRmIBbtR51_w",
    "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIzMD(...)ChwIAb3zvxBu6kvULa2AwAt9U-I"
}

HTTP Request

POST /login

Query Parameters

Parameter Type Description
username string

Your acount email address

password string

Account password

Logout

Invalidate authorization token


curl -X POST "https://hosting.primexm.com/api/logout" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->post('logout');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.post('https://hosting.primexm.com/api/logout', headers=headers)
print(req.json())
Example Response:
{
    "status": true
}

HTTP Request

POST /logout

Refresh Token

Generate new authorization token using refresh token

POST_DATA="{
    \"refresh_token\": \"refresh_tokenValue\"
}"

curl -X POST "https://hosting.primexm.com/api/token" \
   -H "Content-Type: application/json" \
   -d "${POST_DATA}"
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
]);

$options = [
    'json' => [
        "refresh_token" => "refresh_tokenValue"
    ]
]
$resp = $client->post('token', $options);
echo $resp->getBody();
payload = {
    'refresh_token': "refresh_tokenValue"
}


req = requests.post('https://hosting.primexm.com/api/token', json=payload)
print(req.json())
Example Response:
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHR(...)vY2xlYiHGvauCWZD9B0VwXgHEzXDllqY",
    "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJBQ(...)Rmivc_u3YA_kgDqOPtUuGNXOzueXYtZw"
}

HTTP Request

POST /token

Query Parameters

Parameter Type Description
refresh_token string

Refresh token previously obtained from POST /login

Revoke Token

Invalidate authorization and refresh token. Pass refresh token or call this method with valid access token

POST_DATA="{
    \"refresh_token\": \"refresh_tokenValue\"
}"

curl -X POST "https://hosting.primexm.com/api/revoke" \
   -H "Content-Type: application/json" \
   -d "${POST_DATA}"
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
]);

$options = [
    'json' => [
        "refresh_token" => "refresh_tokenValue"
    ]
]
$resp = $client->post('revoke', $options);
echo $resp->getBody();
payload = {
    'refresh_token': "refresh_tokenValue"
}


req = requests.post('https://hosting.primexm.com/api/revoke', json=payload)
print(req.json())
Example Response:
{
    "status": true
}

HTTP Request

POST /revoke

Query Parameters

Parameter Type Description
refresh_token string

User Logs

Returns logs from history


curl -X GET "https://hosting.primexm.com/api/logs" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->get('logs');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.get('https://hosting.primexm.com/api/logs', headers=headers)
print(req.json())

HTTP Request

GET /logs

Returns a list of all statuses with specific status


curl -X GET "https://hosting.primexm.com/api/statuses" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->get('statuses');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.get('https://hosting.primexm.com/api/statuses', headers=headers)
print(req.json())

HTTP Request

GET /statuses

Query Parameters

Parameter Type Description
status string

Returns details of status


curl -X PUT "https://hosting.primexm.com/api/statuses/@id" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->put('statuses/@id');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.put('https://hosting.primexm.com/api/statuses/@id', headers=headers)
print(req.json())

HTTP Request

PUT /statuses/@id

Query Parameters

Parameter Type Description
id int

Billing

Account balance

Get current account balance(unpaid invoices total), account credit


curl -X GET "https://hosting.primexm.com/api/balance" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->get('balance');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.get('https://hosting.primexm.com/api/balance', headers=headers)
print(req.json())
Example Response:
{
    {
        "success": true,
        "details": {
            "currency": "USD",
            "acc_balance": "123456.55",
            "acc_credit": "0.00"
        }
    }
}

HTTP Request

GET /balance

List Invoices

List all invoices under my account


curl -X GET "https://hosting.primexm.com/api/invoice" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->get('invoice');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.get('https://hosting.primexm.com/api/invoice', headers=headers)
print(req.json())
Example Response:
{
    "invoices": [
        {
            "id": "308976",
            "date": "2016-12-30",
            "dateorig": "2016-12-30",
            "duedate": "2017-01-06",
            "paybefore": "2017-01-06",
            "total": "19.65",
            "datepaid": "2016-12-30 12:40:47",
            "status": "Paid",
            "merge_id": null,
            "number": "2016\/12\/1",
            "currency": "USD"
        }
    ]
}

HTTP Request

GET /invoice

Invoice Details

Get invoice details


curl -X GET "https://hosting.primexm.com/api/invoice/@id" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->get('invoice/@id');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.get('https://hosting.primexm.com/api/invoice/@id', headers=headers)
print(req.json())
Example Response:
{
    "invoice": {
        "id": "308976",
        "status": "Paid",
        "date": "2016-12-30",
        "duedate": "2017-01-06",
        "paybefore": "2017-01-06",
        "datepaid": "2016-12-30 12:40:47",
        "subtotal": 16.24,
        "credit": 0,
        "tax": 3.41,
        "taxrate": 21,
        "tax2": 0,
        "taxrate2": 0,
        "taxexempt": "0",
        "total": 19.65,
        "rate": 1,
        "rate2": 0,
        "rate3": 1,
        "notes": "",
        "items": [
            {
                "id": "12305",
                "invoice_id": "308976",
                "type": "Other",
                "item_id": "0",
                "description": "Example Service",
                "amount": "15.00",
                "taxed": "1",
                "qty": "1.00",
                "linetotal": "15.00"
            },
            {
                "id": "12309",
                "invoice_id": "308976",
                "type": "Other",
                "item_id": "-2",
                "description": "PayPal Payment Fee",
                "amount": "1.24",
                "taxed": "1",
                "qty": "1.00",
                "linetotal": "1.24"
            }
        ],
        "client": {
            "id": "26",
            "email": "api@example.com",
            "firstname": "Joe",
            "lastname": "Doe",
            "companyname": "",
            "address1": "Pretty View Lane",
            "address2": "3194",
            "city": "Santa Rosa",
            "state": "California",
            "postcode": "95401",
            "country": "US",
            "phonenumber": "+1.24123123"
        },
        "number": "2016\/12\/1",
        "currency": "USD"
    }
}

HTTP Request

GET /invoice/@id

Query Parameters

Parameter Type Description
id int

Services

List services

List all services under your account


curl -X GET "https://hosting.primexm.com/api/service" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->get('service');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.get('https://hosting.primexm.com/api/service', headers=headers)
print(req.json())
Example Response:
{
    "services": [
        {
            "id": "301",
            "domain": "examplename.com",
            "total": "9.99",
            "status": "Pending",
            "billingcycle": "Monthly",
            "next_due": "2017-12-30",
            "category": "Hosting",
            "category_url": "hosting",
            "name": "Starter Hosting"
        }
    ]
}

HTTP Request

GET /service

Service details

Return details for service @id


curl -X GET "https://hosting.primexm.com/api/service/@id" \
   -H "Authorization: Bearer $token" 
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'https://hosting.primexm.com/api/',
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);


$resp = $client->get('service/@id');
echo $resp->getBody();

headers = {
    'Authorization': 'Bearer ' + token
}

req = requests.get('https://hosting.primexm.com/api/service/@id', headers=headers)
print(req.json())
Example Response:
{
    "service": {
        "id": "301",
        "date_created": "2016-12-30",
        "domain": "examplename.com",
        "firstpayment": "9.99",
        "total": "9.99",
        "billingcycle": "Monthly",
        "next_due": "2017-12-30",
        "next_invoice": "2017-01-27",
        "status": "Active",
        "label": "",
        "username": "examplen",
        "password": "pdtzc",
        "name": "Starter Hosting"
    }
}

HTTP Request

GET /service/@id

Query Parameters

Parameter Type Description
id int

Service id