{"id":3936,"library":"configcat-client","title":"ConfigCat Python SDK","description":"ConfigCat SDK for Python provides easy integration for your application to ConfigCat. It's a feature flag and configuration management service that lets you separate releases from deployments, enabling remote control over features. The library is actively maintained, with the current version being 10.0.0, and receives regular updates including new features and compatibility improvements.","status":"active","version":"10.0.0","language":"en","source_language":"en","source_url":"https://github.com/configcat/python-sdk","tags":["feature flags","remote config","configuration management","A/B testing","developer tools"],"install":[{"cmd":"pip install configcat-client","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"HTTP client for fetching configurations. Minimum version increased in v8.0.1 and v10.0.0.","package":"requests","optional":false},{"reason":"Used for semantic version parsing. Minimum version increased in v8.0.0.","package":"semver","optional":false}],"imports":[{"symbol":"configcatclient","correct":"import configcatclient"},{"note":"Deprecated client creation functions (e.g., `create_client`, `create_client_with_auto_poll`) were removed in v8.0.0. Use `configcatclient.get()` for singleton client instances.","wrong":"from configcatclient import create_client","symbol":"get","correct":"client = configcatclient.get(\"#YOUR-SDK-KEY#\")"},{"symbol":"ConfigCatOptions","correct":"from configcatclient import ConfigCatOptions"},{"symbol":"PollingMode","correct":"from configcatclient import PollingMode"},{"symbol":"User","correct":"from configcatclient import User"}],"quickstart":{"code":"import os\nimport configcatclient\n\n# Get your SDK Key from ConfigCat Dashboard (e.g., via environment variable)\nSDK_KEY = os.environ.get('CONFIGCAT_SDK_KEY', 'YOUR_SDK_KEY_HERE')\n\ndef main():\n    # Create a ConfigCat client instance (recommended as a singleton)\n    client = configcatclient.get(SDK_KEY)\n\n    # Get your setting value\n    # The second argument is the default value if the key is not found\n    is_my_awesome_feature_enabled = client.get_value('isMyAwesomeFeatureEnabled', False)\n\n    if is_my_awesome_feature_enabled:\n        print(\"Feature is ENABLED!\")\n    else:\n        print(\"Feature is DISABLED.\")\n\n    # You can also get a value for a specific user\n    user = configcatclient.User('some-user-id', email='user@example.com')\n    is_feature_for_user = client.get_value('isMyAwesomeFeatureEnabled', False, user)\n    print(f\"Feature for user 'some-user-id': {is_feature_for_user}\")\n\n    # Stop ConfigCat client on application exit to release resources\n    client.close()\n    # Alternatively, configcatclient.close_all() to close all clients\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates how to initialize the ConfigCat client, retrieve a feature flag's value, and safely close the client. It also shows how to get a value for a specific user using a `User` object. Remember to replace `YOUR_SDK_KEY_HERE` with your actual ConfigCat SDK Key, ideally loaded from an environment variable."},"warnings":[{"fix":"Upgrade to Python 3.8 or newer. Ensure your CI/CD pipelines and deployment environments use a supported Python version.","message":"Version 10.0.0 dropped support for Python 2.7, 3.5, 3.6, and 3.7. Attempting to use the library on these versions will result in `ImportError` or other compatibility issues.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Replace calls to removed `create_client` functions with `client = configcatclient.get(sdk_key)`. Update `client.stop()` calls to `client.close()`.","message":"Deprecated client initialization functions like `configcatclient.create_client()`, `create_client_with_auto_poll()`, etc., were removed in v8.0.0. The `stop()` method was also renamed to `close()`.","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"If using local flag overrides, convert your config JSON files from v5 to v6 using the ConfigCat CLI tool. Update any code expecting `User` custom attributes to be strictly strings.","message":"Version 9.0.0 introduced support for Config JSON v6 format. The older v5 format is no longer accepted for flag overrides, and the `User`'s `custom` dictionary now allows attribute values other than strings.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Initialize the client once at application startup using `client = configcatclient.get(SDK_KEY)` and reuse this instance across your application rather than creating new ones.","message":"It is strongly recommended to use the ConfigCat Client as a singleton object throughout your application. `configcatclient.get()` returns a singleton instance for a given SDK key.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure `client.close()` is called for individual clients, or `configcatclient.close_all()` is called to shut down all clients, typically in a `finally` block or application shutdown hook.","message":"Failure to explicitly close the ConfigCat client on application exit can lead to resource leaks (e.g., open HTTP connections, lingering background threads for polling).","severity":"gotcha","affected_versions":"all"},{"fix":"Validate your SDK key format (it's a 22-character string consisting of Latin letters, numbers, and hyphens) before passing it to `configcatclient.get()`, or handle `ConfigCatClientException` gracefully.","message":"Starting from v8.0.0, passing an invalid SDK key format to `configcatclient.get()` will raise a `ConfigCatClientException` unless the client is configured for local-only flag overrides.","severity":"gotcha","affected_versions":">=8.0.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}