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)
Running Unit Tests Suite
To setup for running test on local, create a .env file with following
contents, and replace {API_KEY} and {SECRET_KEY} (or {EU_API_KEY} and {EU_SECRET_KEY} for EU data center) for the project in test:
API_KEY={API_KEY}
SECRET_KEY={SECRET_KEY}
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
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 amplitude_experiment-1.10.1.tar.gz.
File metadata
- Download URL: amplitude_experiment-1.10.1.tar.gz
- Upload date:
- Size: 87.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/43.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.67.1 importlib-metadata/8.5.0 keyring/25.5.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e16290a3f7ffa7b1a88cd68d343e86df43bea48e294a3a6dc2a413f77736ce08
|
|
| MD5 |
eb050e06e276a31f6e741cd668c6cb2c
|
|
| BLAKE2b-256 |
a882ffabda3055632dbf76b527497543aaf4386a327abf8804722c933b965677
|
File details
Details for the file amplitude_experiment-1.10.1-py3-none-any.whl.
File metadata
- Download URL: amplitude_experiment-1.10.1-py3-none-any.whl
- Upload date:
- Size: 126.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/43.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.67.1 importlib-metadata/8.5.0 keyring/25.5.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1191bf3a14a64a2c5e34ea6d04b56a18d669b7b93f63f53f790f87f2c27b6c7a
|
|
| MD5 |
6577d14ba3771cb0e4d61599a2aa9d5b
|
|
| BLAKE2b-256 |
60afb02bbaa03d4ce4023c4347808467f571c1a7d305d032734a7d5b83c604ed
|