# Superposition Provider
Superposition provider is an openfeature provider that works with [Superposition](https://juspay.io/open-source/superposition) to fetch feature flags, configurations, and experiment variants from a Superposition server, store it in-memory and do configuration resolutions based on dynamic contexts. Read the [docs](https://juspay.io/open-source/superposition/docs) for more details.
### Installation
Install the provider
```bash
pip install openfeature-sdk
pip install superposition-provider
```
> **Note:** You will need to boot up Superposition before running the client code. Check the docs on how to get started with Superposition.
## Initialization
To initialize the Superposition provider, you need to create a configuration. Create the provider object and then, you can set the provider using OpenFeature's API.
```python
from openfeature import api
from superposition_provider.provider import SuperpositionProvider
from superposition_provider.types import ExperimentationOptions, SuperpositionProviderOptions, PollingStrategy
config_options = SuperpositionProviderOptions(
endpoint="http://localhost:8080",
token="api-token",
org_id="localorg",
workspace_id="test",
refresh_strategy=PollingStrategy(
interval=5, # Poll every 5 seconds
timeout=3 # Timeout after 3 seconds
),
fallback_config=None,
evaluation_cache_options=None,
experimentation_options=ExperimentationOptions(
refresh_strategy=PollingStrategy(
interval=5, # Poll every 5 seconds
timeout=3 # Timeout after 3 seconds
)
)
)
provider = SuperpositionProvider(provider_options=config_options)
# Initialize provider
await provider.initialize(context=ctx)
api.set_provider(provider)
```
## Usage
Once the provider is initialized, you can evaluate feature flags and configurations using the OpenFeature client.
```python
client = api.get_client()
ctx = EvaluationContext(
targeting_key="25", # Using a targeting key for experiment variant decider
attributes={'d1': 'd1'}
)
bool_val = client.get_boolean_details(
flag_key="bool",
default_value=True,
evaluation_context=ctx
)
# Note: If you want the whole config, you can directly use the provider itself
resp = provider.resolve_all_config_details({}, ctx)
print(f"Response for all config: {resp}")
print("Successfully resolved boolean flag details:", bool_val)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "superposition-provider",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "openfeature, superposition_provider",
"author": null,
"author_email": null,
"download_url": null,
"platform": null,
"description": "# Superposition Provider\n\nSuperposition provider is an openfeature provider that works with [Superposition](https://juspay.io/open-source/superposition) to fetch feature flags, configurations, and experiment variants from a Superposition server, store it in-memory and do configuration resolutions based on dynamic contexts. Read the [docs](https://juspay.io/open-source/superposition/docs) for more details.\n\n### Installation\n\nInstall the provider\n\n```bash\npip install openfeature-sdk\npip install superposition-provider\n```\n\n> **Note:** You will need to boot up Superposition before running the client code. Check the docs on how to get started with Superposition.\n\n## Initialization\n\nTo initialize the Superposition provider, you need to create a configuration. Create the provider object and then, you can set the provider using OpenFeature's API.\n\n```python\nfrom openfeature import api\nfrom superposition_provider.provider import SuperpositionProvider\nfrom superposition_provider.types import ExperimentationOptions, SuperpositionProviderOptions, PollingStrategy\n\nconfig_options = SuperpositionProviderOptions(\n endpoint=\"http://localhost:8080\",\n token=\"api-token\",\n org_id=\"localorg\", \n workspace_id=\"test\",\n refresh_strategy=PollingStrategy(\n interval=5, # Poll every 5 seconds\n timeout=3 # Timeout after 3 seconds\n ),\n fallback_config=None,\n evaluation_cache_options=None,\n experimentation_options=ExperimentationOptions(\n refresh_strategy=PollingStrategy(\n interval=5, # Poll every 5 seconds\n timeout=3 # Timeout after 3 seconds\n )\n )\n)\n\nprovider = SuperpositionProvider(provider_options=config_options)\n# Initialize provider\nawait provider.initialize(context=ctx)\napi.set_provider(provider)\n```\n\n## Usage\n\nOnce the provider is initialized, you can evaluate feature flags and configurations using the OpenFeature client.\n\n```python\nclient = api.get_client()\n\nctx = EvaluationContext(\n targeting_key=\"25\", # Using a targeting key for experiment variant decider\n attributes={'d1': 'd1'}\n)\n\nbool_val = client.get_boolean_details(\n flag_key=\"bool\",\n default_value=True,\n evaluation_context=ctx\n)\n# Note: If you want the whole config, you can directly use the provider itself\nresp = provider.resolve_all_config_details({}, ctx)\nprint(f\"Response for all config: {resp}\")\n\nprint(\"Successfully resolved boolean flag details:\", bool_val)\n```\n\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "superposition_provider",
"version": "0.88.1",
"project_urls": null,
"split_keywords": [
"openfeature",
" superposition_provider"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e10feb4624b25f351f2386cfa3338b57450bc4a2c3897df5754cd6fd127b9915",
"md5": "4201ec5ab82e2b40be4f2c25ee819002",
"sha256": "8e1ad79c1c6f61552184d2e12aeaa22bbedf76d2a3ecb4f5e6bb3a231f3488a0"
},
"downloads": -1,
"filename": "superposition_provider-0.88.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4201ec5ab82e2b40be4f2c25ee819002",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 1537990,
"upload_time": "2025-08-22T05:41:06",
"upload_time_iso_8601": "2025-08-22T05:41:06.018494Z",
"url": "https://files.pythonhosted.org/packages/e1/0f/eb4624b25f351f2386cfa3338b57450bc4a2c3897df5754cd6fd127b9915/superposition_provider-0.88.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-22 05:41:06",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "superposition-provider"
}