RedPennon feature flag evaluation API client
Project description
redpennon · Python SDK
Thin HTTP client for the RedPennon feature flag evaluation API.
Installation
pip install redpennon
Requires Python 3.12+ and httpx.
Quick start
from redpennon import Client, UserContext
client = Client(api_key="YOUR_ENV_API_KEY")
# Simple: get the resolved value or your default on any failure.
enabled = client.variable_value("dark-mode-enabled", default=False)
# With user context (for targeting rules).
user = UserContext(id="user_123", email="alice@example.com")
enabled = client.variable_value("dark-mode-enabled", default=False, user=user)
# Full result: value + variation + reason.
result = client.variable("dark-mode-enabled", user=user)
print(result.value, result.variation, result.reason)
# Batch: resolve many flags in one round-trip.
results = client.variables(["flag-a", "flag-b"], user=user)
flag_a = results["flag-a"].value
API
Client(api_key, *, base_url=None, http_client=None)
| Parameter | Type | Description |
|---|---|---|
api_key |
str |
Environment API key from the RedPennon dashboard. |
base_url |
str | None |
Override the API base URL (default: https://api.redpennon.dev). |
http_client |
httpx.Client | None |
Custom client — useful for testing with MockTransport. |
client.variable_value(key, *, default, user=None) → T
Returns the resolved value or default on any failure (network error, non-2xx, value=null). Use this in production code — your default is the load-bearing contract.
client.variable(key, *, user=None) → VariableResult
Returns the full evaluation result (value, variation, reason, feature). Raises APIError on network or non-2xx errors.
client.variables(keys, *, user=None) → dict[str, VariableResult]
Batch evaluation — one HTTP round-trip for multiple flags. Unknown keys return reason="variable_not_found" inline rather than raising.
Local development
pip install -e '.[dev]'
pytest
License
MIT © RedPennon
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file redpennon-1.0.0.tar.gz.
File metadata
- Download URL: redpennon-1.0.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f255c82bdbc677de70e9463dcea6399a2537fcebe1e18698038100046356a247
|
|
| MD5 |
68da6d52ce7e3d4186507c82f6daa113
|
|
| BLAKE2b-256 |
9b5476eb16a6af56668de736364e92f592b354688e4905835b8d2d4bfbb796b8
|
File details
Details for the file redpennon-1.0.0-py3-none-any.whl.
File metadata
- Download URL: redpennon-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9076aade3bcde3522e77f76b506fe46e94c9ece14663ea7a311eabaf8ec6a028
|
|
| MD5 |
a82fe38256aa9587bfb7f45eacd5cfa4
|
|
| BLAKE2b-256 |
3a25e5b286529df686300fcccd8c26ae0cc23b7d7df3faacebb2bd84f2fed80a
|