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.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc3b57fc740728984f0e4296145c5ee1331f1ce394409d9027d9b6a03f62f89a |
|
MD5 | 725af25182123edf557d73362314b5e4 |
|
BLAKE2b-256 | 7c207dbb55d8713066219a7afa53ea549f0876bb91ac3956c1a8d2c9ab3559af |
Close
Hashes for amplitude_experiment-1.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 607f02ce5ab64c16edb9adcc98dc48055a638079ae68fcbb37e7003ea3577564 |
|
MD5 | a3d36c894daed2ed99333a327f1fa7d5 |
|
BLAKE2b-256 | 83d08c8fd0dd497c9423120fffe477d105f687d57c523b06dfd2e27c39903297 |