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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c710141177ccfb31dbeb8a69e206ad3d47b742b498783948b76dffd63a4d61e4 |
|
MD5 | 76cd7c566dc9501c437c64ad95a6cc2f |
|
BLAKE2b-256 | dd8d2a0aaea97104b92b17b277f2958901958817ba9a15f0e33f64ccdf258d65 |
Close
Hashes for amplitude_experiment-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bacb4952fe7cf54804455d7c3b8564f4b48681d7a17621189efcae153f2678f |
|
MD5 | ddb3225877ae142a16c2a39d2c9f21dd |
|
BLAKE2b-256 | 208bd57af467743ef7ff26ac95482e49e96e311caab8ed5f5a28dbfdac68a779 |