Skip to main content

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

Metadata

Release files for redpennon 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redpennon 1.1.0
File Size Uploaded Provenance Actions
redpennon-1.1.0.tar.gz 9.7 kB Without provenance Details for redpennon-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for redpennon 1.1.0
File Interpreter ABI Platform Actions
redpennon-1.1.0-py3-none-any.whl Python 3 none any Details for redpennon-1.1.0-py3-none-any.whl

Total release size: 16.6 kB

Release files / redpennon-1.1.0.tar.gz

Download URL redpennon-1.1.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
caaf5bdcdb9e579ebf3ab66bc4040a99ca11f400c14ed1696fccc1b876d01717
BLAKE2b-256 checksum
How to use checksums
c263f59b03b078105ef475e61c97c2b6ff68d89ce8f032dd8e5d7421bb214664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / redpennon-1.1.0-py3-none-any.whl

Download URL redpennon-1.1.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf472e719dbd0eddc9a70d906055894dc36738fae93c3aeeba7e9aa12e50191a
BLAKE2b-256 checksum
How to use checksums
75e5900bb3159eb751928470acbe459ad1fbdb13013b44d20087c0d5ea9c3212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for redpennon 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page