The official Amplitude Experiment Python SDK for server-side instrumentation.
Project description
Experiment Python SDK
Amplitude Python Server SDK for Experiment.
Installation
pip install amplitude-experiment
Remote Evaluation Quick Start
from amplitude_experiment import Experiment, RemoteEvaluationConfig, RemoteEvaluationClient, User
# (1) Get your deployment's API key
apiKey = 'YOUR-API-KEY'
# (2) Initialize the experiment remote evaluation
experiment = Experiment.initialize_remote(api_key)
# (3) Fetch variants for a user
user = User(
device_id="abcdefg",
user_id="user@company.com",
user_properties={
'premium': True
}
)
# (4) Lookup a flag's variant
#
# To fetch synchronous
variants = experiment.fetch(user)
variant = variants['YOUR-FLAG-KEY']
if variant:
if variant.value == 'on':
# Flag is on
else:
# Flag is off
# To fetch asynchronous
experiment.fetch_async(user, fetch_callback)
def fetch_callback(user, variants):
variant = variants['YOUR-FLAG-KEY']
if variant:
if variant.value == 'on':
# Flag is on
else:
# Flag is off
Local Evaluation Quick Start
# (1) Initialize the local evaluation client with a server deployment key.
experiment = Experiment.initialize_local(api_key)
# (2) Start the local evaluation client.
experiment.start()
# (3) Evaluate a user.
user = User(
device_id="abcdefg",
user_id="user@company.com",
user_properties={
'premium': True
}
)
variants = experiment.evaluate(user)
More Information
Please visit our :100:Developer Center for more instructions on using our the SDK.
See our Experiment Python SDK Docs for a list and description of all available SDK methods.
Need Help?
If you have any problems or issues over our SDK, feel free to create a github issue or submit a request on Amplitude Help.
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
Close
Hashes for amplitude-experiment-1.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc7b24db3bd38537fdf874718fd8aa9f0831c34b832a781b221a126cc4121a6a |
|
MD5 | 9b043306d63765d209bf9468d00038de |
|
BLAKE2b-256 | 4fc3e5d2550eba1a480ea9117c7d518f1429a47df43711ba22fdb750e5a041b7 |
Close
Hashes for amplitude_experiment-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a874d82748193395a158c7975bcc238875f153ee8bd0ae5fe259fe78a93890ca |
|
MD5 | e351547b53382b194d52639cf6549886 |
|
BLAKE2b-256 | 0513a2eaf593112736e218ad6fdc249b72921c2a6f40add9375d40487c5cdd87 |