node package manager


nodejs wrapper for digitalocean v2 api


digitalocean-node is a library for nodejs to access the DigitalOcean v2 API.

npm install digitalocean --save
var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.droplets.create(options, callback);
client.droplets.get(123, callback);
client.droplets.delete(123, callback);
client.droplets.powerOff(123, callback);
client.droplets.getAction(123, 456, callback);

See below for all resources and actions

var client = digitalocean.client('TOKEN');
client.get('/account', {}, function (errstatusbodyheaders) {
  console.log(body); //json object 

The DigitalOcean client depends on request, and options can be passed through (e.g. a proxy or user agent).

var client = digitalocean.client('TOKEN', {
  request: myInitializedRequestObject,
  requestOptions: {
    proxy: '',
    headers: {
      'User-Agent': 'foo'

All the callbacks for the following will take first an error argument, then a data argument, the headers, then the raw response. For example:

client.account.get(function(erraccountheadersresponse) {
  console.log("error: " + err);
  console.log("account: " + account);
  console.log("headers: " + headers);
  console.log("response: " + response);

If a function is said to be supporting pagination, then that function can be used in many ways as shown below. Results from the function are arranged in pages.

The page argument is optional and is used to specify which page of objects to retrieve. The perPage argument is also optional and is used to specify how many objects per page.

// Normal usage of function 
client.droplets.list(callback); // Callback receives an array of first 25 issues 
// Using pagination parameters 
client.droplets.list(2, 100, callback); // Callback receives an array of second 100 issues 
client.droplets.list(10, callback); // Callback receives an array of 25 issues from page 10 
// Pagination parameters can be set with query object too 
  page: 2,
  per_page: 100
}, callback); //array of second 100 issues which are closed 

To fetch all the pages of a resource, the pages must be traversed. For example, to fetch all Droplets:

listPagesUntilDone(1, function(allDroplets) {
function listPagesUntilDone(pagecallbackarray) {
  client.droplets.list(page, function(errdroplets_response) {
    if (err) {
      return console.error('Error fetching pages', err);
    if (array === undefined) {
      array = [];
    array = array.concat(droplets);
    // has no pages or has pages and has no last page 
    var isLastPage = response['links'] && (
      !response['links']['pages'] ||
        (response['links']['pages'] && response['links']['pages']['last'] === undefined)
    if (!err && isLastPage) {, array);
    } else if (!err && !isLastPage) {
      listPagesUntilDone(page + 1, callback, array);
    } else {
      // whoops, try again 
      listPagesUntilDone(page, callback, array);

You can also check your rate limit status by calling the following.

client.droplets.list(function (erraccountheadersresponse) {
  console.log(headers['ratelimit-remaining']); // 4999 
  console.log(headers['ratelimit-limit']);  // 5000 
  console.log(headers['ratelimit-reset']);  // Time in Unix Epoch, e.g. 1415984218 

This library is also available as a single file built for usage in the browser at dist/digitalocean.js. It uses browserify to package all dependencies and output the built file. This file is updated and released to Bower for each release with the same version.

For example, using the built file at dist/digitalocean.js:

    <script src="dist/digitalocean.js"></script> 
      var client = digitalocean.client('TOKEN');
      client.account.get(function(_account) {

Where you see attributes it is a plain JavaScript object, e.g. { email: '' }

var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  • client.droplets.list([page, perPage,] callback)
  • client.droplets.get(, callback)
  • client.droplets.create(attributes, callback)
  • client.droplets.delete(, callback)
  • client.droplets.deleteByTagName(, callback)
  • client.droplets.kernels([page, perPage,], callback)
  • client.droplets.snapshots([page, perPage,], callback)
  • client.droplets.backups([page, perPage,], callback)
  • client.droplets.neighbors([page, perPage,], callback)
  • client.droplets.listActions([page, perPage,], callback)
  • client.droplets.getAction(,, callback)

For the latest valid attributes, see the official docs.

Methods resulting in an action:

  • client.droplets.actionByTag(, actionType, callback)
  • client.droplets.reboot(, callback)
  • client.droplets.powerCycle(, callback)
  • client.droplets.shutdown(, callback)
  • client.droplets.powerOff(, callback)
  • client.droplets.powerOn(, callback)
  • client.droplets.passwordReset(, callback)
  • client.droplets.enableIpv6(, callback)
  • client.droplets.enableBackups(, callback)
  • client.droplets.disableBackups(, callback)
  • client.droplets.enablePrivateNetworking(, callback)
  • client.droplets.snapshot(, parametersOrName, callback)
  • client.droplets.changeKernel(, parametersOrKernelId, callback)
  • client.droplets.rename(, parametersOrHostname, callback)
  • client.droplets.rebuild(, parametersOrImage, callback)
  • client.droplets.restore(, parametersOrImageId, callback)
  • client.droplets.resize(, parametersOrSizeSlug, callback)
var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  •[page, perPage,] callback)
  •, callback)
  •, callback)
  •, callback)
  •[page, perPage,], callback)
  •, attributes, callback)
  •,, callback)
  •,, callback)
  •,,, attributes, callback)

For the latest valid domain attributes, see the official docs. For the latest valid domain record attributes, see the official docs.

var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  • client.images.list([page, perPage,] callback)
  • client.images.get(, callback)
  • client.images.delete(, callback)
  • client.images.update(, attributes, callback)
  • client.imageActions.list([page, perPage,], callback)
  • client.imageActions.get([page, perPage,],, callback)

Methods resulting in an action:

  • client.imageActions.transfer(, parametersOrRegionSlug, callback)
  • client.imageActions.convert(, callback)
var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  • client.regions.list(callback)
var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  • client.sizes.list(callback)
var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  • client.account.get(callback)
  • client.account.listSshKey([page, perPage,] callback)
  • client.account.createSshKey(attributes, callback)
  • client.account.getSshKey(, callback)
  • client.account.deleteSshKey(, callback)
  • client.account.updateSshKey(, attributes, callback)

For the latest ssh key valid attributes, see the official docs.

var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  • client.floatingIps.list([page, perPage,] callback)
  • client.floatingIps.get(floatingIp.ip, callback)
  • client.floatingIps.create(attributes, callback)
  • client.floatingIps.delete(floatingIp.ip, callback)
  • client.floatingIps.listActions([page, perPage,] callback)
  • client.floatingIps.getAction(floatingIp.ip, callback)

For the latest valid attributes, see the official docs.

Methods resulting in an action:

  • client.floatingIpActions.assign(floatingIp.ip, parametersOrDropletId, callback)
  • client.floatingIpActions.unassign(floatingIp.ip, callback)
var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
  • client.tags.list([page, perPage,] callback)
  • client.tags.get(, callback)
  • client.tags.create(attributes, callback)
  • client.tags.update(, attributes, callback)
  • client.tags.tag(, [{resource_id: , resource_type: }], callback)
  • client.tags.untag(, [{resource_id: , resource_type: }], callback)
  • client.tags.delete(, callback)

For the latest valid attributes, see the official docs.

  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
npm test


npm run release:patch # or release:minor or release:major depending on the type of version bump 


Based on the work of @pksunkara in octonode.