The canarygate package is the official client for integrating CanaryGate into Python applications.
Compatibility
| Environment | Support |
|---|---|
| Python 3.9+ | Yes |
The SDK fetches flags via a snapshot request (/sdk/flags) and optionally keeps them in sync with the server through SSE streaming when stream is enabled.
Installation
pip install canarygateFull API
| Method | Description |
|---|---|
CanaryGate(api_key, Options) | Creates the client |
init() | Loads flags via snapshot; starts SSE when stream is enabled. Raises RuntimeError if the initial fetch fails |
get_flag(key, context) | Returns FlagData or None |
get_flags(context) | Returns list[FlagData] (all flags) |
is_stale() | True if the connection is degraded |
get_last_sync_at() | ISO str of the last sync or None |
disconnect() | Closes the stream connection (if any) and releases resources |
Next steps
Last updated on