Replane Python SDK

Python SDK for Replane - a dynamic configuration platform with real-time updates.

Features

  • Real-time updates via Server-Sent Events (SSE)

  • Context-based overrides for feature flags, A/B testing, and gradual rollouts

  • Zero dependencies for sync client (stdlib only)

  • Both sync and async clients available

  • Type-safe with full type hints

  • Testing utilities with in-memory client

Quick Example

Sync Client

from replane import Replane

# Using context manager (recommended)
with Replane(
    base_url="https://replane.example.com",
    sdk_key="rp_...",
) as replane:
    # Get a config value
    rate_limit = replane.configs["rate_limit"]

    # Get with context for override evaluation
    user_client = replane.with_context({"user_id": user.id, "plan": user.plan})
    feature_enabled = user_client.configs["new_feature"]

Or without context manager:

replane = Replane()
replane.connect(base_url="...", sdk_key="...")

rate_limit = replane.configs["rate_limit"]

replane.close()

Async Client

from replane import AsyncReplane

# Using async context manager (recommended)
async with AsyncReplane(
    base_url="https://replane.example.com",
    sdk_key="rp_...",
) as replane:
    rate_limit = replane.configs["rate_limit"]

    user_client = replane.with_context({"user_id": user.id})
    feature_enabled = user_client.configs["new_feature"]

Or without context manager:

replane = AsyncReplane()
await replane.connect(base_url="...", sdk_key="...")

rate_limit = replane.configs["rate_limit"]

await replane.close()

Type-safe with Generated Types

Generate TypedDict types from the Replane dashboard for full type safety.

Example generated replane_types.py:

# replane_types.py - Generated from Replane dashboard
from typing import List, TypedDict

class AppSettings(TypedDict):
    max_upload_size_mb: float
    allowed_file_types: List[str]
    maintenance_mode: bool

class Configs(TypedDict):
    app_settings: AppSettings
    rate_limit: int
    feature_enabled: bool

Usage with generated types:

from replane import Replane
from replane_types import Configs

with Replane[Configs](
    base_url="https://replane.example.com",
    sdk_key="rp_...",
) as replane:
    # Dictionary-style access with full type safety
    settings = replane.configs["app_settings"]
    print(settings["max_upload_size_mb"])  # IDE knows the type
    print(settings["allowed_file_types"])  # Autocomplete works

Indices and tables