Question

How to get all droplets size by API? When i send get on /v2/size return only 19

  • Posted October 10, 2020
  • API

How to get all droplets size by API? λ curl -X GET -H “Content-Type: application/json” -H “Authorization: Bearer MYnumber” “https://api.digitalocean.com/v2/sizes

retun only 19 results

Subscribe
Share

Hi, I get the same result, just 19 sizes available. I believe the API gives outdated list of available droplet sizes. The sizes differs to the plans available through DO control panel during droplet creation process. What may be interesting, I successfully created a droplet with the size that does not have corresponding plan. Here is the response I got after creation:

{"droplet":{"id":123456789,"name":"test-ubuntu2004","memory":1024,"vcpus":1,"disk":30,"locked":false,"status":"new","kernel":null,"created_at":"2020-10-10T19:32:21Z","features":[],"backup_ids":[],"next_backup_window":null,"snapshot_ids":[],"image":{"id":69463186,"name":"20.04 (LTS) x64","distribution":"Ubuntu","slug":"ubuntu-20-04-x64","public":true,"regions":["nyc3","nyc1","sfo1","nyc2","ams2","sgp1","lon1","ams3","fra1","tor1","sfo2","blr1","sfo3"],"created_at":"2020-09-03T02:05:57Z","min_disk_size":15,"type":"base","size_gigabytes":2.36,"description":"Ubuntu 20.04 x86","tags":[],"status":"available"},"volume_ids":[],"size":{"slug":"1gb","memory":1024,"vcpus":1,"disk":30,"transfer":2.0,"price_monthly":10.0,"price_hourly":0.01488,"regions":["ams2","ams3","blr1","fra1","lon1","nyc1","nyc2","nyc3","sfo1","sfo2","sfo3","sgp1","tor1"],"available":true},"size_slug":"1gb","networks":{"v4":[],"v6":[]},"region":{"name":"London 1","slug":"lon1","features":["private_networking","backups","ipv6","metadata","install_agent","storage","image_transfer"],"available":true,"sizes":["s-1vcpu-1gb","512mb","s-1vcpu-2gb","1gb","s-3vcpu-1gb","s-2vcpu-2gb","s-1vcpu-3gb","s-2vcpu-4gb","2gb","s-4vcpu-8gb","m-1vcpu-8gb","c-2","4gb","c2-2vcpu-4gb","g-2vcpu-8gb","gd-2vcpu-8gb","m-16gb","s-8vcpu-16gb","s-6vcpu-16gb","c-4","8gb","c2-4vpcu-8gb","m-2vcpu-16gb","m3-2vcpu-16gb","g-4vcpu-16gb","gd-4vcpu-16gb","m6-2vcpu-16gb","m-32gb","s-8vcpu-32gb","c-8","16gb","c2-8vpcu-16gb","m-4vcpu-32gb","m3-4vcpu-32gb","g-8vcpu-32gb","s-12vcpu-48gb","gd-8vcpu-32gb","m6-4vcpu-32gb","m-64gb","s-16vcpu-64gb","c-16","32gb","c2-16vcpu-32gb","m-8vcpu-64gb","m3-8vcpu-64gb","s-20vcpu-96gb","48gb","m6-8vcpu-64gb","m-128gb","s-24vcpu-128gb","64gb","c2-32vpcu-64gb","m-16vcpu-128gb","m3-16vcpu-128gb","s-32vcpu-192gb","m-24vcpu-192gb","m-224gb","m6-16vcpu-128gb","m3-24vcpu-192gb","m6-24vcpu-192gb","m3-32vcpu-256gb","m6-32vcpu-256gb"]},"tags":["test"]},"links":{"actions":[{"id":1041287508,"rel":"create","href":"https://api.digitalocean.com/v2/actions/1041287508"}]}}

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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The examples below use jq, make sure you install it too.

The API returns the total number of available sizes:

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer <token>" "https://api.digitalocean.com/v2/sizes" | jq '.meta.total'

From that, you can call the API with a per_page query parameter set to the total. At the time of writing this, there are 70 sizes, so I do:

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer <token>" "https://api.digitalocean.com/v2/sizes?per_page=70" | jq

This seems rather accurate given what I see in the UI.