Veeam Service Provider Console REST API wrapper for Python
Project description
Veeam Service Provider Console Python API Wrapper
Python package for interacting with the Veeam Service Provider Console REST API
This project is an independent, open source Python client for the Veeam Service Provider Console REST API. It is not affiliated with, endorsed by, or sponsored by Veeam Software.
Supported Versions
| VSPC Version | API Version | Supported |
|---|---|---|
| 9.2 | 3.6.2 | ✅ |
| 9.1 | 3.6.1 | ✅ |
| 9 | 3.6 | ✅ |
| 8.1 | 3.5.1 | ✅ |
| < 8.1 | < 3.5.1 | ❌ |
How to support new API versions
- Download the OpenAPI JSON spec into openapi_schemas
- Install the openapi-python-client package
- Fix the OpenAPI JSON spec to conform to proper standards:
python fix_openapi_yaml.py .\openapi_schemas\vspc_rest_{vspc_version}.json .\openapi_schemas\vspc_rest_{vspc_version}_fixed.json - Run
openapi-python-client generate --path ".\openapi_schemas\vspc_rest_{vspc_version}_fixed.json" --output-path ".\veeam_spc" --overwrite - Fix any warnings/errors (application/binary+base64 can be ignored)
- Rename the folder to match the API version (i.e.,
v3_5_1) - Update versions.py and the main readme for the new version
- Write pytest tests
- If an older API has been deprecated, delete its folder and yaml as well as its versions.py reference, then update the supported versions section of the readme
Install
Note: This package requires Python 3.10 or later. If you are on Python 3.9, please use an earlier release of this library.
From PyPi
pip install veeam-spc
From Source
Clone the repository and install dependencies:
git clone https://github.com/Cenvora/veeam-spc.git
cd veeam-spc
pip install -e .
Usage Tips
- For endpoints requiring authentication, use
AuthenticatedClientinstead ofClient. - To support multiple API versions, import the client and models from the desired versioned subpackage (e.g.,
veeam_spc.v3_5_1). - For file downloads (PDF, CSV, etc.), access the raw response content:
response.content. - Refer to the generated
apiandmodelsmodules for available endpoints and request/response schemas.
Usage
Recommended Usage (Smart Client)
The VeeamClient handles:
- API version routing
- Authentication
- Token refresh
X-Client-Versionheader injection so package API version matches header values- Async calls
- Operation discovery
Each packaged version can be called independently through separate imports, but this is the recommended way to use this library.
Create a client and connect
You can authenticate using either username/password or a pre-existing token.
Option 1: Username/Password Authentication
import asyncio
from veeam_spc.client import VeeamClient
async def main():
vc = VeeamClient(
host="https://vspc.example.com:1280",
username="administrator",
password="SuperSecretPassword",
api_version="3.6",
verify_ssl=False,
)
await vc.connect()
# use the client...
await vc.close()
asyncio.run(main())
Option 2: Token Authentication (recommended for long-lived access)
VSPC supports permanent tokens that don't expire, making them ideal for service accounts and CI/CD pipelines.
import asyncio
from veeam_spc.client import VeeamClient
async def main():
vc = VeeamClient(
host="https://vspc.example.com:1280",
token="your-permanent-token-here",
api_version="3.6",
verify_ssl=False,
)
await vc.connect()
# use the client...
await vc.close()
asyncio.run(main())
Call an API endpoint (async)
provider = await vc.call(
vc.api("provider").get_provider
)
# provider is a Provider model
print(provider.name)
Call any endpoint
Operations map directly to the OpenAPI layout:
api/
└── provider/
└── get_provider.py
Call it like this:
await vc.call(
vc.api("provider").get_provider
)
Or explicitly:
await vc.call(
vc.api("provider.get_provider")
)
Pagination example
result = await vc.call(
vc.api("companies").get_companies,
limit=50,
offset=0,
)
Close the client
await vc.close()
Basic Usage (Direct API Access)
If you prefer to use the versioned packages directly without the SmartClient:
First, create a client from the appropriate API version:
from veeam_spc.v3_5_1 import Client
client = Client(base_url="https://server:1280/api/v3")
If the endpoints you're going to hit require authentication, use AuthenticatedClient:
from veeam_spc.v3_5_1 import AuthenticatedClient
client = AuthenticatedClient(base_url="https://server:1280/api/v3", token="SuperSecretToken")
Now call your endpoint and use your models:
from veeam_spc.v3_5_1.models import About
from veeam_spc.v3_5_1.api.about import get_about_information
from veeam_spc.v3_5_1.types import Response
with client:
about_info: About = get_about_information.sync(client=client, x_client_version="3.5.1")
# or if you need more info (e.g. status_code)
response: Response[About] = get_about_information.sync_detailed(client=client, x_client_version="3.5.1")
Async Usage
Or do the same thing with an async version:
from veeam_spc.v3_5_1.models import About
from veeam_spc.v3_5_1.api.about import get_about_information
from veeam_spc.v3_5_1.types import Response
client = AuthenticatedClient(base_url="https://server:1280/api/v3", token="SuperSecretToken")
async with client:
about_info = await get_about_information.asyncio(client=client, x_client_version="3.5.1")
response: Response[About] = await get_about_information.asyncio_detailed(client=client, x_client_version="3.5.1")
SSL Verification
By default, HTTPS APIs will verify SSL certificates. You can pass a custom certificate bundle or disable verification (not recommended):
from veeam_spc.v3_5_1 import AuthenticatedClient
client = AuthenticatedClient(
base_url="https://internal_api.example.com/api/v3",
token="SuperSecretToken",
verify_ssl="/path/to/certificate_bundle.pem",
)
# Disable SSL verification (security risk)
client = AuthenticatedClient(
base_url="https://internal_api.example.com/api/v3",
token="SuperSecretToken",
verify_ssl=False
)
Advanced Customizations
You can customize the underlying httpx.Client or httpx.AsyncClient:
from veeam_spc.v3_5_1 import Client
def log_request(request):
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
def log_response(response):
request = response.request
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
client = Client(
base_url="https://server:1280/api/v3",
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
Contributing
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch
- Make your changes and add tests
- Submit a pull request with a clear description
Please follow PEP8 style and include docstrings for new functions/classes.
🤝 Core Contributors
This project is made possible thanks to the efforts of our core contributors:
We’re grateful for their continued support and contributions.
Project details
Release history Release notifications | RSS feed
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 veeam_spc-0.3.2.tar.gz.
File metadata
- Download URL: veeam_spc-0.3.2.tar.gz
- Upload date:
- Size: 6.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
446f9c8404a17e83cc859ee6f65fd8b5790281a19f669650b83215124ee71dd0
|
|
| MD5 |
5d0cddd175440585babf75bfe9d7c741
|
|
| BLAKE2b-256 |
0f86d8d67c5be968db5016f5e9151d06a7798fd0003f11b77396fe8332bf1b9e
|
Provenance
The following attestation bundles were made for veeam_spc-0.3.2.tar.gz:
Publisher:
publish-on-release.yml on Cenvora/veeam-spc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
veeam_spc-0.3.2.tar.gz -
Subject digest:
446f9c8404a17e83cc859ee6f65fd8b5790281a19f669650b83215124ee71dd0 - Sigstore transparency entry: 1279638745
- Sigstore integration time:
-
Permalink:
Cenvora/veeam-spc@3166b4112ba5e5770167942f8cf3f79ed243f4da -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/Cenvora
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-on-release.yml@3166b4112ba5e5770167942f8cf3f79ed243f4da -
Trigger Event:
push
-
Statement type:
File details
Details for the file veeam_spc-0.3.2-py3-none-any.whl.
File metadata
- Download URL: veeam_spc-0.3.2-py3-none-any.whl
- Upload date:
- Size: 15.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca2b460fc422e776dd651831098d179aa07f2d05b863b6455d9f2e73c254ea35
|
|
| MD5 |
7a46bd142472ad02f0f7735e94dd947d
|
|
| BLAKE2b-256 |
93e20a26deb2dd6006394b08ef031b91ba3ca17e621afac784dc3be1c33dd8d8
|
Provenance
The following attestation bundles were made for veeam_spc-0.3.2-py3-none-any.whl:
Publisher:
publish-on-release.yml on Cenvora/veeam-spc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
veeam_spc-0.3.2-py3-none-any.whl -
Subject digest:
ca2b460fc422e776dd651831098d179aa07f2d05b863b6455d9f2e73c254ea35 - Sigstore transparency entry: 1279638765
- Sigstore integration time:
-
Permalink:
Cenvora/veeam-spc@3166b4112ba5e5770167942f8cf3f79ed243f4da -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/Cenvora
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-on-release.yml@3166b4112ba5e5770167942f8cf3f79ed243f4da -
Trigger Event:
push
-
Statement type: