Skip to main content

Python Library for Vultr API

The unofficial python library for the Vultr API.

CI PyPI

Python 3.6.8 codecov

pre-commit

security: bandit Imports: isort Code style: black

Installation

pip install -U pyvultr

Usage

Configuration

from pyvultr import VultrV2

# Set your api key or we'll get it from env `VULTR_API_KEY`.
VULTR_API_KEY = '...'

v2 = VultrV2(api_key=VULTR_API_KEY)

Get Account

account = v2.account.get()
print(account)

List Region

regions: VultrPagination[BackupItem] = v2.region.list()

# Here `regions` is a VultrPagination object, you can use it like list, eg: get by index or slice.
# VultrPagination will help you automatically get the next page when you need it.

print(regions[3:5])
# >>> [RegionItem(id='dfw', country='US', options=['ddos_protection'], continent='North America', city='Dallas'), RegionItem(id='ewr', country='US', options=['ddos_protection', 'block_storage'], continent='North America', city='New Jersey')]

print(regions[12])
# >>> RegionItem(id='ord', country='US', options=['ddos_protection'], continent='North America', city='Chicago')

# Of course you can use `for` to iterate all items.
# But be careful, it will cause a lot of requests if it's has a lot of data.
for region in regions:
    print(region)

# A smarter way to iterate is to determine the number of iterations you want.
smart_regions: VultrPagination[RegionItem] = v2.region.list(capacity=3)
for region in smart_regions:
    print(region)
# >>> RegionItem(id='ams', country='NL', options=['ddos_protection'], continent='Europe', city='Amsterdam')
# >>> RegionItem(id='atl', country='US', options=['ddos_protection'], continent='North America', city='Atlanta')
# >>> RegionItem(id='cdg', country='FR', options=['ddos_protection'], continent='Europe', city='Paris')

# At last, you can get all data just like calling attributes (better programming experience if you use IDE):
first_region: RegionItem = regions.first()
print(first_region.country, first_region.city)
# >>> NL Amsterdam

CLI

PyVultr also provides a command line interface.
It's a simple wrapper of the python library using Fire, and it has a beautiful output by using Pygments.
It registered a command pyvultr in the system, so you can just type pyvultr to use it:

# please setup Your API Key first:
# you can generate your API Key from https://my.vultr.com/settings/#settingsapi
# export VULTR_API_KEY="..."

# show help by type `pyvultr`
$ pyvultr

pyvultr cli usage is very similar to the python library usage. let's explain this with get account information api :

In Python:

from pyvultr import VultrV2

# here we get api key from env `VULTR_API_KEY`
VultrV2().account.get()
>>> AccountInfo(name='test man', email='test@xxx.xxx', acls=['manage_users', 'subscriptions_view', 'subscriptions', 'billing', 'support', 'provisioning', 'dns', 'abuse', 'upgrade', 'firewall', 'alerts', 'objstore', 'loadbalancer', 'vke'], balance=11.2, pending_charges=3.4, last_payment_date='2019-07-16T05:19:50+00:00', last_payment_amount=-10)

In CLI:

$ pyvultr account get
{
    "name": "test man",
    "email": "test@xxx.xxx",
    "acls": [
        "manage_users",
        "subscriptions_view",
        "subscriptions",
        "billing",
        "support",
        "provisioning",
        "dns",
        "abuse",
        "upgrade",
        "firewall",
        "alerts",
        "objstore",
        "loadbalancer",
        "vke"
    ],
    "balance": 11.2,
    "pending_charges": 3.4,
    "last_payment_date": "2019-07-16T05:19:50+00:00",
    "last_payment_amount": -10
}

Actually, we have a beautiful output:

CLI Example

Testing

python -m pytest -v

Metadata

Release files for pyvultr 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvultr 0.1.5
File Size Uploaded Provenance Actions
pyvultr-0.1.5.tar.gz 38.5 kB Without provenance Details for pyvultr-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyvultr 0.1.5
File Interpreter ABI Platform Actions
pyvultr-0.1.5-py3-none-any.whl Python 3 none any Details for pyvultr-0.1.5-py3-none-any.whl

Total release size: 95.4 kB

Release files / pyvultr-0.1.5.tar.gz

Download URL pyvultr-0.1.5.tar.gz
Size 38.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4954904650bad58c6b48ae0d5015fe4f7d41e79be943d0b8526ccda9d48efcc5
BLAKE2b-256 checksum
How to use checksums
d744f603101422b1bd7c6ab970be0201e234f4d68fe17f3ee1a58634bd354aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.6.8 Darwin/21.2.0

Release files / pyvultr-0.1.5-py3-none-any.whl

Download URL pyvultr-0.1.5-py3-none-any.whl
Size 56.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d4dda9cf9e0fd2f8293c8bde97a3f88628e2950ac65947b97d82fc4050c6525
BLAKE2b-256 checksum
How to use checksums
dbc52f123fe2cbb4e101ec1d34fbf91a1097aea4238ec23e34936981d997a034
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.6.8 Darwin/21.2.0

Security for pyvultr 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page