Skip to content

Automating Vultr with Curl

Vultr is a popular cloud hosting provider that offers a powerful API for managing your cloud resources. The Vultr API provides a wide range of functionality, allowing you to create, manage, and delete virtual machines, manage DNS, storage, and more. In this article, we will explore the basics of the Vultr API and how to interact with it using the curl command-line tool.

Getting Started with Vultr API

Before we dive into the API itself, let's first make sure we have everything set up to get started.

  1. First, you need to have a Vultr account. You can sign up for a new account or log in to your existing one at Vultr.com
  2. Next, you'll need to generate an API key. To do this, go to the API section of the Vultr control panel and create a new API key. Make sure to keep this key secure, as it grants access to your Vultr account.

Now that we have an API key, we can start interacting with the Vultr API.

Using the Vultr API with curl

Authentication exmaple

curl -H 'Authorization: Bearer <api-key>' https://api.vultr.com/v2/account

List regions

curl --location --request GET 'https://api.vultr.com/v2/regions'

List of all regions

ID       CITY               COUNTRY
ams      Amsterdam          NL
atl      Atlanta            US
blr      Bangalore          IN
bom      Mumbai             IN
cdg      Paris              FR
del      Delhi NCR          IN
dfw      Dallas             US
ewr      New Jersey         US
fra      Frankfurt          DE
hnl      Honolulu           US
icn      Seoul              KR
itm      Osaka              JP
jnb      Johannesburg       ZA
lax      Los Angeles        US
lhr      London             GB
mad      Madrid             ES
mel      Melbourne          AU
mex      Mexico City        MX
mia      Miami              US
nrt      Tokyo              JP
ord      Chicago            US
sao      São Paulo          BR
scl      Santiago           CL
sea      Seattle            US
sgp      Singapore          SG
sjc      Silicon Valley     US
sto      Stockholm          SE
syd      Sydney             AU
waw      Warsaw             PL
yto      Toronto            CA

List plans

curl --location --request GET 'https://api.vultr.com/v2/plans'

List of all plans

PLAN_ID                         CORES   RAM     DISK   BANDWIDTH   COST
"vc2-1c-1gb"                    1       1024    25     1024        5
"vc2-1c-1gb-sc1"                1       1024    25     1024        7.5
"vc2-1c-2gb"                    1       2048    55     2048        10
"vc2-1c-2gb-sc1"                1       2048    55     2048        15
"vc2-2c-4gb"                    2       4096    80     3072        20
"vc2-2c-4gb-sc1"                2       4096    80     3072        30
"vc2-4c-8gb"                    4       8192    160    4096        40
"vc2-4c-8gb-sc1"                4       8192    160    4096        60
"vc2-6c-16gb"                   6       16384   320    5120        80
"vc2-6c-16gb-sc1"               6       16384   320    5120        120
"vc2-8c-32gb"                   8       32768   640    6144        160
"vc2-8c-32gb-sc1"               8       32768   640    6144        240
"vc2-16c-64gb"                  16      65536   1280   10240       320
"vc2-16c-64gb-sc1"              16      65536   1280   10240       480
"vc2-24c-96gb"                  24      98304   1600   15360       640
"vc2-24c-96gb-sc1"              24      98304   1600   15360       960
"vhf-1c-1gb"                    1       1024    32     1024        6
"vhf-1c-1gb-sc1"                1       1024    32     1024        9
"vhf-1c-2gb"                    1       2048    64     2048        12
"vhf-1c-2gb-sc1"                1       2048    64     2048        18
"vhf-2c-2gb"                    2       2048    80     3072        18
"vhf-2c-2gb-sc1"                2       2048    80     3072        27
"vhf-2c-4gb"                    2       4096    128    3072        24
"vhf-2c-4gb-sc1"                2       4096    128    3072        36
"vhf-3c-8gb"                    3       8192    256    4096        48
"vhf-3c-8gb-sc1"                3       8192    256    4096        72
"vhf-4c-16gb"                   4       16384   384    5120        96
"vhf-4c-16gb-sc1"               4       16384   384    5120        144
"vhf-6c-24gb"                   6       24576   448    6144        144
"vhf-6c-24gb-sc1"               6       24576   448    6144        216
"vhf-8c-32gb"                   8       32768   512    7168        192
"vhf-8c-32gb-sc1"               8       32768   512    7168        288
"vhf-12c-48gb"                  12      49152   768    8192        256
"vhf-12c-48gb-sc1"              12      49152   768    8192        384
"vhp-1c-1gb-amd"                1       1024    25     2048        6
"vhp-1c-2gb-amd"                1       2048    50     3072        12
"vhp-2c-2gb-amd"                2       2048    60     4096        18
"vhp-2c-4gb-amd"                2       4096    100    5120        24
"vhp-4c-8gb-amd"                4       8192    180    6144        48
"vhp-4c-12gb-amd"               4       12288   260    7168        72
"vhp-8c-16gb-amd"               8       16384   350    8192        96
"vhp-12c-24gb-amd"              12      24576   500    12288       144
"vhp-1c-1gb-intel"              1       1024    25     2048        6
"vhp-1c-2gb-intel"              1       2048    50     3072        12
"vhp-2c-2gb-intel"              2       2048    60     4096        18
"vhp-2c-4gb-intel"              2       4096    100    5120        24
"vhp-4c-8gb-intel"              4       8192    180    6144        48
"vhp-4c-12gb-intel"             4       12288   260    7168        72
"vhp-8c-16gb-intel"             8       16384   350    8192        96
"vhp-12c-24gb-intel"            12      24576   500    12288       144
"voc-c-1c-2gb-25s-amd"          1       2048    25     4096        28
"voc-c-1c-2gb-25s-amd-sc1"      1       2048    25     4096        42
"voc-g-1c-4gb-30s-amd"          1       4096    30     4096        30
"voc-g-1c-4gb-30s-amd-sc1"      1       4096    30     4096        45
"voc-m-1c-8gb-50s-amd"          1       8192    50     5120        40
"voc-m-1c-8gb-50s-amd-sc1"      1       8192    50     5120        60
"voc-c-2c-4gb-50s-amd"          2       4096    50     5120        40
"voc-g-2c-8gb-50s-amd"          2       8192    50     5120        60
"voc-c-2c-4gb-50s-amd-sc1"      2       4096    50     5120        60
"voc-g-2c-8gb-50s-amd-sc1"      2       8192    50     5120        90
"voc-c-2c-4gb-75s-amd"          2       4096    75     5120        45
"voc-c-2c-4gb-75s-amd-sc1"      2       4096    75     5120        67.5
"voc-c-4c-8gb-75s-amd"          4       8192    75     6144        80
"voc-c-4c-8gb-75s-amd-sc1"      4       8192    75     6144        120
"voc-g-4c-16gb-80s-amd"         4       16384   80     6144        120
"voc-g-4c-16gb-80s-amd-sc1"     4       16384   80     6144        180
"voc-m-2c-16gb-100s-amd"        2       16384   100    6144        80
"voc-m-2c-16gb-100s-amd-sc1"    2       16384   100    6144        120
"voc-s-1c-8gb-150s-amd"         1       8192    150    4096        75
"voc-s-1c-8gb-150s-amd-sc1"     1       8192    150    4096        112.5
"voc-c-4c-8gb-150s-amd"         4       8192    150    6144        90
"voc-c-4c-8gb-150s-amd-sc1"     4       8192    150    6144        135
"voc-c-8c-16gb-150s-amd"        8       16384   150    7168        160
"voc-c-8c-16gb-150s-amd-sc1"    8       16384   150    7168        240
"voc-g-8c-32gb-160s-amd"        8       32768   160    7168        240
"voc-g-8c-32gb-160s-amd-sc1"    8       32768   160    7168        360
"voc-m-2c-16gb-200s-amd"        2       16384   200    6144        100
"voc-m-2c-16gb-200s-amd-sc1"    2       16384   200    6144        150
"voc-m-4c-32gb-200s-amd"        4       32768   200    8192        160
"voc-m-4c-32gb-200s-amd-sc1"    4       32768   200    8192        240
"voc-c-8c-16gb-300s-amd"        8       16384   300    7168        180
"voc-c-8c-16gb-300s-amd-sc1"    8       16384   300    7168        270
"voc-c-16c-32gb-300s-amd"       16      32768   300    8192        320
"voc-c-16c-32gb-300s-amd-sc1"   16      32768   300    8192        480
"voc-s-2c-16gb-320s-amd"        2       16384   320    6144        125
"voc-s-2c-16gb-320s-amd-sc1"    2       16384   320    6144        187.5
"voc-g-16c-64gb-320s-amd"       16      65536   320    8192        480
"voc-g-16c-64gb-320s-amd-sc1"   16      65536   320    8192        720
"voc-m-2c-16gb-400s-amd"        2       16384   400    6144        125
"voc-m-2c-16gb-400s-amd-sc1"    2       16384   400    6144        187.5
"voc-m-4c-32gb-400s-amd"        4       32768   400    8192        195
"voc-m-4c-32gb-400s-amd-sc1"    4       32768   400    8192        292.5
"voc-m-8c-64gb-400s-amd"        8       65536   400    9216        320
"voc-m-8c-64gb-400s-amd-sc1"    8       65536   400    9216        480
"voc-s-2c-16gb-480s-amd"        2       16384   480    6144        155
"voc-s-2c-16gb-480s-amd-sc1"    2       16384   480    6144        232.5
"voc-g-24c-96gb-480s-amd"       24      98304   480    9216        720
"voc-g-24c-96gb-480s-amd-sc1"   24      98304   480    9216        1080
"voc-c-16c-32gb-500s-amd"       16      32768   500    8192        360
"voc-c-16c-32gb-500s-amd-sc1"   16      32768   500    8192        540

List OS

curl --location --request GET 'https://api.vultr.com/v2/os'

List of all Operating Systems

OS_ID   OS_NAME                          OS_FAMILY
124     Windows 2012 R2 Standard x64     windows
159     Custom                           iso
164     Snapshot                         snapshot
167     CentOS 7 x64                     centos
180     Backup                           backup
186     Application                      application
240     Windows 2016 Standard x64        windows
270     Ubuntu 18.04 LTS x64             ubuntu
327     FreeBSD 12 x64                   freebsd
352     Debian 10 x64 (buster)           debian
371     Windows 2019 Standard x64        windows
381     CentOS 7 SELinux x64             centos
387     Ubuntu 20.04 LTS x64             ubuntu
391     Fedora CoreOS Stable             fedora-coreos
401     CentOS 8 Stream x64              centos
424     Fedora CoreOS Next               fedora-coreos
425     Fedora CoreOS Testing            fedora-coreos
447     FreeBSD 13 x64                   freebsd
448     Rocky Linux x64                  rockylinux
452     AlmaLinux x64                    almalinux
477     Debian 11 x64 (bullseye)         debian
501     Windows 2022 Standard x64        windows
521     Windows Core 2022 Standard x64   windows
522     Windows Core 2016 Standard x64   windows
523     Windows Core 2019 Standard x64   windows
535     Arch Linux x64                   archlinux
542     CentOS 9 Stream x64              centos
1743    Ubuntu 22.04 LTS x64             ubuntu
1744    Fedora 36 x64                    fedora
1797    OpenBSD 7.1 x64                  openbsd
1868    AlmaLinux 9 x64                  almalinux
1869    Rocky Linux 9 x64                rockylinux
1929    Fedora 37 x64                    fedora
1946    Ubuntu 22.10 x64                 ubuntu
1968    OpenBSD 7.2 x64                  openbsd

List applications

curl --location --request GET 'https://api.vultr.com/v2/applications'

Create an instance

curl -s --location --request POST 'https://api.vultr.com/v2/instances' \
--header "Authorization: Bearer <api-key>" \
--header 'Content-Type: application/json' \
--data-raw '{
    "region": "lax",
    "plan": "vc2-1c-1gb",
    "label": "test-instance",
    "hostname": "test-instance",
    "os_id": 1743,
    "backups": "disabled",
    "enable_ipv6": false
}'

Conclusion

In this article, we have explored the basics of using the Vultr API with curl. We started by authenticating with our API key and then demonstrated how to retrieve a list of all available plans and create an instance. The Vultr API is powerful and flexible, providing a wide range of functionality for managing your cloud resources. By using the curl command-line tool, you can easily integrate the Vultr API into your own scripts and automation workflows.

References

Vultr APIv2 Official Docs