Skip to main content

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 (includes status / status_text). A 404 means 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:

  1. 200 with that object
  2. 404 — flag ID not found
  3. 500 — 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

rocketflag-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

rocketflag-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

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

Hashes for rocketflag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1121797d66364a7b2c544a5dcd8ab5a2d6cc7033f7b2fe199a2764caa10a09b1
MD5 b25683f1c9b248d4d40beb35d521a0d3
BLAKE2b-256 362e41256d5a5d125e20773af8ba9021e9dbfd8ec678eb7c74f35d981e5b4f63

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocketflag-0.1.0.tar.gz:

Publisher: pypi-publish.yml on RocketFlag/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for rocketflag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ceadb49eaa86a69d585b2ad57c6d88e64a8a503bef99f1e0a5db13bd308cf24d
MD5 b85837f2550dec7721005dfcba9b3094
BLAKE2b-256 2eeaa0e7a51b79e67fd4d8f6d0d0e98a1d0e6376c4b829dad01d7e1047e2deb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rocketflag-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on RocketFlag/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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