{"library":"openfeature-provider-flagsmith","title":"OpenFeature Provider for Flagsmith","description":"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install openfeature-provider-flagsmith"],"cli":null},"imports":["from openfeature_provider_flagsmith import FlagsmithProvider","from openfeature import OpenFeatureAPI"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom openfeature import OpenFeatureAPI\nfrom openfeature_provider_flagsmith import FlagsmithProvider\n\n# Ensure you have your Flagsmith Environment Key set as an environment variable\n# Or replace os.environ.get() with your actual key directly (not recommended for production)\nFLAGSMITH_ENVIRONMENT_KEY = os.environ.get(\"FLAGSMITH_ENVIRONMENT_KEY\", \"\")\n\nif not FLAGSMITH_ENVIRONMENT_KEY:\n    print(\"Error: FLAGSMITH_ENVIRONMENT_KEY environment variable not set.\")\n    print(\"Please set it to your Flagsmith Environment Key to run this example.\")\nelse:\n    # 1. Initialize the Flagsmith Provider\n    provider = FlagsmithProvider(environment_key=FLAGSMITH_ENVIRONMENT_KEY)\n\n    # 2. Set the provider globally for OpenFeature\n    OpenFeatureAPI.set_provider(provider)\n\n    # 3. Get an OpenFeature client\n    client = OpenFeatureAPI.get_client()\n\n    # 4. Evaluate a feature flag (assuming 'my_boolean_flag' exists in Flagsmith)\n    # Provide a default value (False) in case the flag is not found or an error occurs\n    is_feature_enabled = client.get_boolean_value(\"my_boolean_flag\", False)\n\n    print(f\"Feature 'my_boolean_flag' is enabled: {is_feature_enabled}\")\n\n    # Example with a string flag\n    welcome_message = client.get_string_value(\"welcome_message\", \"Hello, World!\")\n    print(f\"Welcome message: {welcome_message}\")\n","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}