Cloudflare Reseller API Client
This module can be used as a client to access the Cloudflare Reseller and Host APIs. API documentation with the available actions and required parameters can be found on the Cloudflare documentation site:
This module can be install via npm:
$ npm install --save cloudflare-reseller
The .call()
method accepts three arguments:
- The name of the Cloudflare Reseller API action to call
- An object with the variables for the API call
- An optional callback function
If no callback function is passed to the call then a promise is returned. To use a callback instead, pass a callback function as the third argument.
var cloudflare = require('cloudlfare-reseller');
//Configure the API client with the Cloudflare API Host Key
cloudflare.configure('hostKey');
//Example of a promise-based call to the client
cloudlfare.call('user_lookup', {
unique_id: 'test'
})
.then(function(data) {
console.log(data);
})
.catch(function(err) {
console.log(err);
});
//Example of a callback-based call to the client
cloudflare.call('user_lookup', {
unique_id: 'test'
}, function(err, data) {
if (err) {
console.log(err);
} else {
console.log(data);
}
});