Python quickstart
Wire the Python SDK into your app and see your first flag fetch.
Wire the Python SDK into your app in three steps. This assumes you've already
created a flag and copied a development SDK key — if not, start with the
Quickstart.
1. Install
pip install switchbox-flags
The package is switchbox-flags; you import it as switchbox. It has zero
runtime dependencies — nothing else is pulled in.
2. Create a client
Create one client when your app starts and reuse it. It fetches your config once on creation, then refreshes it in the background every 30 seconds.
from switchbox import Switchboxclient = Switchbox(sdk_key="your-sdk-key-from-dashboard")
3. Check a flag
if client.enabled("new_checkout", user={"user_id": "42"}):show_new_checkout()else:show_old_checkout()
enabled() is an in-memory lookup against the cached config — no network call,
sub-millisecond. The user dict is optional; pass it when a flag uses targeting
rules or a percentage rollout (the user_id drives deterministic bucketing).
On shutdown, stop the background poller:
client.close()
Or use the context manager, which closes for you:
with Switchbox(sdk_key="your-sdk-key-from-dashboard") as client:if client.enabled("new_checkout", user={"user_id": "42"}):show_new_checkout()
See it connect
Run your app. Within a few seconds, the development environment in the
dashboard shows a Connected ✓ badge — that's your client successfully
fetching its config from the edge.
Now flip the flag off in the dashboard and Save. Your app picks up the change on its next poll (within ~30 seconds), with no redeploy.
Where to next
- Python SDK reference — every method and option.
- Targeting rules — turn a flag on for specific users.
- Percentage rollouts — release to a fraction of users.