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.
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.
Illustrative package name
Install (illustrative)
pip install stratagateway
python -m pip install stratagatewayStatus: 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.
Illustrative SDK syntax
Client initialization (preview)
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
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.
Illustrative SDK API
Create instance (preview)
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
{
"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
instances = client.instances.list()
for instance in instances.data:
print(instance.name, instance.status)Get a single instance
Get instance
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 syntax
Create network (preview)
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 syntax
Create firewall (preview)
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 syntax
Add SSH key (preview)
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:
instance = client.instances.get("inst_example")
except StrataGatewayError as error:
print(error.code)
print(error.message)A planned SDK error concept is StrataGatewayError.
In Development
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.
Illustrative type model
Illustrative type model
Illustrative InstanceStatus type
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.
Illustrative async interface
Async example
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
STRATA_API_TOKEN=your_token_hereLinux/macOS
export STRATA_API_TOKEN="your_token_here"PowerShell
$env:STRATA_API_TOKEN="your_token_here"Python
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
Python Application
→ StrataGateway Python SDK
→ REST API
→ StrataGateway Control PlaneSee 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.
Illustrative automation workflow
Automation workflow
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.
Next steps
REST API
Resource-oriented HTTP API reference.
Authentication
Token-based authentication and identity boundaries.
CLI
Terminal-native infrastructure workflows.
TypeScript SDK
JavaScript and TypeScript developer tooling.
Terraform Provider
Declarative infrastructure-as-code provisioning.
Cloud Compute
Provision and manage compute instances.
Was this page helpful?