<p align="center">
<a href="https://amplitude.com" target="_blank" align="center">
<img src="https://static.amplitude.com/lightning/46c85bfd91905de8047f1ee65c7c93d6fa9ee6ea/static/media/amplitude-logo-with-text.4fb9e463.svg" width="280">
</a>
<br />
</p>
[![PyPI version](https://badge.fury.io/py/amplitude-experiment.svg)](https://badge.fury.io/py/amplitude-experiment)
# Experiment Python SDK
Amplitude Python Server SDK for Experiment.
## Installation
```python
pip install amplitude-experiment
```
## Remote Evaluation Quick Start
```python
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
```python
# (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](https://www.docs.developers.amplitude.com/experiment/sdks/python-sdk/) for more instructions on using our the SDK.
See our [Experiment Python SDK Docs](https://amplitude.github.io/experiment-python-server/) 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](https://github.com/amplitude/experiments-python-server/issues/new) or submit a request on [Amplitude Help](https://help.amplitude.com/hc/en-us/requests/new).
Raw data
{
"_id": null,
"home_page": "https://github.com/amplitude/experiment-python-server",
"name": "amplitude-experiment",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6, <4",
"maintainer_email": "",
"keywords": "amplitude,python,backend",
"author": "Amplitude Inc.",
"author_email": "sdk.dev@amplitude.com",
"download_url": "https://files.pythonhosted.org/packages/7c/20/7dbb55d8713066219a7afa53ea549f0876bb91ac3956c1a8d2c9ab3559af/amplitude-experiment-1.3.1.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://amplitude.com\" target=\"_blank\" align=\"center\">\n <img src=\"https://static.amplitude.com/lightning/46c85bfd91905de8047f1ee65c7c93d6fa9ee6ea/static/media/amplitude-logo-with-text.4fb9e463.svg\" width=\"280\">\n </a>\n <br />\n</p>\n\n[![PyPI version](https://badge.fury.io/py/amplitude-experiment.svg)](https://badge.fury.io/py/amplitude-experiment)\n\n# Experiment Python SDK\nAmplitude Python Server SDK for Experiment.\n\n## Installation\n```python\npip install amplitude-experiment\n```\n\n## Remote Evaluation Quick Start\n```python\nfrom amplitude_experiment import Experiment, RemoteEvaluationConfig, RemoteEvaluationClient, User\n\n# (1) Get your deployment's API key\napiKey = 'YOUR-API-KEY'\n\n # (2) Initialize the experiment remote evaluation\nexperiment = Experiment.initialize_remote(api_key)\n\n# (3) Fetch variants for a user\nuser = User(\n device_id=\"abcdefg\",\n user_id=\"user@company.com\",\n user_properties={\n 'premium': True\n }\n)\n\n# (4) Lookup a flag's variant\n#\n# To fetch synchronous\nvariants = experiment.fetch(user)\nvariant = variants['YOUR-FLAG-KEY']\nif variant:\n if variant.value == 'on':\n # Flag is on\n else:\n # Flag is off\n\n# To fetch asynchronous\nexperiment.fetch_async(user, fetch_callback)\n\ndef fetch_callback(user, variants):\n variant = variants['YOUR-FLAG-KEY']\n if variant:\n if variant.value == 'on':\n # Flag is on\n else:\n # Flag is off\n\n```\n\n## Local Evaluation Quick Start\n```python\n# (1) Initialize the local evaluation client with a server deployment key.\nexperiment = Experiment.initialize_local(api_key)\n\n# (2) Start the local evaluation client.\nexperiment.start()\n\n# (3) Evaluate a user.\nuser = User(\n device_id=\"abcdefg\",\n user_id=\"user@company.com\",\n user_properties={\n 'premium': True\n }\n)\nvariants = experiment.evaluate(user)\n```\n\n## More Information\nPlease visit our :100:[Developer Center](https://www.docs.developers.amplitude.com/experiment/sdks/python-sdk/) for more instructions on using our the SDK.\n\nSee our [Experiment Python SDK Docs](https://amplitude.github.io/experiment-python-server/) for a list and description of all available SDK methods.\n\n## Need Help?\nIf you have any problems or issues over our SDK, feel free to [create a github issue](https://github.com/amplitude/experiments-python-server/issues/new) or submit a request on [Amplitude Help](https://help.amplitude.com/hc/en-us/requests/new).\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "The official Amplitude Experiment Python SDK for server-side instrumentation.",
"version": "1.3.1",
"project_urls": {
"Bug Reports": "https://github.com/amplitude/experiment-python-server/issues",
"Developer Doc": "https://www.docs.developers.amplitude.com/experiment/sdks/python-sdk/",
"Homepage": "https://github.com/amplitude/experiment-python-server",
"Source": "https://github.com/amplitude/experiment-python-server"
},
"split_keywords": [
"amplitude",
"python",
"backend"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "83d08c8fd0dd497c9423120fffe477d105f687d57c523b06dfd2e27c39903297",
"md5": "a3d36c894daed2ed99333a327f1fa7d5",
"sha256": "607f02ce5ab64c16edb9adcc98dc48055a638079ae68fcbb37e7003ea3577564"
},
"downloads": -1,
"filename": "amplitude_experiment-1.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a3d36c894daed2ed99333a327f1fa7d5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6, <4",
"size": 2696721,
"upload_time": "2024-01-30T22:20:10",
"upload_time_iso_8601": "2024-01-30T22:20:10.025545Z",
"url": "https://files.pythonhosted.org/packages/83/d0/8c8fd0dd497c9423120fffe477d105f687d57c523b06dfd2e27c39903297/amplitude_experiment-1.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7c207dbb55d8713066219a7afa53ea549f0876bb91ac3956c1a8d2c9ab3559af",
"md5": "725af25182123edf557d73362314b5e4",
"sha256": "dc3b57fc740728984f0e4296145c5ee1331f1ce394409d9027d9b6a03f62f89a"
},
"downloads": -1,
"filename": "amplitude-experiment-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "725af25182123edf557d73362314b5e4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6, <4",
"size": 2658578,
"upload_time": "2024-01-30T22:20:13",
"upload_time_iso_8601": "2024-01-30T22:20:13.099861Z",
"url": "https://files.pythonhosted.org/packages/7c/20/7dbb55d8713066219a7afa53ea549f0876bb91ac3956c1a8d2c9ab3559af/amplitude-experiment-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-30 22:20:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "amplitude",
"github_project": "experiment-python-server",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "amplitude-experiment"
}