whmcs-sdk
v0.1.4
Published
A comprehensive and easy-to-use Node SDK, designed to simplify interactions with the WHMCS API and streamline your development process.
Downloads
537
Readme
WHMCS SDK
A comprehensive and easy-to-use Node SDK, designed to simplify interactions with the WHMCS API and streamline your development process.
Table of Contents
Useful Info
- Install Node.js version 20.0.0 or higher.
- Only API Credentials are supported for authenticating (username and password is depreciated as of 7.2!)
- For a full list of Modules/Methods visit the WHMCS Docs
Installation
To install the WHMCS SDK, use your preferred package manager:
NPM
npm install whmcs-sdk
Bun
bun install whmcs-sdk
Yarn
yarn install whmcs-sdk
Implemented Functions
There is a variety of pre-made functions you can use to help make your experience more seamless.
Main Functions
- call(action, options)
Helper Functions
- get(action, options): An alias of
call
but appendsGet
to the name. - add(action, options): An alias of
call
but appendsAdd
to the name. - update(action, options): An alias of
call
but appendsUpdate
to the name. - delete(action, options): An alias of
call
but appendsDelete
to the name.
The "action" (string) is the name of a WHMCS API Index name. The "options" (object) of any parameters you want to pass in.
Usage
To use the module you will first need to import it:
import { whmcsApi } from 'whmcs-sdk';
you can then instantiate a new client with options:
const whmcs = new whmcsApi({
host: 'yourwebsite.com',
identifier: 'api identifier',
secret: 'api secret'
//endpoint: 'includes/api.php', //only required if you changed the api.php location
});
Using the client
whmcs.call('DomainWhois', {
domain: 'whmcs.com'
}, function (err, res, body) {
if (err) return console.log('Error:', err);
console.log('Domain information:', body);
});
Using the Helper Functions
whmcs.get('Servers')
.then(servers => console.log('Servers:' servers))
.catch(err => console.error('Error:', err));