Skip to main content

Official Python SDK for the Waveium API

Project description

Waveium Python SDK

Official Python client library for the Waveium API. Build and run RF propagation simulations on top of a real environment model, stream progress via Server-Sent Events, and read the parquet results straight into a pandas DataFrame.

New here? Start with the step-by-step walkthrough at docs/getting_started.md.

Features

  • Full coverage of the Environment -> Scene -> Execution workflow.
  • Synchronous (waveium.Client) and asynchronous (waveium.AsyncClient) clients.
  • Built-in SSE progress streaming with blocking wait() helpers and a create_and_run() convenience for the common case.
  • read_parquet() streams result files straight into pandas without writing to disk; structured=True merges xyz triplets and complex re/im pairs for immediate analysis.
  • Pydantic v2 models throughout for type safety.
  • .env auto-loaded via python-dotenv.
  • Typed exception hierarchy for precise error handling.

Installation

pip install "waveium[parquet]"

The [parquet] extra pulls in pandas and pyarrow, which client.executions.read_parquet() requires. Drop it if you only need to drive simulations without reading results in-process.

Python 3.9 or newer. Tested up to 3.13.

Quick start

import waveium

client = waveium.init()  # reads WAVEIUM_API_KEY from env / .env

# 1. Create an environment (outdoor, route-based).
env_resp = client.environments.create(
    name="Stockholm Route",
    environment_type="outdoor",
    route={
        "start": "Stockholm Central Station",
        "end": "Gamla Stan",
        "area": "Stockholm, Sweden",
    },
    stations={"BS1": [59.3293, 18.0686, 25.0]},
)
env = client.environments.wait(
    env_resp.environment.environment_id, timeout=900
)

# 2. Create and generate a scene.
scene = client.scenes.create(
    environment_id=env.environment_id,
    name="Default Scene",
    parameters={
        "stations": {"BS1": [59.3293, 18.0686, 25.0]},
        "station_radio_config": {
            "BS1": {"tx_power_dbm": 20.0, "noise_floor_dbm": -100.0}
        },
    },
)
client.scenes.generate(scene.scene_id)
client.scenes.wait(scene.scene_id, timeout=3600)

# 3. Run an execution and stream progress.
execution = client.scenes.create_and_run(
    scene.scene_id,
    execution_name="Quick Start",
    timeout=3600,
)

# 4. Read the parquet results into a DataFrame.
df = client.executions.read_parquet(
    execution.execution_id, structured=True
)
print(df.columns)
client.close()

For a guided walkthrough -- including how to plot RSSI, SNR, and channel gain -- see docs/getting_started.md.

Authentication

The SDK reads the API key from the WAVEIUM_API_KEY (or WAVEIUM_SDK_TOKEN) environment variable. Create keys at https://app.waveium.io.

Using a .env file (recommended)

WAVEIUM_API_KEY=wvx_paste_your_key_here
import waveium
client = waveium.init()  # .env auto-loaded

Passing the key explicitly

client = waveium.init(api_key="wvx_...")

Firebase JWT exchange

If you already have a signed-in Firebase user, exchange the JWT for a long-lived API key in one call:

client = waveium.auth(
    firebase_token="eyJ...",      # or set FIREBASE_TOKEN
    token_name="My Python App",
    expires_days=30,
)

Under the hood this POSTs the Firebase JWT to /auth/tokens with Authorization: Bearer <jwt> and returns a Client bound to the new wvx_ key.

Async usage

The AsyncClient mirrors the sync client one-for-one and works as an async context manager:

import asyncio
import waveium


async def main() -> None:
    async with waveium.AsyncClient() as client:
        execution = await client.scenes.create_and_run(
            "scn_xxx",
            execution_name="Async run",
            timeout=3600,
        )
        df = await client.executions.read_parquet(
            execution.execution_id, structured=True
        )
        print(df.head())


asyncio.run(main())

See examples/async_streaming_usage.py for the full set of async streaming patterns.

Available resources

Resource Purpose
client.environments Create / list / get / wait on environments.
client.scenes Scene lifecycle, generate(), wait(), create_execution(), create_and_run(), file upload.
client.executions Execution lifecycle, SSE streaming, wait(), get(), progress(), read_parquet(), download_parquet(), download_archive(), post-processing.
client.antenna_patterns List, upload, and manage antenna patterns.
client.auth Create, list, and revoke API tokens (Firebase exchange lives here).
client.users me() and admin user management.
client.organizations Organization admin.
client.teams Team membership management.
client.projects Project scoping for shared work.
client.roles RBAC role and permission queries.

Error handling

All SDK errors inherit from waveium.WaveiumError:

from waveium import (
    WaveiumError,           # Base class
    AuthenticationError,    # 401
    AuthorizationError,     # 403
    NotFoundError,          # 404
    ConflictError,          # 409 (e.g. scene not completed yet)
    ValidationError,        # 400
    RateLimitError,         # 429
    APIError,               # 5xx
    NetworkError,           # connection / DNS / timeout
    FileUploadError,
    FileDownloadError,
    ConfigurationError,
    StreamError,
    StreamTimeoutError,
    StreamReconnectError,
    ExecutionFailedError,   # terminal "failed" SSE event
)

try:
    client.scenes.create_and_run(scene_id, timeout=3600)
except ExecutionFailedError as e:
    print(f"Execution {e.execution_id} failed: {e.error_message}")
except ConflictError:
    print("Scene is not in completed state yet")
except WaveiumError as e:
    print(f"SDK error: {e}")

Configuration

Variable Meaning Default
WAVEIUM_API_KEY API key (starts with wvx_) --
WAVEIUM_SDK_TOKEN Alias for WAVEIUM_API_KEY --
FIREBASE_TOKEN Firebase JWT for waveium.auth() --
WAVEIUM_BASE_URL API base URL https://api.waveium.io
WAVEIUM_TIMEOUT HTTP timeout in seconds 60
WAVEIUM_MAX_RETRIES Retry budget for idempotent requests 3

Override programmatically:

client = waveium.init(
    api_key="wvx_...",
    base_url="https://api.waveium.io",
    timeout=120.0,
    max_retries=5,
)

Examples

See the examples/ directory for runnable scripts. Each reads WAVEIUM_API_KEY from the environment (or a .env file).

Script What it shows
basic_usage.py Full Env -> Scene -> Execution pipeline, synchronous.
streaming_usage.py Four tiers of SSE streaming (raw stream, blocking wait, create-and-run, environment wait).
async_usage.py Async environment creation.
async_streaming_usage.py Async counterparts of the streaming tiers.
load_and_plot.py Minimal results-only script: point it at an execution_id to plot channel power and CIR.
helsinki_usage.py Full outdoor Helsinki route: run the sim, download the parquet, and plot a 2D PDP.
helsinki_track_usage.py Outdoor bbox variant: generate/upload a GPX track with timestamps as the UE trajectory, run the sim, download the parquet, and plot a 2D PDP.
upload_download.py Scene file upload and execution result download.
underground_workflow.py Complex underground scenario driven by JSON tunnel graph and CSV stations/UE, using polling.
underground_workflow_sse.py Same scenario using SSE streaming instead of polling.
verify_sdk.py Quick smoke test: init, users.me(), list environments.

Development

cd python313
pip install -e ".[dev,parquet]"

Code quality gates (match the project's pyproject.toml and setup.cfg):

black src/ examples/ tests/
flake8 src/ examples/ tests/
mypy --strict src/
pytest

License

MIT -- see LICENSE.

Support

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

waveium-0.5.0.tar.gz (86.2 kB view details)

Uploaded Source

Built Distribution

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

waveium-0.5.0-py3-none-any.whl (74.3 kB view details)

Uploaded Python 3

File details

Details for the file waveium-0.5.0.tar.gz.

File metadata

  • Download URL: waveium-0.5.0.tar.gz
  • Upload date:
  • Size: 86.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for waveium-0.5.0.tar.gz
Algorithm Hash digest
SHA256 81f3817912837506932f41a94236e1d1487b430cb5f00add842a17e0d61b1a9d
MD5 d94a877611229710cafb0e84aee30bd5
BLAKE2b-256 4ae8c8dd324aec79a2e31e1a518588db8f78c0ae9ae934acb8192e359809ac90

See more details on using hashes here.

File details

Details for the file waveium-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: waveium-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 74.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for waveium-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fd27b82d03d50bf1db91ba3a595d68659b4c6290bee3242b35225fe0078120f
MD5 b3b433677df304ae3bfde0b098ba987c
BLAKE2b-256 5b8f101736670a9c818d4f99a94a608d4a06d0a763625250910325f5cd6a8fa3

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