Skip to content

Instantly share code, notes, and snippets.

@rohancme
Last active September 15, 2015 19:52
Show Gist options
  • Save rohancme/7788caff59b64b5adb39 to your computer and use it in GitHub Desktop.
Save rohancme/7788caff59b64b5adb39 to your computer and use it in GitHub Desktop.
Digital Ocean API v2 basics

Get list of available images

(Replace XXXXXX with your access token):

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer XXXXXX' "https://api.digitalocean.com/v2/images"

To pretty-print:

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer XXXXXX' "https://api.digitalocean.com/v2/images" |python -m json.tool

To pretty-print and filter only the slugs, use grep:

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer XXXXXX' "https://api.digitalocean.com/v2/images" |python -m json.tool| grep slug

Get list of your ssh-keys with their names and IDs:

curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer XXXXXX' "https://api.digitalocean.com/v2/account/keys" |python -m json.tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment