
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
digital-ocean-api
Advanced tools
A thin wrapper for the Digital Ocean API (v2)
First get the package through NPM
npm install digital-ocean-api
Now set it up inside your application
var DigitalOceanApi = require('digital-ocean-api');
var api = new DigitalOceanApi({
token: 'yourAccessToken'
});
All the methods utilize the same callback interface, except for the Paginator getPageRange method.
function(error, data) {};
Errors are created internally following the following pattern:
var error = new Error('message');
error.code = 'string_coded_error';
error.original = errorObject; // if applicable
These are the top-level errors (every callback can be return these errors)
When a method accesses a paginated resource, you can pass along a callback and exhaust the entire resource, or you don't provide a callback in which you will get an instance of Paginator, a helper utility to more easily work with multi- page resources.
var paginator = api.listDroplets();
The paginator implements the following methods:
The getPageRange is the only method to access the api inside this library which does not respect the same callback interface. Since it's an asynchronous function it will call the callback whenver it gets back results from a page. The order is rather random and as such it's important to provide an easy-to-use api to find out which page it is.
paginator.getPageRange(1, 5, function(error, data, page) {
});
Droplet actions always have a boolean and callback as it's last two arguments.
API.prototype.rebuildDroplet = function(id, image, tagged, callback)
If the tagged boolean is true, the id argument will be used as a tag instead and the action will be performed against all droplets with the specified tag. In that case, the result will be an array of actions.
The "tagged" argument is optional for the sake of backwards compatibility.
Refer to the actual API Documentation to learn what the returned values can be. Bear in mind that the returned data is sanitized.
Methods marked with a star (*) are paginated methods.
api.getUserInfo(function(err, info) {
});
// Exhaustive call (not recommended here)
api.listActions(function(err, actions) {
});
// Paginator object
var paginator = api.listActions();
api.getAction(id, function(err, action) {
})
// Exhaustive call
api.listDroplets(function(err, droplets) {
});
// Paginator object
var paginator = api.listDroplets();
// Exhaustive call (recommended)
api.listRegions(function(err, regions) {
});
// Paginator object
var paginator = api.listRegions();
// Exhaustive call (recommended)
api.listSizes(function(err, sizes) {
});
// Paginator object
var paginator = api.listSizes();
MIT
FAQs
A thin wrapper for the Digital Ocean API (v2)
We found that digital-ocean-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.