I frequently need to check the
id of a particular Droplet image (or in AWS parlance, an AMI) that I can use to launch new DigitalOcean droplets via Ansible. And seeing as tonight I had to search for 'how to get a list of all DigitalOcean images' about the hundredth time, I figured I'd publish this in a blog post so I can find it more easily in the future.
Without further ado:
curl -X GET --silent "https://api.digitalocean.com/v2/images?per_page=999" -H "Authorization: Bearer $DO_API_TOKEN"
This assumes you have
exported a valid
$DO_API_TOKEN previously. If not, just paste your DigitalOcean API token in place of
$DO_API_TOKEN, and then run the command.
It dumps out a ton of JSON, so you can either paste it through something like http://jsonprettyprint.com, or try reading it in all it's unformatted glory. And if the latter, are you a robot?
Bonus trick: If you're on a Mac, you can add
| pbcopy to the end of that command to have the output stuck into your clipboard, for easy pasting.