Question

Why /v2/sizes doesn't returns all available sizes?

Hi, A GET request to “https://api.digitalocean.com/v2/sizes” should return a list of the available sizes. But when i try with

curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ****" "https://api.digitalocean.com/v2/sizes" | jq ".sizes[] | .slug"

I get

  • “512mb”
  • “s-1vcpu-1gb”
  • “1gb”
  • “s-1vcpu-2gb”
  • “s-1vcpu-3gb”
  • “s-2vcpu-2gb”
  • “s-3vcpu-1gb”
  • “2gb”
  • “s-2vcpu-4gb”
  • “4gb”
  • “c-2”
  • “s-4vcpu-8gb”
  • “8gb”
  • “c-4”
  • “s-6vcpu-16gb”
  • “16gb”
  • “c-8”
  • “s-8vcpu-32gb”
  • “s-12vcpu-48gb”
  • “32gb”

I have tried to resize a machine to a not-listed-above “c-16” size and its works! So my question is, why it is missing from the list returned by “/v2/sizes” ?


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
January 4, 2019
Accepted Answer

List responses from the DigitalOcean API are paginated. By default, only 20 items are listed in the first page. For example, this will return 20:

curl -X GET -H "Content-Type: application/json" \
    -H "Authorization: Bearer $DO_TOKEN" \
    "https://api.digitalocean.com/v2/sizes" | \
    jq ".sizes[] | .slug" | wc -l

If we made this query without the jq filter, we would see the response contains:

  "links": {
    "pages": {
      "last": "https://api.digitalocean.com/v2/sizes?page=2",
      "next": "https://api.digitalocean.com/v2/sizes?page=2"
    }
  },
  "meta": {
    "total": 29
  }

This indicates that there are additional results that can be accessed on the next page by appending the page=2 query parameter to the request.

If you want to access more than 20 results per page, you can adjust this using the per_page query parameter. The maximum number of results in a page is 200. So adjusting our request to use per_page=200:

curl -X GET -H "Content-Type: application/json" \
    -H "Authorization: Bearer $DO_TOKEN" \
    "https://api.digitalocean.com/v2/sizes?per_page=200" | \
    jq ".sizes[] | .slug" | wc -l

we get 29 results. Also, the links section of the response will be empty indicating that there are no additional pages.

Unfortunately, the API lists only sizes that are unlocked to you. I think the default is limited to sizes up to 100 USD/month. In the console, you can request to unlock larger sizes. It would be great if the API would list all sizes with an “unlocked” flag, instead, but this is not the case.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel