Developer Platform

Python SDK

Build, automate, and manage StrataGateway infrastructure through a clean, Python-native developer interface.

Planned

Development Preview

The StrataGateway Python SDK is currently planned and is not yet publicly available. Package names, client interfaces, resource models, authentication behavior, error types, and distribution methods may change before release.

Jump to article

Overview

The StrataGateway Python SDK is intended to provide a Python-native interface over the StrataGateway REST API, giving developers a direct way to automate infrastructure workflows from Python applications and operational tooling.

Idiomatic Python interfaces
Predictable resource methods
Type hints
Automation-friendly workflows
Infrastructure scripting
Synchronous and potentially asynchronous workflows
API parity with core platform functionality
Integration with backend applications and DevOps tooling

The StrataGateway Python SDK is currently planned and is not yet publicly available. Package names, client interfaces, resource models, authentication behavior, error types, and distribution methods may change before release.

Planned installation

The SDK is not yet published. The commands below are illustrative and only show the intended future installation shape.

Planned

Illustrative package name

Install (illustrative)

Install (illustrative)Bash
pip install stratagateway
python -m pip install stratagateway

Status: Planned. The final package name and distribution method will be confirmed before public release.

Do not assume a public PyPI package currently exists.

Client setup

Initialize the planned SDK client with your API token. The syntax below is illustrative only.

Preview

Illustrative SDK syntax

Client initialization (preview)

Client initialization (preview)Python
import os
from stratagateway import StrataGateway

client = StrataGateway(
    token=os.environ["STRATA_API_TOKEN"]
)

This interface is a preview of the planned client shape and should not be treated as a published module contract yet.

Authentication

The Python SDK is expected to use the same API token authentication model as the REST API.

Set the STRATA_API_TOKENenvironment variable and pass it to the client.

Authentication via environment variable

Authentication via environment variablePython
import os
from stratagateway import StrataGateway

client = StrataGateway(
    token=os.environ["STRATA_API_TOKEN"]
)

Security

Never hardcode API tokens directly into application source code or commit them to version control. Use environment variables or a secrets manager instead.

See Authentication for the platform token model.

Creating an instance

Provision a new compute instance using the planned instances resource. The example below uses illustrative SDK API syntax.

Preview

Illustrative SDK API

Create instance (preview)

Create instance (preview)Python
instance = client.instances.create(
    name="web-prod-01",
    region="fra-1",
    plan="compute-standard",
    image="ubuntu-24.04-lts",
    ssh_keys=["key_8f3a9b1c"],
)

print(instance.id)

Illustrative result

Illustrative response

Illustrative responseJSON
{
    "id": "inst_7a91c2",
    "name": "web-prod-01",
    "status": "provisioning",
    "region": "fra-1"
}

Provisioning is expected to be asynchronous. The initial response returns a provisioning status, and final provisioning times are not yet defined.

Listing instances

List all instances or retrieve a single instance by identifier.

List all instances

List instances

List instancesPython
instances = client.instances.list()

for instance in instances.data:
    print(instance.name, instance.status)

Get a single instance

Get instance

Get instancePython
instance = client.instances.get("inst_7a91c2")

Exact response object shapes are not finalized.

Working with networks

Create and manage private networks using the planned networks resource.

Preview

Preview syntax

Create network (preview)

Create network (preview)Python
network = client.networks.create(
    name="production-private",
    region="fra-1",
    cidr="10.10.0.0/24",
)

See Networking for the network resource model.

Working with firewalls

Create and manage firewall policies using the planned firewalls resource.

Preview

Preview syntax

Create firewall (preview)

Create firewall (preview)Python
firewall = client.firewalls.create(
    name="web-production",
    rules=[
        {
            "direction": "inbound",
            "protocol": "tcp",
            "port": "443",
            "source": "0.0.0.0/0",
            "action": "allow",
        }
    ],
)

See Firewalls for the firewall policy model.

SSH keys

Manage SSH keys for instance access using the planned SSH keys resource.

Preview

Preview syntax

Add SSH key (preview)

Add SSH key (preview)Python
key = client.ssh_keys.create(
    name="Personal Laptop",
    public_key="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...",
)

Security note: The SDK must only receive public SSH key material. Private SSH keys must remain on the user's trusted device and must never be uploaded to StrataGateway.

See SSH Keys for the key management model.

Error handling

Illustrative Python error handling pattern:

Try/except example

Try/except examplePython
try:
    instance = client.instances.get("inst_example")
except StrataGatewayError as error:
    print(error.code)
    print(error.message)

A planned SDK error concept is StrataGatewayError.

Planned

In Development

code
message
request_id
status_code

The final Python SDK error hierarchy is still being designed.

Type hints

The Python SDK is intended to include type hints to improve editor autocomplete, static analysis, API discoverability, request validation, and resource modeling.

Editor autocomplete
Static analysis
API discoverability
Request validation
Resource modeling

Illustrative type model

Preview

Illustrative type model

Illustrative InstanceStatus type

Illustrative InstanceStatus typePython
from typing import Literal

InstanceStatus = Literal[
    "provisioning",
    "running",
    "stopped",
    "rebuilding",
    "deleting",
    "error",
]

The exact type definitions are not finalized.

Async support

Async Python support is being considered for workloads that need concurrent infrastructure operations.

Planned

Illustrative async interface

Async example

Async examplePython
from stratagateway import AsyncStrataGateway

client = AsyncStrataGateway(
    token=os.environ["STRATA_API_TOKEN"]
)

instance = await client.instances.create(
    name="worker-01",
    region="fra-1",
    plan="compute-standard",
    image="ubuntu-24.04-lts",
)

The final asynchronous SDK design has not yet been finalized.

Environment variables

Environment variables are preferable to hardcoding credentials in source code.

Environment variable

Environment variableBash
STRATA_API_TOKEN=your_token_here

Linux/macOS

Linux/macOSBash
export STRATA_API_TOKEN="your_token_here"

PowerShell

PowerShellPowerShell
$env:STRATA_API_TOKEN="your_token_here"

Python

PythonPython
import os

token = os.environ["STRATA_API_TOKEN"]

REST API relationship

The Python SDK is intended to provide Python-native abstractions over the same API used by the CLI, TypeScript SDK, and Terraform integration.

Architecture layer

Architecture layertext
Python Application
→ StrataGateway Python SDK
→ REST API
→ StrataGateway Control Plane

See REST API for the underlying HTTP resource model.

Automation example

The SDK is intended for repeatable infrastructure automation and operational scripts. The example below shows one restrained workflow for creating several compute resources.

Preview

Illustrative automation workflow

Automation workflow

Automation workflowPython
names = ["worker-01", "worker-02", "worker-03"]

for name in names:
    client.instances.create(
        name=name,
        region="fra-1",
        plan="compute-standard",
        image="ubuntu-24.04-lts",
    )

This example does not imply concurrency behavior, rate limit handling, or provisioning guarantees.

Was this page helpful?