Skip to main content

Feature flags for Indie Flags — is_enabled, get_value, optional 60s cache

Project description

Indie Flags — Python SDK

Feature flags for Indie Flags. is_enabled, get_value, optional 60s cache. Python 3.9+, stdlib only (no extra dependencies).

Install

pip install indie-flags

Get your API key

In the Indie Flags dashboard, open your project → API Keys. Copy the client key (if_pub_...).

Usage

Init (recommended)

from indie_flags import IndieFlags

flags = IndieFlags(
    api_key="if_pub_xxxxxxxx",
    # base_url="https://your-api.com",  # optional, self-hosted
    # email="user@example.com",          # optional, for overrides
)
flags.init()

if flags.is_enabled("new-checkout"):
    # show new checkout
else:
    # show old checkout

theme = flags.get_value("theme")  # "dark" | "light" | "system"

Without init

flags = IndieFlags(api_key="if_pub_xxxxxxxx")
on = flags.is_enabled("new-feature")
value = flags.get_value("ab-test-variant")

Options

Option Type Description
api_key str Required. Project API key from dashboard.
base_url str API base URL. Default https://api.indieflags.dev.
env str Environment (e.g. "production", "staging").
email str User email for flag overrides.
cache_ttl_sec int Cache TTL after init(). Default 60. Set 0 to disable.

Methods

  • init() — Fetch all flags and cache. Call once at startup.
  • is_enabled(flag_key: str) -> bool — Whether the flag is on.
  • get_value(flag_key: str) -> bool | str — Flag value (bool or str for enums).
  • invalidate_cache() — Clear cache.

API

Uses GET /eval and GET /eval/flags. See the REST API docs for direct HTTP usage.

Tests

pip install -e ".[dev]"
pytest tests/ -v

Publishing to PyPI (maintainers)

  1. Create an API token on PyPI
    pypi.org → Account settings → API tokens → Add API token (scope: “Entire account” or limit to project indie-flags).

  2. Bump version in pyproject.toml (e.g. 0.1.00.1.1).

  3. Build and upload (from sdk-python/):

    python3 -m venv .venv && source .venv/bin/activate   # once
    pip install build twine
    python -m build
    twine upload dist/*
    

    On macOS/Homebrew, use a venv (as above); pip may not be available system-wide.

  4. When Twine asks for credentials:

    • Username: __token__
    • Password: your PyPI API token (starts with pypi-).

    Or set once and reuse:
    export TWINE_USERNAME=__token__ and export TWINE_PASSWORD=pypi-...

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

indie_flags-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

indie_flags-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file indie_flags-0.1.0.tar.gz.

File metadata

  • Download URL: indie_flags-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for indie_flags-0.1.0.tar.gz
Algorithm Hash digest
SHA256 81f194c5260b774f2d10a13db6ff674dc986c9eb49d4b357a0269232ddc94a0c
MD5 a9c7b9f0431381e32cc47b2224d88ae3
BLAKE2b-256 72aa5a3079fb582a15b501a24f57635b6542eac2d039cd924a1242dffc8a6a06

See more details on using hashes here.

File details

Details for the file indie_flags-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: indie_flags-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for indie_flags-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b02b3b747e71dd698fd5b5b711a9b3079c59a2185833512fa9630901938c66
MD5 9c1d5dea82dcf2f17713fbb38b91364e
BLAKE2b-256 5da478fe34d4b8afa43b766a35b5e2eeca53c78a762b823b5b0d0079c182ea39

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