CloudNexus Python SDK
The official Python client for CloudNexus infrastructure. Build, deploy, and manage scalable cloud resources with a type-safe, async-first developer experience.
Overview
The CloudNexus Python SDK provides a comprehensive interface to interact with all CloudNexus services. It features automatic retries, exponential backoff, streaming responses, and full type hints for better IDE support.
Native asyncio support for non-blocking operations and concurrent requests.
Full type stubs for all models and methods. Works seamlessly with mypy.
Iterate over large result sets automatically without manual cursor management.
Automatic region routing and failover for low-latency operations.
Installation
Pip
pip install cloudnexus-sdk
Requirements
Ensure your environment meets the following requirements:
- Python 3.8, 3.9, 3.10, 3.11, or 3.12
- Internet connection to reach CloudNexus API endpoints
Authentication
Authenticate by passing your API key or using environment variables. We recommend using environment variables for security.
import os from cloudnexus import Client # Method 1: Environment Variable (Recommended) # export CLOUDNEXUS_API_KEY="your-key-here" client = Client() # Method 2: Explicit Key client = Client( api_key=os.getenv("CLOUDNEXUS_API_KEY"), region="us-east-1" )
Quick Start
Create your first server instance in seconds:
from cloudnexus import Client client = Client() # Create a new compute instance server = client.compute.servers.create( name="production-app-01", plan="standard-4", # 4 vCPU, 16GB RAM image="ubuntu-22.04", region="us-east-1", ssh_keys=["key-abc123"], tags={"env": "production", "app": "web"} ) print(f"Server created: {server.id}") print(f"IP Address: {server.ipv4_address}")
Listing Resources
The SDK supports automatic pagination for all list operations:
# Auto-paginating iterator for server in client.compute.servers.list(): print(f"{server.name} is {server.status}") # Or fetch specific page pages = client.compute.servers.list(page_size=50, offset=0) print(f"Total count: {pages.total_count}")
Async Support
For high-throughput applications, use the async client:
import asyncio from cloudnexus import AsyncClient async def deploy_infrastructure(): client = AsyncClient() # Create multiple resources concurrently servers = await asyncio.gather( client.compute.servers.create(name="app-1", plan="standard-2"), client.compute.servers.create(name="app-2", plan="standard-2"), client.compute.servers.create(name="db-1", plan="standard-8"), ) for s in servers: print(f"Deployed {s.name}") asyncio.run(deploy_infrastructure())
Pagination & Streaming
Large datasets are handled efficiently with async iterators and streaming downloads:
# Streaming object storage downloads with client.storage.objects.download("my-bucket", "large-file.zip") as stream: with open("large-file.zip", "wb") as f: for chunk in stream.iter_chunks(chunk_size=8192): f.write(chunk)
Common Models
| Model | Description | Type |
|---|---|---|
Server |
Compute instance representation | Object |
Database |
Managed database cluster | Object |
Bucket |
Object storage container | Object |
LoadBalancer |
Network load balancer | Object |
Page[T] |
Paginated response wrapper | Generic |