We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Use the DigitalOcean API (Deprecated)

PostedApril 2, 2013 42.4k views DigitalOcean

DigitalOcean API v1 is Deprecated

Note: This article is for the deprecated DigitalOcean API v1. Click the following link for information about the new API: How To Use the DigitalOcean API v2

About the DigitalOcean API

The DigitalOcean API provides a complete way to manage your DigitalOcean assets without the control panel.

Any action you can perform to your droplets, images, and SSH keys can also be done with the API, as described here.

In order to use the API, you need your client key and API key.

Step One - Create your API key

Before we do anything with the API, we'll need an API key associated with a client key.

From your control panel, click on the "My Settings" link in the left-hand sidebar. In your settings, click "API Access".

API Access

Take note of your client key; it's unique to your account and should be kept private.

At this point, you don't have an API key yet, so let's make one by clicking "Generate a new API Key".

When your API key appears, be sure to take note of it. It will never be visible on this page again.

Both a client key and its associated API key are required to use the API. It's important not to forget them.

Step Two - Use the API

The entire API specification can be found here.

All API requests are in the form:


For example, to list all of your droplets and their information:


Using Wrappers for the API

A variety of wrappers exist for the API in different languages. These can be found on GitHub and can be useful for integrating the API into a script or program.

Here is an example of using the API using a Python wrapper, dop, provided by Antonio Montero.

To install Python packages, the preferred method is pip. Install it with:

curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py

Next, we can install dop using pip:

pip install dop

In the Python interactive shell, we can see how it works:

Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from dop.client import Client
>>> client = Client('QWeRtyUIoPASDFGhJk1lz', 'dummyOwkdBo1Bwdcfoj8oBNkwoAQ17dvbwJWOkdLh')
>>> droplets = client.show_active_droplets()
>>> for droplet in droplets:
...     print droplet.to_json()
{'status': u'active', 'region_id': 1, 'event_id': 11, 'size_id': 66, 'image_id': 1234, 'backups_active': True, 'ip_address': u'', 'id': 12345, 'name': u'test1'}
{'status': u'active', 'region_id': 1, 'event_id': 21, 'size_id': 66, 'image_id': 4321, 'backups_active': True, 'ip_address': u'', 'id': 54321, 'name': u'test2'}
{'status': u'active', 'region_id': 1, 'event_id': 31, 'size_id': 64, 'image_id': 4444, 'backups_active': None, 'ip_address': u'', 'id': 55555, 'name': u'test3'}

You can leverage any wrapper to your advantage in an automated environment.


Currently, the API (even the control panel) does not support resizing droplets to 96 GB droplets.

Resizes through the API are performed with the "fast-resize" as shown in the control panel. Therefore, resizing a droplet through the API will not change its disk space. At present, API calls to a non-existent droplet, image, size, or region will return a 200 OK status code with a JSON response including an "error_message" key.

By Justin Kim


Creative Commons License