amplitude-data-wrapper


Nameamplitude-data-wrapper JSON
Version 0.4.5 PyPI version JSON
download
home_page
Summarypython wrapper for using the amplitude analytics and taxonomy APIs
upload_time2023-06-21 20:58:11
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) 2022 NAV IT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords amplitude
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Amplitude data wrapper

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

This is a wrapper for [Amplitude](https://amplitude.com/) APIs. You can use it to query and export data from your account and use the taxonomy API.

Built with [requests](https://requests.readthedocs.io/en/latest/) and [tqdm](https://github.com/tqdm/tqdm)

**Why use this package instead of other wrappers?**

This package supports regions and so you can use it with Amplitude accounts in the EU and USA.

This package also supports using a proxy so you can keep your project API keys and API secrets confidential.

## Supported Amplitude APIs and docs

- [Amplitude data wrapper](#amplitude-data-wrapper)
  - [Supported Amplitude APIs and docs](#supported-amplitude-apis-and-docs)
    - [Dashboard Rest API](#dashboard-rest-api)
    - [Privacy API](#privacy-api)
    - [Cohort API](#cohort-api)
    - [Export API](#export-api)
    - [Taxonomy API](#taxonomy-api)

See examples below and in [example.py](example.py)

Install with

```
pip install amplitude-data-wrapper
```

### Dashboard Rest API

[Results from an existing chart](https://developers.amplitude.com/docs/dashboard-rest-api#results-from-an-existing-chart)

Get data from EU account by setting `region=1`.

```python
import amplitude_data_wrapper.analytics_api as amp

r = amp.get_chart(chart_id, api_key, api_secret, region=1)
r.status_code  # 200
r.text # print data
```

Get data from US account by setting `region=2`.

```python

r = amp.get_chart(chart_id, api_key, api_secret, region=2)
r.status_code  # 200
r.text # print data
```

Get data from EU account with a proxy by setting region and proxy using a dictionary.

```python

proxies = {"http": "http://myproxy.domain.org/path"}
r = amp.get_chart(chart_id, api_key, api_secret, region=1, proxy=proxies)
r.status_code  # 200
r.text # print data
```

[Event segmentation](https://developers.amplitude.com/docs/dashboard-rest-api#event-segmentation) lets you export events with segments and filters.

```python
our_event_dict = {
    "event_type": "pageview",
    "group_by": [{"type": "event", "value": "app"}, {"type": "event", "value": "team"}],
}
data = amp.get_event_segmentation(
    api_key=api_key,
    secret=api_secret,
    start="20220601",
    end="20220602",
    event=our_event_dict,
    metrics="uniques",
    interval=1,
    limit=1000,
)
```

[User search](https://developers.amplitude.com/docs/dashboard-rest-api#user-search) lets you search for a user with a specific Amplitude ID, Device ID, User ID, or User ID prefix.

```python
user = amp.find_user(
    user=example_id_eu, 
    api_key=api_key, 
    secret=api_secret,
    region=1)
```

### Privacy API

Delete user data with a [deletion job](https://developers.amplitude.com/docs/user-deletion#deletion-job)

```python
deleteme = amp.delete_user_data(
    user["matches"][0]["amplitude_id"],
    email=email,
    api_key=api_key,
    secret=api_secret,
    region=1,
    ignore_invalid_id=True,
    delete_from_org=False,
)
```

[Get a list of deletion jobs](https://developers.amplitude.com/docs/user-deletion#get)

```python
tobe_deleted = amp.get_deletion_jobs(
    start="2022-06-01",
    end="2022-07-01",
    api_key=api_key,
    secret=api_secret,
    region=1,
)
```

### Cohort API

[Getting one cohort](https://developers.amplitude.com/docs/behavioral-cohorts-api#getting-one-cohort)

```python
proxies = {"http": "http://myproxy.domain.org/path"}
file_path = "path-to/cohortdata.csv"
kull = amp.get_cohort(
    api_key,
    api_secret,
    cohort_id,
    filename=file_path,
    props=1,
    region=1,
    proxy=proxies,
)
```

### Export API

[Export API - Export your project's event data](https://developers.amplitude.com/docs/export-api#export-api---export-your-projects-event-data)

```python
start = "20220601T00"
end = "20220601T01"
data = amp.export_project_data(
    start=start,
    end=end,
    api_key=api_key,
    secret=api_secret,
    filename="path-to/projectdata_eu.zip",
    region=1,
)
```

### Taxonomy API

[Get all event types](https://developers.amplitude.com/docs/taxonomy-api#get-all-event-types)

```python
types = amp.get_all_event_types(
    api_key=api_key, 
    secret=api_secret, 
    region=1)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "amplitude-data-wrapper",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "amplitude",
    "author": "",
    "author_email": "Tobias McVey <tobias.mcvey@nav.no>",
    "download_url": "https://files.pythonhosted.org/packages/4e/7a/de33f0a6e9659d0bf880c610abbaaa5cbbee717cf47772f0c5f5981c9adb/amplitude-data-wrapper-0.4.5.tar.gz",
    "platform": null,
    "description": "# Amplitude data wrapper\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nThis is a wrapper for [Amplitude](https://amplitude.com/) APIs. You can use it to query and export data from your account and use the taxonomy API.\n\nBuilt with [requests](https://requests.readthedocs.io/en/latest/) and [tqdm](https://github.com/tqdm/tqdm)\n\n**Why use this package instead of other wrappers?**\n\nThis package supports regions and so you can use it with Amplitude accounts in the EU and USA.\n\nThis package also supports using a proxy so you can keep your project API keys and API secrets confidential.\n\n## Supported Amplitude APIs and docs\n\n- [Amplitude data wrapper](#amplitude-data-wrapper)\n  - [Supported Amplitude APIs and docs](#supported-amplitude-apis-and-docs)\n    - [Dashboard Rest API](#dashboard-rest-api)\n    - [Privacy API](#privacy-api)\n    - [Cohort API](#cohort-api)\n    - [Export API](#export-api)\n    - [Taxonomy API](#taxonomy-api)\n\nSee examples below and in [example.py](example.py)\n\nInstall with\n\n```\npip install amplitude-data-wrapper\n```\n\n### Dashboard Rest API\n\n[Results from an existing chart](https://developers.amplitude.com/docs/dashboard-rest-api#results-from-an-existing-chart)\n\nGet data from EU account by setting `region=1`.\n\n```python\nimport amplitude_data_wrapper.analytics_api as amp\n\nr = amp.get_chart(chart_id, api_key, api_secret, region=1)\nr.status_code  # 200\nr.text # print data\n```\n\nGet data from US account by setting `region=2`.\n\n```python\n\nr = amp.get_chart(chart_id, api_key, api_secret, region=2)\nr.status_code  # 200\nr.text # print data\n```\n\nGet data from EU account with a proxy by setting region and proxy using a dictionary.\n\n```python\n\nproxies = {\"http\": \"http://myproxy.domain.org/path\"}\nr = amp.get_chart(chart_id, api_key, api_secret, region=1, proxy=proxies)\nr.status_code  # 200\nr.text # print data\n```\n\n[Event segmentation](https://developers.amplitude.com/docs/dashboard-rest-api#event-segmentation) lets you export events with segments and filters.\n\n```python\nour_event_dict = {\n    \"event_type\": \"pageview\",\n    \"group_by\": [{\"type\": \"event\", \"value\": \"app\"}, {\"type\": \"event\", \"value\": \"team\"}],\n}\ndata = amp.get_event_segmentation(\n    api_key=api_key,\n    secret=api_secret,\n    start=\"20220601\",\n    end=\"20220602\",\n    event=our_event_dict,\n    metrics=\"uniques\",\n    interval=1,\n    limit=1000,\n)\n```\n\n[User search](https://developers.amplitude.com/docs/dashboard-rest-api#user-search) lets you search for a user with a specific Amplitude ID, Device ID, User ID, or User ID prefix.\n\n```python\nuser = amp.find_user(\n    user=example_id_eu, \n    api_key=api_key, \n    secret=api_secret,\n    region=1)\n```\n\n### Privacy API\n\nDelete user data with a [deletion job](https://developers.amplitude.com/docs/user-deletion#deletion-job)\n\n```python\ndeleteme = amp.delete_user_data(\n    user[\"matches\"][0][\"amplitude_id\"],\n    email=email,\n    api_key=api_key,\n    secret=api_secret,\n    region=1,\n    ignore_invalid_id=True,\n    delete_from_org=False,\n)\n```\n\n[Get a list of deletion jobs](https://developers.amplitude.com/docs/user-deletion#get)\n\n```python\ntobe_deleted = amp.get_deletion_jobs(\n    start=\"2022-06-01\",\n    end=\"2022-07-01\",\n    api_key=api_key,\n    secret=api_secret,\n    region=1,\n)\n```\n\n### Cohort API\n\n[Getting one cohort](https://developers.amplitude.com/docs/behavioral-cohorts-api#getting-one-cohort)\n\n```python\nproxies = {\"http\": \"http://myproxy.domain.org/path\"}\nfile_path = \"path-to/cohortdata.csv\"\nkull = amp.get_cohort(\n    api_key,\n    api_secret,\n    cohort_id,\n    filename=file_path,\n    props=1,\n    region=1,\n    proxy=proxies,\n)\n```\n\n### Export API\n\n[Export API - Export your project's event data](https://developers.amplitude.com/docs/export-api#export-api---export-your-projects-event-data)\n\n```python\nstart = \"20220601T00\"\nend = \"20220601T01\"\ndata = amp.export_project_data(\n    start=start,\n    end=end,\n    api_key=api_key,\n    secret=api_secret,\n    filename=\"path-to/projectdata_eu.zip\",\n    region=1,\n)\n```\n\n### Taxonomy API\n\n[Get all event types](https://developers.amplitude.com/docs/taxonomy-api#get-all-event-types)\n\n```python\ntypes = amp.get_all_event_types(\n    api_key=api_key, \n    secret=api_secret, \n    region=1)\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 NAV IT  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "python wrapper for using the amplitude analytics and taxonomy APIs",
    "version": "0.4.5",
    "project_urls": {
        "Homepage": "https://github.com/navikt/amplitude-data-wrapper"
    },
    "split_keywords": [
        "amplitude"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09a113e9e3b8713ec70c9bd8b3313816e700f3e4e48f533d196d618b0ac973b3",
                "md5": "8d095465ce56da84c2ff386065ce482c",
                "sha256": "92290b547f74606cdaf4a2deaaa27c4e0900a737b7115dd2e2d023b6830f540a"
            },
            "downloads": -1,
            "filename": "amplitude_data_wrapper-0.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d095465ce56da84c2ff386065ce482c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7955,
            "upload_time": "2023-06-21T20:58:10",
            "upload_time_iso_8601": "2023-06-21T20:58:10.186104Z",
            "url": "https://files.pythonhosted.org/packages/09/a1/13e9e3b8713ec70c9bd8b3313816e700f3e4e48f533d196d618b0ac973b3/amplitude_data_wrapper-0.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e7ade33f0a6e9659d0bf880c610abbaaa5cbbee717cf47772f0c5f5981c9adb",
                "md5": "0c0a7e5ae230020ba27422855e3f8515",
                "sha256": "d12f9d27272141cf686f39a3a0d4598c2e61561fb835e9a9bd7e949f597468d3"
            },
            "downloads": -1,
            "filename": "amplitude-data-wrapper-0.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "0c0a7e5ae230020ba27422855e3f8515",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 10873,
            "upload_time": "2023-06-21T20:58:11",
            "upload_time_iso_8601": "2023-06-21T20:58:11.609072Z",
            "url": "https://files.pythonhosted.org/packages/4e/7a/de33f0a6e9659d0bf880c610abbaaa5cbbee717cf47772f0c5f5981c9adb/amplitude-data-wrapper-0.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-21 20:58:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "navikt",
    "github_project": "amplitude-data-wrapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "amplitude-data-wrapper"
}
        
Elapsed time: 0.08531s