Python 3 wrapper for the Vultr API v2.0
Project description
Vultr Python
Python 3 wrapper for the Vultr API v2.
Vultr API Reference: https://www.vultr.com/api
[!TIP]
Please submit a Feature Request or report any Issues.
For more details visit www.vultr.com.
Install
From PyPi: https://pypi.org/project/vultr-python
python -m pip install vultr-python
From Source:
git clone https://github.com/cssnr/vultr-python.git
python -m pip install vultr-python
Usage
You will need to create an api key and whitelist your IP address for most functions.
Initialize the Vultr class with your API Key or use the VULTR_API_KEY environment variable.
from vultr import Vultr
vultr = Vultr("VULTR_API_KEY")
List plans and get available regions for that plan
plans = vultr.list_plans({"type": "vc2"}) # Filter by type
plan = plans[0] # 0 seems to be the base plan
regions = vultr.list_regions()
available = vultr.filter_regions(regions, plan["locations"])
Get the OS list and filter by name
os_list = vultr.list_os()
ubuntu_lts = vultr.filter_os(os_list, "Ubuntu 24.04 LTS x64")
Create a new ssh key from key string
sshkey = vultr.create_key("key-name", "ssh-rsa AAAA...")
vultr.delete_key(sshkey['id'])
Create a new instance
data = {
"os_id": ubuntu_lts["id"],
"sshkey_id": [sshkey["id"]],
"hostname": "my-new-host",
"label": "my-new-host",
}
instance = vultr.create_instance(available[0], plan, **data)
Arbitrary Methods get, post, patch, put, delete
plans = vultr.get("/plans", {"type": "vc2"})
sshkey = vultr.post("/ssh-keys", name="key-name", ssh_key="ssh-rsa AAAA...")
instance = vultr.patch("/instances/{instance-id}", plan=plans[1]["id"])
database = vultr.put("/databases/{database-id}", tag="new tag")
vultr.delete("/snapshots/{snapshot-id}")
Error Handling
>>> instance = vultr.create_instance("atl", "vc2-1c-0.5gb-v6", os_id=2284)
Traceback (most recent call last):
vultr.vultr.VultrException: Error 400: Server add failed: Ubuntu 24.04 LTS x64 requires a plan with at least 1000 MB memory.
Using the VultrException class
from vultr import VultrException
try:
instance = vultr.create_instance("atl", "vc2-1c-0.5gb-v6", os_id=2284)
except VultrException as error:
print(error.error)
# 'Server add failed: Ubuntu 24.04 LTS x64 requires a plan with at least 1000 MB memory.'
print(error.status)
# 400
Full Documentation: https://cssnr.github.io/vultr-python
Vultr API Reference: https://www.vultr.com/api
Support
For general help or to request a feature, see:
- Q&A Discussion: https://github.com/cssnr/vultr-python/discussions/categories/q-a
- Request a Feature: https://github.com/cssnr/vultr-python/discussions/categories/feature-requests
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
If you are experiencing an issue/bug or getting unexpected results, you can:
- Report an Issue: https://github.com/cssnr/vultr-python/issues
- Provide General Feedback: https://cssnr.github.io/feedback/
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
Contributing
If you would like to submit a PR, please review the CONTRIBUTING.md.
Please consider making a donation to support the development of this project and additional open source projects.
For a full list of current projects visit: https://cssnr.github.io/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vultr_python-0.2.0.tar.gz.
File metadata
- Download URL: vultr_python-0.2.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f955d46b017320a967fd002fece8a10ca441e8a52ed6124b9a55cb5dd46ee63
|
|
| MD5 |
bab9ab6c6d42d79ed5811cd39223123f
|
|
| BLAKE2b-256 |
48ce6a1b73ff865f549facd64a1657b8910fe13aa1d3e2a6fbd55ef04c691a8b
|
Provenance
The following attestation bundles were made for vultr_python-0.2.0.tar.gz:
Publisher:
release.yaml on cssnr/vultr-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vultr_python-0.2.0.tar.gz -
Subject digest:
8f955d46b017320a967fd002fece8a10ca441e8a52ed6124b9a55cb5dd46ee63 - Sigstore transparency entry: 732082650
- Sigstore integration time:
-
Permalink:
cssnr/vultr-python@f8d2a336f04a5b3639f3e0826671014322e34882 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/cssnr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@f8d2a336f04a5b3639f3e0826671014322e34882 -
Trigger Event:
release
-
Statement type:
File details
Details for the file vultr_python-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vultr_python-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f8dd1355b7dc93a5dfa352f912796f5ad363214d92c4c1d6382041363bce7cd
|
|
| MD5 |
6ec482170194488852cd64a9efb7933d
|
|
| BLAKE2b-256 |
7727f37609490a8e019e707d28fea2c1c3fc19f46b16275bc784f282a551f282
|
Provenance
The following attestation bundles were made for vultr_python-0.2.0-py3-none-any.whl:
Publisher:
release.yaml on cssnr/vultr-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vultr_python-0.2.0-py3-none-any.whl -
Subject digest:
8f8dd1355b7dc93a5dfa352f912796f5ad363214d92c4c1d6382041363bce7cd - Sigstore transparency entry: 732082651
- Sigstore integration time:
-
Permalink:
cssnr/vultr-python@f8d2a336f04a5b3639f3e0826671014322e34882 -
Branch / Tag:
refs/tags/0.2.0 - Owner: https://github.com/cssnr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@f8d2a336f04a5b3639f3e0826671014322e34882 -
Trigger Event:
release
-
Statement type: