RocketFlag Python SDK
Official Python SDK for RocketFlag. Same evaluation API as the Node and Go SDKs: create a client, fetch a flag, branch on flag.enabled.
Installation
pip install rocketflag
Python 3.9+. No third-party runtime dependencies.
Published releases go to PyPI via GitHub Releases. For an unreleased commit:
pip install git+https://github.com/RocketFlag/python-sdk.git
Basic usage
from rocketflag import create_client
rocketflag = create_client() # default API URL and version (v1)
flag = rocketflag.get_flag("IFldMzqP5jtv9wAL")
if flag.enabled:
render_new_dashboard()
else:
render_legacy_dashboard()
You can also construct Client directly:
from rocketflag import Client
client = Client()
flag = client.get_flag("IFldMzqP5jtv9wAL")
Custom version or API URL
rocketflag = create_client("v2", "https://your-api-domain.com")
Cohorts and environment
flag = rocketflag.get_flag("IFldMzqP5jtv9wAL", {
"cohort": "beta",
"env": "prod",
})
env must be alphanumeric, matching the Node SDK.
Caching
Opt-in in-memory cache, keyed by flag ID and user context. Same behaviour as Node/Go.
# Cache flag responses for 5 minutes.
rocketflag = create_client(ttl_seconds=300)
flag = rocketflag.get_flag("IFldMzqP5jtv9wAL", {"cohort": "beta"})
# Force a fresh fetch.
flag = rocketflag.get_flag("IFldMzqP5jtv9wAL", ttl_seconds=0)
# Shorter TTL for one call.
flag = rocketflag.get_flag("IFldMzqP5jtv9wAL", ttl_seconds=10)
Without a client default or per-call TTL, every call hits the API. The cache has no size cap; entries expire on the next lookup after TTL.
Errors
from rocketflag import APIError, InvalidResponseError, NetworkError, create_client
rocketflag = create_client()
try:
flag = rocketflag.get_flag("IFldMzqP5jtv9wAL")
except APIError as err:
print(f"API Error: {err.status} {err.status_text}")
except InvalidResponseError as err:
print(f"Invalid Response Error: {err}")
except NetworkError as err:
print(f"Network Error: {err}")
APIError— non-OK HTTP status (includesstatus/status_text). A404means the flag ID is unknown.InvalidResponseError— body is not JSON or not a flag object (name,enabled,id).NetworkError— connection failure.
Response
A successful call returns a Flag:
Flag(name="The user-created flag name", enabled=True, id="asklWQQZdslhfsszZWkj")
The HTTP API may also return:
200with that object404— flag ID not found500— rare server error; RocketFlag is alerted
Development
python -m pip install -e ".[dev]"
python -m pytest
A container demo that hits the live API lives in demo/.
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 rocketflag-0.1.0.tar.gz.
File metadata
- Download URL: rocketflag-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1121797d66364a7b2c544a5dcd8ab5a2d6cc7033f7b2fe199a2764caa10a09b1
|
|
| MD5 |
b25683f1c9b248d4d40beb35d521a0d3
|
|
| BLAKE2b-256 |
362e41256d5a5d125e20773af8ba9021e9dbfd8ec678eb7c74f35d981e5b4f63
|
Provenance
The following attestation bundles were made for rocketflag-0.1.0.tar.gz:
Publisher:
pypi-publish.yml on RocketFlag/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocketflag-0.1.0.tar.gz -
Subject digest:
1121797d66364a7b2c544a5dcd8ab5a2d6cc7033f7b2fe199a2764caa10a09b1 - Sigstore transparency entry: 2861238857
- Sigstore integration time:
-
Permalink:
RocketFlag/python-sdk@eda8bce09558be8904fc51dd4151fb57c82033fc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/RocketFlag
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@eda8bce09558be8904fc51dd4151fb57c82033fc -
Trigger Event:
release
-
Statement type:
File details
Details for the file rocketflag-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rocketflag-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceadb49eaa86a69d585b2ad57c6d88e64a8a503bef99f1e0a5db13bd308cf24d
|
|
| MD5 |
b85837f2550dec7721005dfcba9b3094
|
|
| BLAKE2b-256 |
2eeaa0e7a51b79e67fd4d8f6d0d0e98a1d0e6376c4b829dad01d7e1047e2deb9
|
Provenance
The following attestation bundles were made for rocketflag-0.1.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on RocketFlag/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rocketflag-0.1.0-py3-none-any.whl -
Subject digest:
ceadb49eaa86a69d585b2ad57c6d88e64a8a503bef99f1e0a5db13bd308cf24d - Sigstore transparency entry: 2861239585
- Sigstore integration time:
-
Permalink:
RocketFlag/python-sdk@eda8bce09558be8904fc51dd4151fb57c82033fc -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/RocketFlag
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@eda8bce09558be8904fc51dd4151fb57c82033fc -
Trigger Event:
release
-
Statement type: