Stegawave Python SDK

Why this SDK

The stegawave package wraps the public Stegawave REST API with typed models, ergonomic helpers, and production-ready retry logic. Use it to provision pipelines, monitor readiness, manage viewer tokens, and automate decode workflows from one cohesive client.

Workflow helpers

Built-in session wrappers handle provisioning waits and retry logic so your code stays focused on the pipeline lifecycle instead of polling loops.

Full API coverage

Endpoints for /create-pipeline, /get-pipeline, /pipeline-state, /delete, /token, /decode, and /iptv map to dedicated methods.

Purpose-built errors

Network hiccups, auth failures, validation issues, and rate limits surface as descriptive subclasses of StegawaveError.

Installation & Setup

Install from PyPI and either pass credentials explicitly or rely on environment variables. The client enforces an API key at construction time.

Make sure you always use the latest version: pip install --upgrade stegawave

pip install stegawave
Variable Purpose Default
STEGAWAVE_API_KEY Primary authentication token None (required)
from stegawave import StegawaveClient
# Explicit credentials client = StegawaveClient(api_key="your-api-key", timeout=20.0, retry_attempts=5) # Or rely on environment variables with StegawaveClient() as client: print("Client ready")

Quick start pipeline

Provision a pipeline that mirrors the UI defaults, wait for readiness, and collect ingest plus signed playback URLs.

from stegawave import StegawaveClient, models

request = models.CreatePipelineRequest(
    name="launch-stream",
    description="Product launch livestream",
    segmentDuration=4,
    autoStart=True,
  input=models.InputConfig(Type="RTP"),
    encoder=models.EncoderConfig(
        vodArchive=False,
        Outputs=[
            models.OutputConfig(
                OutputName="cmaf-1080p",
                resolution="1920x1080",
                FramerateNumerator=30,
                FramerateDenominator=1,
                VideoBitrate="7.5M",
            ),
            models.OutputConfig(
                OutputName="cmaf-720p",
                resolution="1280x720",
                FramerateNumerator=30,
                FramerateDenominator=1,
                VideoBitrate="5.2M",
            ),
        ],
    ),
    packager=models.PackagerConfig(
        originEndpoints=[
            models.OriginEndpoint(
                name="cmaf-hybrid",
                ContainerType="CMAF",
                HlsManifests=[models.HlsManifest(ManifestName="index")],
                DashManifests=[models.DashManifest(ManifestName="index")],
                StartoverWindowSeconds=86_400,
            )
        ]
    ),
)

with StegawaveClient() as client:
    session = client.create_pipeline_session(request, wait=True)
    print("Input URI:", session.input_uri)
    for playback in session.signed_manifest_uris("viewer-key"):
        print("Manifest:", playback)

PipelineSession tour

The PipelineSession wrapper keeps the latest status cached, handles polling for readiness, normalizes ingest details, and signs CDN manifests for a viewer token.

Monitor readiness

session = client.get_pipeline_session(event_id)
status = session.wait_until_ready(timeout=600, poll_interval=5)
print(status.status, status.createdAt)

Normalize ingest

input_details = session.get_input()
print(input_details.protocol)
print(input_details.uri)
print(input_details.allowed_ips)

Deliver playback

for url in session.signed_manifest_uris("viewer123", exp_hours=4):
    print("Signed:", url)

Model building patterns

Models enforce structure with helpful validation. Compose them incrementally to build tailored pipelines.

SRT listener input

models.InputConfig(
    Type="SRT_LISTENER",
    whitelist=["203.0.113.50/32"],
    SrtListenerSettings=models.SrtListenerSettings(
        IngestPort=9000,
        MinLatency=2000,
        PassphraseEnabled=True,
    ),
)

SRT caller input

models.InputConfig(
    Type="SRT_CALLER",
    SrtCallerSources=[
        models.SrtCallerSource(
            SrtListenerAddress="encoder.example.com",
            SrtListenerPort=9000,
            StreamId="primary-feed"
        )
    ]
)

ABR ladder

models.OutputGroup(
    Outputs=[
        models.OutputConfig(
            resolution="1920x1080",
            FramerateNumerator=60,
            FramerateDenominator=1,
            VideoBitrate="8M",
        ),
        models.OutputConfig(
            resolution="1280x720",
            FramerateNumerator=60,
            FramerateDenominator=1,
            VideoBitrate="4M",
        ),
    ],
)

CMAF + HLS/DASH

models.OriginEndpoint(
    name="cmaf-hybrid",
    ContainerType="CMAF",
    HlsManifests=[models.HlsManifest(ManifestWindowSeconds=600)],
    DashManifests=[models.DashManifest(ManifestWindowSeconds=600)],
    StartoverWindowSeconds=86_400,
)

Lifecycle operations

Control an existing pipeline by event ID. Responses are typed, so you can inspect structured fields without manual parsing.

from stegawave import StegawaveClient

EVENT_ID = "example-event-id-123456"

with StegawaveClient() as client:
    start = client.start_pipeline(EVENT_ID)
    print("Start state:", start.state)

    ready = client.wait_for_event(EVENT_ID, timeout=120, poll_interval=5)
    print("Pipeline status:", ready.status)

    stop = client.stop_pipeline(EVENT_ID)
    print("Stop state:", stop.state)

    delete = client.delete_pipeline(EVENT_ID)
    print("Delete status:", delete.status)
    if delete.note:
        print("Note:", delete.note)

Viewer tokens & playback

Generate viewer-specific tokens and stitch them into signed CDN URLs. Tokens arrive as a dictionary keyed by the requested user IDs.

with StegawaveClient() as client:
    tokens = client.fetch_token(["alice", "bob"], exp_hours=2)
    session = client.get_pipeline_session("event-id")

    print(tokens.tokens["alice"])
    for manifest in session.signed_manifest_uris("alice", parameter="token"):
        print(manifest)

Decode & IPTV automation

Tie IPTV discovery into watermark decode jobs. The SDK normalizes IPTV results and decode responses so you can audit the full flow.

with StegawaveClient() as client:
    query = models.IptvQueryRequest(
        server="https://iptv.example.com",
        username="ops",
        password="secret",
        channelName="news-channel",
        format="m3u8",
        preferHD=True,
    )
    catalog = client.iptv_query(query)
    stream = catalog.results[0]

    decode_request = models.DecodeJobRequest(
        eventID="event-id",
        input_stream=stream.stream_urls[0],
    )
    decode_response = client.submit_decode_job(decode_request)
    print("Decode message:", decode_response.message)
    if decode_response.clientID:
        print("Client ID:", decode_response.clientID)

Error handling

Every failure path produces a descriptive exception with optional payload data.

  • AuthenticationError – Missing or invalid API key.
  • AuthorizationError – API key lacks permission for the target resource.
  • ValidationError – The request payload failed schema checks.
  • ProvisioningError – Pipeline provisioning failed or timed out.
  • RateLimitError – Slow down after 429 responses.
  • NetworkError – Retries exhausted while calling the API.
  • ServerError – Upstream 5xx responses.
  • UnexpectedResponseError – Payload shape did not match the models.

Example scripts

Copy, adapt, and run the reference scripts that live alongside this documentation.

Provision a pipeline, await readiness, and emit ingest plus signed manifests.

Loading example…

Models Reference

Complete reference for all Pydantic models available in the SDK. Import from stegawave.models.

Pipeline Creation Models

CreatePipelineRequest

Main request model for creating a new pipeline.

Field Type Required Description
name str Pipeline name
description str Optional description
segmentDuration int Segment duration in seconds (1-30, default: 4)
autoStart bool Automatically start pipeline after creation (default: false)
input InputConfig Input configuration
encoder EncoderConfig Encoder configuration
packager PackagerConfig Packager configuration

InputConfig

Defines the input source type and settings.

Field Type Required Description
Type InputType "RTP", "RTP_FEC", "RIST", "ZIXI_PUSH", "SRT_LISTENER", "SRT_CALLER"
whitelist List[str] CIDR blocks for IP whitelisting (defaults to [0.0.0.0/0])
SrtListenerSettings SrtListenerSettings Required for SRT_LISTENER inputs
SrtCallerSources List[SrtCallerSource] Required for SRT_CALLER inputs

SrtListenerSettings

Configuration for SRT listener inputs.

Field Type Required Description
IngestPort int Port number (1024-65535, excluding 2077/2088)
MinLatency int Min latency in ms (0-60000, default: 2000)
MaxLatency int Max latency in ms (0-60000)
PassphraseEnabled bool Auto-generate 32-char passphrase
Passphrase str Explicit 32-character passphrase

SrtCallerSource

Configuration for SRT caller inputs (outbound connections).

Field Type Required Description
SrtListenerAddress str Remote SRT listener hostname/IP
SrtListenerPort int Remote port (1-65535)
StreamId str Stream ID for routing (max 512 chars)
SrtCallerDecryption SrtCallerDecryption Decryption settings for encrypted remote

EncoderConfig

Encoder settings for video/audio transcoding.

Field Type Required Description
vodArchive bool Enable VOD archiving to S3 (default: false)
Outputs List[OutputConfig] List of output renditions
InputSpecification InputSpecification Input codec/bitrate/resolution constraints

OutputConfig

Configuration for a single output rendition (ABR tier).

Field Type Required Description
resolution str * Resolution as "WIDTHxHEIGHT" (e.g., "1920x1080")
Width int * Width in pixels (1-7680)
Height int * Height in pixels (1-4320)
FramerateNumerator int Framerate numerator (e.g., 30 for 30fps)
FramerateDenominator int Framerate denominator (e.g., 1 for 30fps)
VideoBitrate int | str Video bitrate (supports "5M", "3000k")
AudioBitrate int | str Audio bitrate (default: 128000)
SampleRate int Audio sample rate in Hz (default: 48000)
Profile H264Profile | H265Profile Codec profile (e.g., "HIGH", "MAIN")
AdaptiveQuantization AdaptiveQuantization "AUTO", "OFF", "LOW", "MEDIUM", "HIGH", "HIGHER", "MAX"
OutputName str Custom name for this output

* Provide either resolution string or Width/Height, not both.

PackagerConfig

Packager and origin endpoint configuration.

Field Type Required Description
originEndpoints List[OriginEndpoint] List of origin endpoints

OriginEndpoint

Configuration for a packager origin endpoint.

Field Type Required Description
name str Endpoint name
ContainerType ContainerType "CMAF", "TS", "ISM" (default: "CMAF")
description str Optional description
HlsManifests List[HlsManifest] * HLS manifest configurations
DashManifests List[DashManifest] * DASH manifest configurations
MssManifests List[MssManifest] * MSS manifest configurations
StartoverWindowSeconds int DVR window in seconds (60-1209600)
TsUseAudioRenditionGroup bool Allow audio/video rendition mixing (TS only)

* At least one manifest type must be provided.

HlsManifest

HLS manifest configuration.

Field Type Required Description
ManifestName str Manifest filename without extension (default: "index")
ManifestWindowSeconds int Manifest window duration (30-3600, default: 360)
ProgramDateTimeIntervalSeconds int PDT tag interval (0-3600)
ChildManifestName str Child manifest name for master/child setup

DashManifest

DASH manifest configuration.

Field Type Required Description
ManifestName str Manifest filename without extension (default: "index")
ManifestWindowSeconds int MPD window duration (30-3600, default: 360)
MinUpdatePeriodSeconds int Min manifest refresh interval (1-120)
MinBufferTimeSeconds int Min player buffer requirement (1-900)
SuggestedPresentationDelaySeconds int Recommended playback delay from live edge (1-900)

Response Models

CreatePipelineResponse

Field Type Description
message str Response message
eventID str Unique pipeline identifier
status str Pipeline status ("provisioning")

Methods: is_success(), valid() - check if creation succeeded

PipelineStatusResponse

Field Type Description
eventID str Pipeline ID
name str Pipeline name
description str Pipeline description
status str Current status
createdAt datetime Creation timestamp
lastUpdated datetime Last update timestamp
input PipelineInputStatus Input details and endpoints
encoder PipelineEncoderStatus Encoder profiles and settings
packager PipelinePackagerStatus Packager endpoints
cdn PipelineCdnStatus CDN endpoints
detected_users List[str] List of detected watermark users

Methods: is_ready(), is_terminal_failure()

TokenResponse

Field Type Description
tokens Dict[str, str] User key → JWT token mapping

StateResponse

Field Type Description
message str Response message
eventID str Pipeline ID
action str "status", "start", or "stop"
state str Current state (e.g., "RUNNING", "STOPPED", "STARTING")

DeleteResponse

Field Type Description
message str Response message
eventID str Deleted pipeline ID
status str Deletion status
note str Optional note

ResetHistoryResponse

Requirement: Pipeline must be stopped before calling reset_history(). If the pipeline is running, the API returns a 400 error.

Field Type Description
message str Response message
eventID str Pipeline ID
note Optional[str] Optional additional information

VodArchiveResponse

Field Type Description
eventID str Pipeline ID
clientID str Client ID
eventName str Pipeline name
archive VodArchiveInfo Archive metadata (file count, size, expiry)
files List[VodArchiveFile] List of archive files with presigned URLs

IPTV & Decode Models

IptvQueryRequest

Field Type Required Description
server HttpUrl IPTV server URL
username str IPTV username
password str IPTV password
channelName str Channel name to search
categoryId int Category filter
format str Stream format preference
preferHD bool Prefer HD streams
preferUK bool Prefer UK streams
avoidVIP bool Avoid VIP-only streams

IptvQueryResponse

Field Type Description
results List[IptvStream] List of matching IPTV streams

IptvStream

Field Type Description
name str Stream name
stream_id int Stream identifier
stream_urls List[HttpUrl] Playback URLs

DecodeJobRequest

Field Type Required Description
eventID str Pipeline ID to decode against
input_stream HttpUrl Stream URL to decode

DecodeJobResponse

Field Type Description
message str Response message
eventID str Pipeline ID
clientID str Detected client/user ID (if found)

Type Aliases & Enums

InputType

Literal type for input protocols:

"RTP" | "RTP_FEC" | "RIST" | "ZIXI_PUSH" | "SRT_LISTENER" | "SRT_CALLER"

ContainerType

Literal type for packager container formats:

"CMAF" | "TS" | "ISM"

AdaptiveQuantization

Literal type for adaptive quantization modes:

"AUTO" | "OFF" | "LOW" | "MEDIUM" | "HIGH" | "HIGHER" | "MAX"

H264Profile

Literal type for H.264 codec profiles:

"BASELINE" | "MAIN" | "HIGH" | "HIGH_10BIT" | "HIGH_422" | "HIGH_422_10BIT"

H265Profile

Literal type for H.265 codec profiles:

"MAIN" | "MAIN_10BIT"

Client Methods Reference

Complete API reference for StegawaveClient methods.

Pipeline Management

create_pipeline(request: CreatePipelineRequest) → CreatePipelineResponse

Create a new pipeline. Returns immediately without waiting for provisioning.

response = client.create_pipeline(request)
print(response.eventID)

create_pipeline_session(request: CreatePipelineRequest, wait: bool = True) → PipelineSession

Create pipeline and return a session wrapper. If wait=True, blocks until ready.

session = client.create_pipeline_session(request, wait=True)
print(session.input_uri)

get_pipeline(event_id: str) → PipelineStatusResponse

Get status for a specific pipeline by event ID.

status = client.get_pipeline("event-123")
print(status.status, status.createdAt)

list_pipelines() → PipelineListResponse

List all pipelines for this client.

listing = client.list_pipelines()
for pipeline in listing.pipelines:
    print(pipeline.eventID, pipeline.status)

get_pipeline_session(event_id: str) → PipelineSession

Get a session wrapper for an existing pipeline.

session = client.get_pipeline_session("event-123")
print(session.status.status)

start_pipeline(event_id: str) → StateResponse

Start a stopped pipeline.

response = client.start_pipeline("event-123")
print(response.state)

stop_pipeline(event_id: str) → StateResponse

Stop a running pipeline.

response = client.stop_pipeline("event-123")
print(response.state)

delete_pipeline(event_id: str) → DeleteResponse

Delete a pipeline and all associated resources.

response = client.delete_pipeline("event-123")
print(response.status)

reset_history(event_id: str) → ResetHistoryResponse

Reset the channel history (DVR/startover window) for a pipeline. The pipeline must be stopped first or the API will return a 400 error. This operation clears the DVR window and manifest history.

# Stop pipeline, reset history, then restart
client.stop_pipeline("event-123")
response = client.reset_history("event-123")
print(response.message)  # "Channel history reset successfully"
client.start_pipeline("event-123")

wait_for_event(event_id: str, timeout: float = 300.0, poll_interval: float = 5.0) → PipelineStatusResponse

Poll until pipeline is ready or timeout expires.

status = client.wait_for_event("event-123", timeout=600)
print("Ready:", status.is_ready())

Token & Playback

fetch_token(user_keys: List[str], exp_hours: int = 0) → TokenResponse

Generate viewer tokens for one or more user keys. exp_hours=0 means no expiration.

tokens = client.fetch_token(["user1", "user2"], exp_hours=4)
print(tokens.tokens["user1"])

IPTV & Decode

iptv_query(request: IptvQueryRequest) → IptvQueryResponse

Search IPTV catalogs for matching channels.

response = client.iptv_query(request)
for stream in response.results:
    print(stream.name, stream.stream_urls)

submit_decode_job(request: DecodeJobRequest) → DecodeJobResponse

Submit a watermark decode job for a stream URL.

response = client.submit_decode_job(request)
if response.clientID:
    print("Detected:", response.clientID)

VOD Archive

get_vod_archive(event_id: str, expires_in: int = 3600, download: bool = False, download_path: str = None) → VodArchiveResponse

List VOD archive files with presigned URLs. Optionally download all files.

# List files only
response = client.get_vod_archive("event-123", expires_in=7200)
for file in response.files:
    print(file.filename, file.url)

# Download all files
response = client.get_vod_archive(
    "event-123",
    download=True,
    download_path="./archive"
)

PipelineSession Reference

The PipelineSession class wraps a pipeline with convenience methods for status polling, input details, and signed manifest generation.

Properties

Property Type Description
event_id str Pipeline event ID
status PipelineStatusResponse Latest status (cached)
input_uri str | None Primary input endpoint URI

Methods

refresh() → PipelineStatusResponse

Fetch latest status from API and update cache.

status = session.refresh()
print(status.status)

wait_until_ready(timeout: float = 300.0, poll_interval: float = 5.0) → PipelineStatusResponse

Poll until pipeline is ready or timeout expires.

status = session.wait_until_ready(timeout=600, poll_interval=5)
print("Ready:", status.is_ready())

get_input() → InputDetails

Normalize input details into a structured object.

input_details = session.get_input()
print(input_details.protocol)
print(input_details.uri)
print(input_details.uris)
print(input_details.allowed_ips)

get_manifests() → List[ManifestDetails] | None

Extract manifest metadata from CDN endpoints.

manifests = session.get_manifests()
if manifests:
    for manifest in manifests:
        print(manifest.protocol, manifest.uri)

signed_manifest_uris(user_key: str, exp_hours: int = 0, parameter: str = "token") → List[str]

Generate signed CDN manifest URLs for a viewer.

urls = session.signed_manifest_uris("viewer-123", exp_hours=4)
for url in urls:
    print(url)