Skip to content

Python SDK

The official Python SDK for the WAYSCloud API. One client, nine services, typed exceptions, automatic retries, and connection pooling.

bash
pip install wayscloud

Requires 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.

ParameterEnvironment variableDefault
tokenWAYSCLOUD_TOKEN
api_keyWAYSCLOUD_API_KEY
base_urlWAYSCLOUD_API_URLhttps://api.wayscloud.services
timeout30.0

Services

ServicePropertyDescription
VPSclient.vpsVirtual private servers
DNSclient.dnsDNS zones and records
Storageclient.storageS3-compatible object storage
Databaseclient.databaseManaged PostgreSQL & MariaDB
Redisclient.redisManaged Redis
Appsclient.appsApp Platform (containers)
IoTclient.iotIoT device management
SMSclient.smsSMS messaging
Accountclient.accountProfile 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.

ExceptionHTTP Status
AuthenticationError401, 403
NotFoundError404
ValidationError422
ServerError5xx

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 here

Or 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

WAYSCloud AS