By jeff403786
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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
It took me some searching and trial and error, but I think this is what you are looking for:
https://api.digitalocean.com/v2/images?per_page=999
So with curl, use something like:
curl -X GET --silent "https://api.digitalocean.com/v2/images?per_page=999" -H "Authorization: Bearer $TOKEN" |jq '.'
As you’ve noticed, results are now paginated. You can adjust the size of the page using the ?per_page= parameter. Check out the details in the docs.
Are you working in a specific language? There are already a number of clients and wrapper libraries that exist that deal with things like pagination for you.
Let us know how it goes!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.