Flipt Server SDK
Actively maintained. Last release 2 months ago. A safe choice.
pip install fliptFlipt Python
This directory contains the Python source code for the Flipt server-side client.
Documentation
API documentation is available at https://www.flipt.io/docs/reference/overview.
Installation
pip install flipt=={version}
Usage
In your Python code you can import this client and use it as so:
from flipt import FliptClient
from flipt.evaluation import BatchEvaluationRequest, EvaluationRequest
flipt_client = FliptClient()
variant_flag = flipt_client.evaluation.variant(
EvaluationRequest(
namespace_key="default",
flag_key="flagll",
entity_id="entity",
context={"fizz": "buzz"},
)
)
print(variant_flag)
There is a more detailed example in the examples directory.
Setting HTTP Headers
You can set custom HTTP headers for the client by using the headers parameter in the constructor.
flipt_client = FliptClient(headers={"X-Custom-Header": "Custom-Value"})
Flipt V2 Environment Support
Flipt V2 introduces the concept of environments. This client supports evaluation of flags in a specific environment by using the X-Flipt-Environment header.
flipt_client = FliptClient(headers={"X-Flipt-Environment": "production"})
Upgrading to 2.0
Version 2.0 replaces the httpx dependency with httpx2, Pydantic's maintained fork with the same API. The Flipt API surface does not change. These details do:
- Transport errors such as connection refused, timeouts, and Transport Layer Security (TLS) failures are now
httpx2exceptions, for examplehttpx2.ConnectErrorandhttpx2.TimeoutException. Updateexceptclauses that namehttpxexceptions to thehttpx2equivalents. does not change.