Skip to main content

Official FeatureHub Python SDK.

Overview

To control the feature flags from the FeatureHub Admin console, either use our demo version for evaluation or install the app using our guide here

Versions 3.7+ of Python are supported.

SDK installation

pip install featurehub-sdk

Options to get feature updates

There are 2 ways to request for feature updates via this SDK:

  • SSE (Server Sent Events) realtime updates mechanism

    In this mode, you will make a connection to the FeatureHub Edge server using the EventSource (based on urllib3's sseclient-py), and any updates to any features will come through in near realtime, automatically updating the feature values in the repository. This method is recommended for server applications.

  • FeatureHub polling client (GET request updates)

    In this mode you can set an interval (from 0 - just once) to any number of seconds between polling. This is more useful for when you have short term single threaded processes like command line tools. Batch tools that iterate over data sets and wish to control when updates happen can also benefit from this method.

Example

Check our example Flask app here

Quick start

Connecting to FeatureHub

There are 3 steps to connecting:

  1. Copy FeatureHub API Key from the FeatureHub Admin Console
  2. Create FeatureHub config
  3. Check FeatureHub Repository readiness and request feature state

1. API Key from the FeatureHub Admin Console

Find and copy your API Key from the FeatureHub Admin Console on the API Keys page - you will use this in your code to configure feature updates for your environments. It should look similar to this: default/71ed3c04-122b-4312-9ea8-06b2b8d6ceac/fsTmCrcZZoGyl56kPHxfKAkbHrJ7xZMKO3dlBiab5IqUXjgKvqpjxYdI8zdXiJqYCpv92Jrki0jY5taE. There are two options - a Server Evaluated API Key and a Client Evaluated API Key. More on this here

Client Side evaluation is intended for use in secure environments (such as microservices) and is intended for rapid client side evaluation, per request for example.

Server Side evaluation is more suitable when you are using an insecure client. (e.g. command line tool). This also means you evaluate one user per client.

2. Create FeatureHub config:

Create FeatureHubConfig. You need to provide the API Key and the URL of the FeatureHub Edge server.

from featurehub_sdk.featurehub_config import FeatureHubConfig

edge_url = 'http://localhost:8085/'
client_eval_key = 'default/3f7a1a34-642b-4054-a82f-1ca2d14633ed/aH0l9TDXzauYq6rKQzVUPwbzmzGRqe*oPqyYqhUlVC50RxAzSmx'

config = FeatureHubConfig(edge_url, [client_eval_key])
asyncio.run(config.init()) # run async command in sync

By default, this SDK will use SSE client. If you decide to use FeatureHub polling client, after initialising the config, you can add this:

config.use_polling_edge_service(30)
# OR
config.use_polling_edge_service() # uses environment variable FEATUREHUB_POLL_INTERVAL or default of 30 

in this case it is configured for requesting an update every 30 seconds.

3. Check FeatureHub Repository readiness and request feature state

Check for FeatureHub Repository readiness:

 if config.repository().is_ready():
    # do something

If you are not intending to use rollout strategies, you can pass empty context to the SDK:

Synchronous function:

    def name_arg(name):
        if config.new_context().build_sync().feature('FEATURE_TITLE_TO_UPPERCASE').get_flag:
            return "HELLO WORLD"
        else:
            return "hello world"

Asynchronous function:

async def async_name_arg(name):
        ctx = await config.new_context().build()
        if ctx.feature('FEATURE_TITLE_TO_UPPERCASE').get_flag:
            return "HELLO WORLD"
        else:
            return "hello world"

If you are using rollout strategies and targeting rules they are all determined by the active user context. In this example we pass user_key to the context :

Synchronous function:

    def name_arg(name):
        if config.new_context().user_key(name).build_sync().feature('FEATURE_TITLE_TO_UPPERCASE').get_flag:
            return "HELLO WORLD"
        else:
            return "hello world"

Asynchronous function:

async def async_name_arg(name):
        ctx = await config.new_context().user_key(name).build()
        if ctx.feature('FEATURE_TITLE_TO_UPPERCASE').get_flag:
            return "HELLO WORLD"
        else:
            return "hello world"

See more options to request feature states here

Metadata

Release files for featurehub-sdk 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 featurehub-sdk 1.1.0
File Size Uploaded
featurehub_sdk-1.1.0.tar.gz 19.8 kB Details

Built distribution (wheel)

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

Total release size: 41.7 kB

Release files / featurehub_sdk-1.1.0.tar.gz

Download URL featurehub_sdk-1.1.0.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
470b7b1baae7e7fd49307632e97b65e9c3f745c6440523df3928f5b69f844935
BLAKE2b-256 checksum
How to use checksums
6d266a6a6bff4384b18cb7a366ec9be1240fceb8e3f6f27b314418c2952232a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 7, 2026.

Transparency log

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

Download URL featurehub_sdk-1.1.0-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c2ab220489bf3c2d9df2a5e3a9c5a989408f11d7b23de37ec4d6d2cd6e5cbfb
BLAKE2b-256 checksum
How to use checksums
1abe1cc7d191ece6899fc4b39101d151711479e5205e5dfd821153f1b98c42ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

1 release file

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