GoGreen feature flag and experimentation SDK for Python
Project description
GoGreen Python SDK
Official Python SDK for GoGreen feature flags and experimentation.
Requirements
- Python 3.10+
- GoGreen evaluation API (e.g.
https://eval.gogreenflags.com)
Installation
From PyPI (when published)
pip install gogreen-sdk
From source (GitHub)
pip install git+https://github.com/MarkDurbin104/GoGreen.git#subdirectory=sdk/python
Or clone and install in editable mode:
git clone https://github.com/MarkDurbin104/GoGreen.git
cd GoGreen/sdk/python
pip install -e .
Quick start
from gogreen import GoGreenClient
from gogreen.config import GoGreenConfig
config = GoGreenConfig(
sdk_key="YOUR_SDK_KEY",
environment_id="YOUR_ENV_ID",
default_context={"key": "user-123", "custom": {"plan": "enterprise"}},
api_base_url="https://eval.gogreenflags.com",
)
client = GoGreenClient(config)
client.wait_for_initialization(timeout=5.0)
# Boolean flag
if client.bool_variation("new-checkout", False):
show_new_checkout()
# With optional context override
user = {"key": "user-456", "custom": {"country": "US"}}
theme = client.string_variation("ui-theme", "light", context=user)
# Number flag (e.g. for gradual rollouts)
limit = client.number_variation("rate-limit", 100)
# JSON flag
config_value = client.json_variation("feature-config", {})
# Detail (value + variation id, reason, prerequisite_key)
detail = client.bool_variation_detail("new-checkout", False)
print(detail.value, detail.reason, detail.variation_id)
# Track custom events for experimentation
client.track("checkout_completed", {"revenue": 49.99})
client.close()
API reference
GoGreenConfig
| Parameter | Type | Required | Description |
|---|---|---|---|
sdk_key |
str | Yes | SDK key from your GoGreen environment |
environment_id |
str | Yes | Environment ID (e.g. UUID) |
default_context |
dict | Yes | Default evaluation context; must include "key" |
api_base_url |
str | No | Evaluation API base URL (default: http://localhost:8092) |
stream_url |
str | No | Streaming SSE URL (default: same as api_base_url) |
events_url |
str | No | Events ingestion URL (default: same as api_base_url) |
enable_streaming |
bool | No | Enable real-time flag updates via SSE (default: True) |
offline |
bool | No | Start in offline mode (default: False) |
bootstrap |
dict | No | Initial flags {"flags": {flag_key: result}} to skip first fetch |
request_timeout |
float | No | HTTP timeout in seconds (default: 10.0) |
flush_interval |
float | No | Event batch flush interval in seconds (default: 30.0) |
private_attributes |
list[str] | No | Attribute names to redact in events (PII) |
GoGreenClient
- Variations:
bool_variation,string_variation,number_variation,json_variation
Each has a*_variation_detailvariant returningEvaluationDetail(value, variation_id, reason, rule_index, prerequisite_key). - Lifecycle:
wait_for_initialization(timeout=None),initialized(),close() - Context:
set_context(context),identify(context) - Offline:
enter_offline_mode(),exit_offline_mode() - Events:
on(event, handler)/off(event, handler)for"ready","update","error";track(event_key, properties=None) - All flags:
all_flags()→dict[str, Any] - Test helper:
GoGreenClient.test_client(flags: dict)for unit tests (offline client with fixed flag values).
OpenFeature provider
from gogreen import GoGreenClient, GoGreenProvider
from gogreen.config import GoGreenConfig
from openfeature import api
config = GoGreenConfig(
sdk_key="YOUR_SDK_KEY",
environment_id="YOUR_ENV_ID",
default_context={"key": "user-123", "custom": {}},
)
client = GoGreenClient(config)
api.set_provider(GoGreenProvider(client))
client = api.get_client()
value = client.get_boolean_value("my-flag", False)
Development
pip install -e ".[dev]"
ruff check src tests && ruff format src tests
pytest tests/ -v --cov=src/gogreen --cov-report=term-missing --cov-fail-under=80
Publishing (PyPI)
Releases are built and published via GitHub Actions when a tag sdk/python/vX.Y.Z is pushed. PyPI Trusted Publishing (OIDC) must be configured once on the PyPI project. See the workflow file .github/workflows/sdk-python.yml for setup steps.
License
ISC
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gogreen_sdk-1.0.1.tar.gz.
File metadata
- Download URL: gogreen_sdk-1.0.1.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fa095982781af9f171addbd72da902fb03d5b294a8054ead8703d3a2d4219ff
|
|
| MD5 |
44e8c2f044a2c19cd84313ce3c21a7e0
|
|
| BLAKE2b-256 |
7a722219d6110ba2a01aefc8aacc9e465240ae43bbf5bed8dc1886380807f00d
|
Provenance
The following attestation bundles were made for gogreen_sdk-1.0.1.tar.gz:
Publisher:
sdk-python.yml on MarkDurbin104/GoGreen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gogreen_sdk-1.0.1.tar.gz -
Subject digest:
4fa095982781af9f171addbd72da902fb03d5b294a8054ead8703d3a2d4219ff - Sigstore transparency entry: 1188735788
- Sigstore integration time:
-
Permalink:
MarkDurbin104/GoGreen@16b99a967c4d8180445ee0f6a7ca9648d619dd3d -
Branch / Tag:
refs/tags/sdk/python/v1.0.1 - Owner: https://github.com/MarkDurbin104
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python.yml@16b99a967c4d8180445ee0f6a7ca9648d619dd3d -
Trigger Event:
push
-
Statement type:
File details
Details for the file gogreen_sdk-1.0.1-py3-none-any.whl.
File metadata
- Download URL: gogreen_sdk-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a0bb5782a0280fb4a4949f000d49b31838bd7b06a590217fd43cb4e6f2d7adc
|
|
| MD5 |
c6f459a940979bac0844f76594fdd571
|
|
| BLAKE2b-256 |
1cd00a8feb2f003f9bb2560f7e4f9a0acc9d85b9d6647364da975fe3e2eccc4f
|
Provenance
The following attestation bundles were made for gogreen_sdk-1.0.1-py3-none-any.whl:
Publisher:
sdk-python.yml on MarkDurbin104/GoGreen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gogreen_sdk-1.0.1-py3-none-any.whl -
Subject digest:
0a0bb5782a0280fb4a4949f000d49b31838bd7b06a590217fd43cb4e6f2d7adc - Sigstore transparency entry: 1188735790
- Sigstore integration time:
-
Permalink:
MarkDurbin104/GoGreen@16b99a967c4d8180445ee0f6a7ca9648d619dd3d -
Branch / Tag:
refs/tags/sdk/python/v1.0.1 - Owner: https://github.com/MarkDurbin104
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python.yml@16b99a967c4d8180445ee0f6a7ca9648d619dd3d -
Trigger Event:
push
-
Statement type: