Python
Installation
Install the tggl
package:
pip install tggl
Quick start
Start by creating a client using your API key and use it to evaluate contexts:
from tggl import TgglClient
client = TgglClient('<Your API key>')
flags = client.eval_context({
'user_id': 123,
'email': 'foo@gmail.com',
'plan': 'PRO'
})
You can then check flag results:
# On/Off flags
if (flags.get('feature_1', true)):
print('Feature 1 is active')
# A/B tests
if (flags.get('feature_2', 'Variation A') == 'Variation A'):
print('Should display variation A to user')
A single API call evaluating all flags is performed when calling
eval_context
,
making all subsequent flag checking methods extremely fast.
This means that you do not need to cache results of the get
method since
it does not trigger an API call, it simply looks up the data in the already fetched response.