-
Notifications
You must be signed in to change notification settings - Fork 0
Quickstart
Usman Abbas edited this page May 5, 2026
·
3 revisions
A copy-paste-ready guide to get the Convert Python SDK running in under 5 minutes.
pip install convert-python-sdkOr with uv:
uv add convert-python-sdkThe install includes httpx as the default HTTP client — no extra install is
needed. Python 3.9 or newer is required. To swap the default transport, see
Extending.
import os
from convert_sdk import (
Core,
SDKConfig,
TransportConfig,
FeatureStatus,
)
# 1. Initialize the SDK (sync, blocking)
core = Core(
SDKConfig(
sdk_key=os.environ["CONVERT_SDK_KEY"],
environment="production",
transport=TransportConfig(
config_endpoint="https://cdn-4.convertexperiments.com/api/v1",
),
)
)
# 2. Verify the SDK is ready
assert core.is_ready, "SDK failed to initialize"
# 3. Create a visitor context
context = core.create_context(
"visitor-123",
{"country": "US", "plan": "premium"},
)
# 4. Run an experience
result = context.run_experience(
"homepage-redesign",
location_attributes={"path": "/"},
)
if result is not None:
print(f"Experience: {result.experience_key}")
print(f"Variation: {result.variation_key}")
# 5. Resolve a feature flag
feature = context.run_feature("dark-mode")
if feature is not None and feature.status == FeatureStatus.ENABLED:
theme = feature.variables.get("theme", "dark")
print(f"Dark mode theme: {theme}")
# 6. Track a conversion with revenue
context.track_conversion(
"purchase-completed",
conversion_data={
"revenue": 49.99,
"transaction_id": "txn-abc-123",
},
)
# 7. Flush queued tracking events before the process exits or the request ends
flush = context.release_queues(reason="end_of_request")
print(f"Delivered {flush.delivered_event_count} events")-
Synchronous: The Python SDK is fully synchronous. There is no
on_ready()coroutine.Core(SDKConfig(...))blocks while the config is fetched and returns when the SDK is ready. -
is_ready: Readcore.is_readyafter construction; it isTrueonce the snapshot is loaded. A failed config fetch raisesConfigLoadErrorfrom__init__, so reachingcore.is_readyalready implies success. -
No auto-flush: Tracking events are queued in-process. Call
context.release_queues()explicitly at end-of-request, before exit, or in afinallyblock. See Code Examples — Queue Control. -
Config refresh is opt-in: Long-running services that want background
config refresh must pass
SDKConfig(refresh=RefreshConfig(...)). See Initialization § automatic config refresh. -
Noneis a normal outcome:run_experience()andrun_feature()returnNonewhen the visitor doesn't qualify — no exception is raised.
For tests, CI, or local development, pass an inline config dict:
core = Core(SDKConfig(config_data={
"account_id": "1001",
"project": {"id": "2002", "name": "Demo"},
"experiences": [],
"features": [],
"goals": [],
}))- Installation — Python version, optional dependencies, virtualenv setup
-
Initialization — SDK Key vs. direct config,
RefreshConfig - Configuration — Full config options reference
- Code Examples — All SDK methods with examples
- Type Hints — Dataclasses, Protocols, and enums reference
Copyrights © 2025 All Rights Reserved by Convert Insights, Inc.
Getting Started
Python SDK
- Quickstart
- Installation
- Initialization
- Configuration
- Code Examples
- Type Hints
- Diagnostics
- Extending
- Testing
- Async & Frameworks
Migration
Core Concepts
- Experiences & Variations
- Feature Flags
- Bucketing Algorithm
- Rule Evaluation
- Segments
- Data Management
- Event System
- API Communication
How-To Guides
- Running Experiences
- Running Features
- Tracking Conversions
- Visitor Context
- Persistent DataStore
- Troubleshooting
Edge & Integrations
Maintainers