DigitalOcean API client wrapper


A DigitalOcean API client for use with NodeJS.

var oa = require('oceanusancora'),
    fs = require('fs');
var client = oa.createClient({
  client_id:  'id',
  api_key:    'key'
client.droplets.list(function (errstatusCodebodyresponseres) {
  if (err) {
  console.log(JSON.stringify(res, null, 2, true));

Take a look in the examples folder for more examples.

Install using npm:

npm install oceanusancora

Below is a list of options you may use when calling any scripts you may have written

-c --client_id X
-a --api_key X
--timeout X(ms)
--proxy X
--encoding X

They are fairly self-explanatory no-cookies, timeout, proxy, encoding are all options to request. if using debug its reccomended you use --encoding utf8 or something similar as all you will see is a buffer otherwise in the response.

Because of these command line options you can try a few already from the examples section:

node examples/list_droplets.js -c <client_id> -a <api_key>
// Listing Domains 
// Create New Domain 
new(name, ip_address, cb)
// Show A Domain 
show(domain_id, cb)
// Destroy a Domain 
destroy(domain_id, cb)
// Listing Records for a given Domain 
records(domain_id, cb)
// Create a new Record for a given Domain 
newRecord(domain_id, record_type, data, options, cb)
// Show a Record for a given Domain 
showRecord(domain_id, record_id, cb)
// Destroy a Record for a given Domain 
destroyRecord(domain_id, record_id, cb)
// Edit a Record for a given Domain 
editRecord(domain_id, record_id, record_type, data, options, cb)
// Listing Droplets 
// Add a new Droplet 
new(name, size, image, region, options, cb)// options = {ssh_key_ids : 'string(CSV)', private_networking : boolean, backups_enabled: boolean} 
// Show a Droplet 
show(droplet_id, cb)
// Reboot a Droplet 
reboot(droplet_id, cb)
// Power Cycle a Droplet 
powerCycle(droplet_id, cb)
// Shut Down a Droplet 
shutDown(droplet_id, cb)
// Power Off a Droplet 
powerOff(droplet_id, cb)
// Power On a Droplet 
powerOn(droplet_id, cb)
// Reset root password on a Droplet 
passwordReset(droplet_id, cb)
// Resize a Droplet 
resize(droplet_id, size, cb)
// Make a Snapshot of a Droplet 
snapshot(droplet_id, name, cb)
// Restore a Droplet 
restore(droplet_id, image_id, cb)
// Rebuild a Droplet 
rebuild(droplet_id, image_id, cb)
// Rename a Droplet 
rename(droplet_id, name, cb)
// Destroy a Droplet 
destroy(droplet_id, scrub_data, cb)
// Listing Events 
show(event_id, cb)
// Listing Images 
list(filter, cb)
// Show an Image 
show(image, cb)
// Destroy an Image 
destroy(image, cb)
// Transfer an Image 
transfer(image, region_id, cb)
// Listing Regions 
// Listing Sizes 
// Listing SSH_Keys 
// Add a new SSH Key 
new(name, ssh_pub_key, cb)
// Show a SSH Key 
show(ssh_key_id, cb)
// Edit a SSH Key 
edit(ssh_key_id, options, cb) // options = {name: 'string', ssh_pub_key: 'string'} 
// Destroy a SSH Key 
destroy(ssh_key_id, cb)

npm test todo: further client testing; nock reply data does not represent what DigitalOcean responds with in all cases, but is currently unused.