Skip to main content

Official Python client for Traffic Orchestrator license validation, management, and analytics

Project description

@traffic-orchestrator/python-sdk

Official Python SDK for Traffic Orchestrator — license validation, management, and analytics.

📖 API Reference · SDK Guides · OpenAPI Spec

Install

pip install traffic-orchestrator

Quick Start

from traffic_orchestrator import TrafficOrchestrator

# Validate a license
to = TrafficOrchestrator()
result = to.validate_license("LK-xxxx-xxxx-xxxx", domain="example.com")

if result.valid:
    print(f"License active, plan: {result.plan_id}")

Authenticated Usage

to = TrafficOrchestrator(api_key=os.environ["TO_API_KEY"])

# List licenses
licenses = to.list_licenses()

# Get usage
usage = to.get_usage()
print(f"{usage.validations_month} / {usage.monthly_limit}")

API Methods

Core License Operations

Method Auth Description
validate_license(token, domain?) No Validate a license key
verify_offline(token, public_key, domain?) No Ed25519 offline verification (static)
list_licenses() Yes List all licenses
create_license(options) Yes Create a new license
rotate_license(license_id) Yes Rotate license key
delete_license(license_id) Yes Revoke a license
get_usage() Yes Get usage statistics
get_analytics(days?) Yes Get detailed analytics
health_check() No Check API health

Portal & Enterprise Methods

Method Auth Description
add_domain(license_id, domain) Yes Add domain to license
remove_domain(license_id, domain) Yes Remove domain from license
get_domains(license_id) Yes Get license domains
update_license_status(id, status) Yes Suspend/reactivate license
list_api_keys() Yes List API keys
create_api_key(name, scopes?) Yes Create API key
delete_api_key(key_id) Yes Delete API key
get_dashboard() Yes Full dashboard overview

Error Handling

from traffic_orchestrator import TOError, TOValidationError

try:
    result = to.validate_license("invalid-token")
except TOValidationError as e:
    print(f"Validation failed: {e.code}{e.message}")
except TOError as e:
    print(f"API error: {e.status} {e.message}")

Retry & Resilience

Built-in retry with exponential backoff:

to = TrafficOrchestrator(
    api_key="...",
    timeout=5.0,     # seconds
    max_retries=3,   # retry on 5xx and network errors
)

Multi-Environment

# Production (default)
to = TrafficOrchestrator(api_key=os.environ["TO_API_KEY"])

# Staging
to = TrafficOrchestrator(
    api_key=os.environ["TO_API_KEY_DEV"],
    api_url="https://api-staging.trafficorchestrator.com/api/v1"
)

Offline Verification (Enterprise)

Enterprise licenses are signed JWTs verified without network access using Ed25519:

public_key = open("public_key.pem").read()
result = TrafficOrchestrator.verify_offline(
    token=license_token,
    public_key_pem=public_key,
    domain="example.com"  # Optional domain check
)

if result.valid:
    print(f"Plan: {result.plan_id}")
    print(f"Domains: {result.domains}")
    print(f"Expires: {result.expires_at}")

Type Hints

Full PEP 484 type hints for all methods and return types:

from traffic_orchestrator.types import ValidationResult, License, UsageStats

Requirements

  • Python 3.8+
  • requests or httpx

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traffic_orchestrator-2.0.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traffic_orchestrator-2.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file traffic_orchestrator-2.0.0.tar.gz.

File metadata

  • Download URL: traffic_orchestrator-2.0.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for traffic_orchestrator-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a29f46a5832c06d2a361a121615e1835b034ad4bb9d51517b0a5b017a77a54f6
MD5 ebc9d55af9291ed23bf5a2ca4f0ff8b2
BLAKE2b-256 90f4c8a204013e32de6b950b54d68916fa277d3890c1707cd478104086f84421

See more details on using hashes here.

File details

Details for the file traffic_orchestrator-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for traffic_orchestrator-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 495c9513396ef1bc4b49557952f265ed020f50fca09da2104f31b46d4d52e571
MD5 91def8bdf57c207a36cdc30f7d6ff122
BLAKE2b-256 b9d80b2d8c66244521f2166d54e1f30cfd91e3d8b5062350b38ada671e3f43ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page