node-gandi

Node.js client for Gandi.net XML-RPC API.

Usage no npm install needed!

<script type="module">
  import nodeGandi from 'https://cdn.skypack.dev/node-gandi';
</script>

README

node-gandi

npm version Build Status Dependency Status devDependency Status Inline docs

NPM

Node.js client for Gandi.net XML-RPC API.

Installation

  $ npm install --save node-gandi

Usage

Start by instantiating a Gandi client

  var cli = require('node-gandi');
  var apikey = 'your-24-char-apikey';

  var gandi = new cli(apikey); // or new cli(apikey, true); for OT&E

The client exposes four methods to use in your code.

gandi.call (method, params, callback)

Returns the result(s) of the API call to the method given in parameter.

  var gandi = new cli(apikey, true);
  var domain = 'pegase745.org';

  var cb = function(err, data) {
    if (data[domain] == 'pending') {
      console.log('result is not yet ready')
      setTimeout(function() {
        gandi.call('domain.available', [[domain]], cb);
      }, 700)
    }
    else {
      console.dir(data);
    }
  }

  gandi.call('domain.available', [[domain]], cb);

gandi.list (callback)

Returns the list of available methods in the API.

  var gandi = new cli(apikey, true);

  gandi.list(function(err, data) {
    if (err) throw err;
    console.log(data);
  });

gandi.signature (method, callback)

Returns the signature of the API method given in parameter.

  var gandi = new cli(apikey, true);

  gandi.signature('domain.list', function(err, data) {
    if (err) throw err;
    console.log(data);
  });

gandi.help (method, callback)

Returns a help for the API method given in parameter.

  var gandi = new cli(apikey, true);

  gandi.help('domain.list', function(err, data) {
    if (err) throw err;
    console.log(data);
  });

Run tests

  $ sudo ote_apikey=your-24-char-apikey npm test

License

MIT