Skip to main content

RedPennon feature flag evaluation API client

Project description

redpennon · Python SDK

PyPI Python License: MIT

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

redpennon-1.0.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

redpennon-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

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

Hashes for redpennon-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f255c82bdbc677de70e9463dcea6399a2537fcebe1e18698038100046356a247
MD5 68da6d52ce7e3d4186507c82f6daa113
BLAKE2b-256 9b5476eb16a6af56668de736364e92f592b354688e4905835b8d2d4bfbb796b8

See more details on using hashes here.

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

Hashes for redpennon-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9076aade3bcde3522e77f76b506fe46e94c9ece14663ea7a311eabaf8ec6a028
MD5 a82fe38256aa9587bfb7f45eacd5cfa4
BLAKE2b-256 3a25e5b286529df686300fcccd8c26ae0cc23b7d7df3faacebb2bd84f2fed80a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page