Client API

Getting Started

Before you can start using the client API you first need to enable API access. This needs to be done by logging into the client area, clicking on 'Hello, <NAME>', then 'Client API', then the 'API Status' tab and finally the 'Enable API' button.

API End Point

Each API request should be directed to:

https://customer.ndchost.com/index.php

The client API accepts parameters using either POST or GET. We always recommend using POST!

Required Parameters

The following parameters are always required when making a API request.

  • m - This parameter will always be set to clientapi
  • apikey - Used to authenticate your API request, without it your API request will fail.
  • apimodule - The API module you wish to use
  • apifunction - The function provided by the module you wish to run

Modules and Functions

Below are a list of modules and it's corresponding functions.

client

  • getdetails

cpanellicensing

Example API request using the curl command

Below shows how one could make a simple API request using curl to retrieve your current client details

curl https://customer.ndchost.com/whmcs/index.php \
-d m=clientapi \
-d apikey=supersecretkey \
-d apimodule=client \
-d apifunction=getdetails

Example API request using PHP's curl function

<?PHP
// Required Parameters
$post['m'] = 'clientapi';
$post['apikey'] = 'supersecretkey';
$post['apimodule'] = 'client';
$post['apifunction'] = 'getdetails';
 
// Curl Init
$ch = curl_init();
if($ch === false) die('Curl Error: curl_init failed');
 
// Curl Options
curl_setopt($ch, CURLOPT_URL, 'https://customer.ndchost.com/whmcs/index.php' );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 
// Curl Result
$result = curl_exec($ch);
if($result === false) die(curl_error($ch));
 
// Result Info
$curlinfo = @curl_getinfo($ch);
if($curlinfo['content_type'] != 'application/json') die("api response was not JSON\n");
 
// Decode JSON into an array
$result = @json_decode($result, true);
if(!is_array($result)) die("failed to decode JSON response\n");
 
// Print out result
print_r($result);

Example JSON response

{
   "status":"success",
   "message":"successfully retrieved client details",
   "data":{
      "id":"1",
      "firstname":"Test",
      "lastname":"Client",
      "companyname":"",
      "email":"testclient@domain.com",
      "address1":"1001 Ave Pico",
      "address2":"",
      "city":"San Clemente",
      "state":"Ca",
      "postcode":"92673",
      "country":"US",
      "phonenumber":"123-456-7890",
      "defaultgateway":"paypal",
      "credit":"0.00",
      "billingcid":"0",
      "lastlogin":"2012-08-01 18:30:56",
      "ip":"204.10.36.76",
      "host":"staff.ndchost.com",
      "status":"Active"
   }
}