Skip to content

Python SDK

feat-sdk (PyPI) is the Python SDK. Standard library only. Evaluates flags locally against a polled datafile.

Terminal window
pip install feat-sdk

Python 3.10 or newer.

from feat import Client, ClientConfig, EvalContext
client = Client(ClientConfig(
api_key="feat_sdk_...",
data_plane_url="https://data.feat.so",
))
client.ready()
ctx = EvalContext(
targeting_key="user-123",
kinds={"user": {"plan": "pro", "email": "alice@example.com"}},
)
if client.get_boolean_value("checkout-v2", False, ctx):
# ...
pass
client.close()

Use a server key (feat_sdk_…).

enabled = client.get_boolean_value("checkout-v2", False, ctx)
variant = client.get_string_value("hero-copy", "control", ctx)
limit = client.get_number_value("rate-limit", 100, ctx)
config = client.get_object_value("layout-config", {}, ctx)
result = client.evaluate("checkout-v2", False, ctx)
# result.value, result.variation_id, result.reason, result.error_message

reason is one of TARGETING_MATCH, SPLIT, FALLTHROUGH, DEFAULT, DISABLED, ERROR. See Evaluation order.

  • Client(config) constructs and starts a background daemon thread that polls the datafile.
  • client.ready() blocks until the first datafile arrives.
  • client.close() stops the thread cleanly.

The daemon thread does not block process exit, but close() should still be called for orderly shutdown.

ClientConfig(
api_key="feat_sdk_...",
data_plane_url="https://data.feat.so",
poll_interval=30.0, # seconds; default 30, minimum 5
bootstrap=None, # optional: a parsed datafile dict to skip the first fetch
)

The Python SDK ports the same evaluation algorithm as @feathq/feat-eval bit-for-bit. The same datafile, the same context, and the same flag key always give the same result across Node.js, Go, Python, and Ruby.