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
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.
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: