Skip to main content

The official Amplitude Experiment Python SDK for server-side instrumentation.

Project description


PyPI version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amplitude-experiment-0.3.1.tar.gz (4.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amplitude_experiment-0.3.1-py3-none-any.whl (4.0 MB view details)

Uploaded Python 3

File details

Details for the file amplitude-experiment-0.3.1.tar.gz.

File metadata

  • Download URL: amplitude-experiment-0.3.1.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.7.15

File hashes

Hashes for amplitude-experiment-0.3.1.tar.gz
Algorithm Hash digest
SHA256 3886ea1f20249d56584adfa5512344613efea4951604f6a467ce16b5816a2df7
MD5 cc9ba77964794e0bf4c23b7d8b376334
BLAKE2b-256 012e9e2a55184678200ab1983c6f0391516218473d627d89c779a4a2ffe11db8

See more details on using hashes here.

File details

Details for the file amplitude_experiment-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: amplitude_experiment-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.3 requests/2.28.1 requests-toolbelt/0.10.1 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.11.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.7.15

File hashes

Hashes for amplitude_experiment-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 86c2c202db435fd98c5b2da8471e4a8258979115fb898040982bd6e1bf9bcf8d
MD5 3ad7ee5f41092afb02a4dbaaab2e4d38
BLAKE2b-256 976cfa0fa799de43e09efd67941da823033c93b758b4ec0db0ee91218f7f89d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page