Skip to main content

python wrapper for using the amplitude analytics and taxonomy APIs

Project description

Amplitude data wrapper

Code style: black

This is a wrapper for Amplitude APIs. You can use it to query and export data from your account and use the taxonomy API.

Built with requests and 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

See examples below and in example.py

Install with

pip install amplitude-data-wrapper

Dashboard Rest API

Results from an existing chart

Get data from EU account by setting region=1.

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.

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.

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 lets you export events with segments and filters.

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 lets you search for a user with a specific Amplitude ID, Device ID, User ID, or User ID prefix.

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

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

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

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

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

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

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-data-wrapper-0.4.5.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

amplitude_data_wrapper-0.4.5-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

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