Where is the images list for the V2 api?

August 28, 2014 5.2k views

How do I get a list of the global images available in the v2 api? the following, which is a v2 implementation of the older v1 query doesn’t seem to return everything:
curl -s “https://api.digitalocean.com/v2/images?filter=global” -H “Authorization: Bearer $DO_TOKEN” |grep “name”
“name”:“Ruby on Rails on Ubuntu 14.04 (Nginx + Unicorn)”,
“name”:“node-v0.10.30 on Ubuntu 14.04”,
“name”:“Django on Ubuntu 14.04”,
“name”:“LAMP on Ubuntu 14.04”,
“name”:“LEMP on Ubuntu 14.04”,
“name”:“Docker 1.1.2 on Ubuntu 14.04”,
“name”:“MEAN on Ubuntu 14.04”,
“name”:“Dokku v0.2.3 on Ubuntu 14.04 (w/ Docker 1.1.2)”,
“name”:“GitLab 7.1.1 CE”,
“name”:“Ghost 0.5 on Ubuntu 14.04”,
“name”:“Redmine on Ubuntu 14.04”,
“name”:“WordPress on Ubuntu 14.04”,
“name”:“CentOS 5.8 x64”,
“name”:“CentOS 5.8 x32”,
“name”:“CentOS 6.4 x32”,
“name”:“CentOS 6.4 x64”,
“name”:“Fedora 19 x32”,
“name”:“Fedora 19 x64”,
“name”:“Fedora 20 x32”,
“name”:“Fedora 20 x64”,

I’m trying to script to be able to find the Ubuntu 14.04 images. Yes, I could just hard-code the image ID, and I have that already, but I want to programmatically get the list of available generic images to launch instances with.

I noticed that the results are paginated… is there some way to get non-paginated results instead? That seems to have been the issue. If I hardcode the URL to include &page=2, i can find the images I’m looking for, but I’d much rather have an api result that lists all instead of paginating the results.

2 Answers

It took me some searching and trial and error, but I think this is what you are looking for:


So with curl, use something like:

curl -X GET --silent "https://api.digitalocean.com/v2/images?per_page=999" -H "Authorization: Bearer $TOKEN" |jq '.'

To get just the names used for provisioning with Ansible, add “| grep slug” to the end of the curl command provided by minimalpair above.

curl -X GET –silent “https://api.digitalocean.com/v2/images?per_page=999” -H “Authorization: Bearer $TOKEN” | jq ’.’ | grep slug

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!