Python SDK
The official Python SDK for the WAYSCloud API. One client, nine services, typed exceptions, automatic retries, and connection pooling.
bash
pip install wayscloudRequires Python 3.10+. PyPI page.
Authentication
python
from wayscloud import WaysCloudClient
# Personal Access Token
client = WaysCloudClient(token="wayscloud_pat_xxx...")
# API key
client = WaysCloudClient(api_key="wayscloud_api_xxx...")
# Environment variables (no args needed)
# Set WAYSCLOUD_TOKEN or WAYSCLOUD_API_KEY
client = WaysCloudClient()Priority: explicit arguments > environment variables.
| Parameter | Environment variable | Default |
|---|---|---|
token | WAYSCLOUD_TOKEN | — |
api_key | WAYSCLOUD_API_KEY | — |
base_url | WAYSCLOUD_API_URL | https://api.wayscloud.services |
timeout | — | 30.0 |
Services
| Service | Property | Description |
|---|---|---|
| VPS | client.vps | Virtual private servers |
| DNS | client.dns | DNS zones and records |
| Storage | client.storage | S3-compatible object storage |
| Database | client.database | Managed PostgreSQL & MariaDB |
| Redis | client.redis | Managed Redis |
| Apps | client.apps | App Platform (containers) |
| IoT | client.iot | IoT device management |
| SMS | client.sms | SMS messaging |
| Account | client.account | Profile and SSH keys |
Examples
VPS
python
# List instances
for vm in client.vps.list():
print(vm["hostname"], vm["status"])
# Create
vps = client.vps.create(
hostname="web01.example.com",
plan="vps-medium",
region="no",
os_template="ubuntu-24.04",
)
# Lifecycle
client.vps.start(vps["id"])
client.vps.stop(vps["id"])
client.vps.delete(vps["id"])DNS
python
client.dns.create_zone("example.com")
client.dns.create_record(
"example.com",
record_type="A",
name="www",
value="192.0.2.1",
ttl=3600,
)Database
python
db = client.database.create(name="prod", db_type="postgresql")
creds = client.database.credentials("postgresql", "prod")
print(creds["connection_string"])Storage
python
client.storage.create_bucket("my-bucket")
creds = client.storage.credentials()Redis
python
instance = client.redis.create(name="cache", plan="redis-starter")
creds = client.redis.credentials(instance["id"])Apps
python
app = client.apps.create(name="my-app", region="eu", port=8080)
client.apps.deploy(app["id"], image="ghcr.io/org/app:latest")IoT
python
device = client.iot.create_device(
device_id="sensor-01",
name="Temperature Sensor",
)
creds = client.iot.device_credentials("sensor-01")SMS
python
client.sms.send(to="+4712345678", message="Hello from WAYSCloud")Error handling
python
from wayscloud import NotFoundError, AuthenticationError, ValidationError, ServerError
try:
client.vps.get("nonexistent")
except NotFoundError:
print("Resource not found")
except AuthenticationError:
print("Invalid or expired credentials")
except ValidationError:
print("Invalid request parameters")
except ServerError:
print("Server error — retry later")All exceptions inherit from WaysCloudError with status_code, message, and detail.
| Exception | HTTP Status |
|---|---|
AuthenticationError | 401, 403 |
NotFoundError | 404 |
ValidationError | 422 |
ServerError | 5xx |
Connection management
The SDK uses a persistent HTTP client for connection pooling:
python
with WaysCloudClient(token="wayscloud_pat_xxx...") as client:
zones = client.dns.zones()
vps = client.vps.list()
# Connections released hereOr close manually:
python
client = WaysCloudClient()
try:
data = client.vps.list()
finally:
client.close()Retries
Automatic retries on 429, 502, 503, 504 — up to 3 attempts with exponential backoff. Respects Retry-After headers.
Next steps
- CLI — command-line interface built on this SDK
- Terraform Provider — infrastructure as code
- Python examples — using the REST API directly