Registry / crm-productivity / openfeature-provider-flagsmith

openfeature-provider-flagsmith

JSON →
library0.2.0pypypiunverified

The `openfeature-provider-flagsmith` library provides an OpenFeature-compliant provider for Flagsmith. It allows applications to integrate Flagsmith's feature flag capabilities using the OpenFeature SDK, abstracting the underlying feature flagging system. The current version is 0.1.6, with releases typically tied to updates in OpenFeature SDK or Flagsmith SDK, or feature enhancements.

pip install openfeature-provider-flagsmith
INSTALL
IMPORT
SIG · OPENFEATURE-PROVID
O
openfeature-provider-flagsmith
crm-productivitypythonv0.2.0
Install
3.7s avg
Import
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 26.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.7s · import 0.000s · 27MB
25MB installed
● package 25MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FlagsmithProvider
from openfeature_flagsmith import FlagsmithProvider
from openfeature_flagsmith import FlagsmithProvider

This quickstart demonstrates how to initialize the `FlagsmithProvider` with your Flagsmith Environment Key, register it with the OpenFeature API, and then use the OpenFeature client to evaluate boolean and string feature flags. Ensure your `FLAGSMITH_ENVIRONMENT_KEY` is set as an environment variable.

import os from openfeature import OpenFeatureAPI from openfeature_provider_flagsmith import FlagsmithProvider # Ensure you have your Flagsmith Environment Key set as an environment variable # Or replace os.environ.get() with your actual key directly (not recommended for production) FLAGSMITH_ENVIRONMENT_KEY = os.environ.get("FLAGSMITH_ENVIRONMENT_KEY", "") if not FLAGSMITH_ENVIRONMENT_KEY: print("Error: FLAGSMITH_ENVIRONMENT_KEY environment variable not set.") print("Please set it to your Flagsmith Environment Key to run this example.") else: # 1. Initialize the Flagsmith Provider provider = FlagsmithProvider(environment_key=FLAGSMITH_ENVIRONMENT_KEY) # 2. Set the provider globally for OpenFeature OpenFeatureAPI.set_provider(provider) # 3. Get an OpenFeature client client = OpenFeatureAPI.get_client() # 4. Evaluate a feature flag (assuming 'my_boolean_flag' exists in Flagsmith) # Provide a default value (False) in case the flag is not found or an error occurs is_feature_enabled = client.get_boolean_value("my_boolean_flag", False) print(f"Feature 'my_boolean_flag' is enabled: {is_feature_enabled}") # Example with a string flag welcome_message = client.get_string_value("welcome_message", "Hello, World!") print(f"Welcome message: {welcome_message}")
Debug
Known issues
gotchaThe `environment_key` is a mandatory argument for `FlagsmithProvider`. Failure to provide a valid key will lead to errors during initialization or feature flag evaluation.
fix
Always provide your Flagsmith Environment Key during `FlagsmithProvider` instantiation: `FlagsmithProvider(environment_key="YOUR_KEY")`.
affects: All
gotchaThe provider relies on network connectivity to the Flagsmith API. Issues like network timeouts or incorrect API endpoints (if customized) can prevent feature flags from being resolved.
fix
Ensure your application has stable network access to the Flagsmith API. Check your Flagsmith project configuration and API status if you encounter network-related errors. Consider using `OpenFeatureAPI.set_default_value` for robust fallback behavior.
affects: All
gotchaThe OpenFeature `get_value` methods (e.g., `get_boolean_value`) require a default value. This default is returned if the flag is not found in Flagsmith, if the provider is not configured correctly, or if an error occurs during evaluation.
fix
Always provide a sensible and safe default value that ensures your application can function even if the feature flag cannot be resolved correctly. E.g., `client.get_boolean_value("my_flag", False)`.
affects: All
deprecatedThe `flagsmith` SDK dependency has minimum version `4.0.0` and maximum `5.x.x` (i.e., `<6.0.0`). Newer versions of the `flagsmith` SDK (e.g., `6.x.x`) may introduce breaking changes not yet supported by this provider.
fix
Strictly adhere to the `flagsmith` SDK version range specified by `openfeature-provider-flagsmith`'s `install_requires`. Upgrade `openfeature-provider-flagsmith` if you need to use a newer `flagsmith` SDK version.
affects: >=0.1.0
Upgrade
Version history
0.2.0latest on PyPI · released Apr 30, 2026
Audit
Dependencies
flagsmithrequiredRequired for interacting with the Flagsmith API.
openfeature-sdkrequiredThe core OpenFeature SDK for Python, which this provider integrates with.
Agent activity
22 hits · last 30 days
node
19
OpenAI (training)
1
Resources
openfeature-provider-flagsmith — pip install openfeature-provider-flagsmith · libregistry