python wrapper for using the amplitude analytics and taxonomy APIs
Project description
Amplitude data wrapper
This is a wrapper for Amplitude APIs. You can use it to query and export data from your account and use the taxonomy API.
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
# without proxy
r = amp.get_chart(
api_key=api_key, secret=api_secret, chart_id=chart_id_eu, region=1
) # region 1 is EU
r.status_code
r.json() # returns data as json
Get data from US account by setting region=2
.
r = amp.get_chart(
api_key=api_key, secret=api_secret, chart_id=chart_id_eu, region=2
) # region 2 is USA
r.json() # returns data as json
Get data from EU account with a proxy by setting region and proxy using a dictionary.
# with proxy
proxies = {"http": "http://myproxy.example.org/method"}
r = amp.get_chart(api_key, api_secret, chart_id_eu, region=1, proxy=proxies)
r.status_code # print status code
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,
)
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
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
types = amp.get_all_event_types(
api_key=api_key,
secret=api_secret,
region=1)
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
File details
Details for the file amplitude_data_wrapper-0.5.0.tar.gz
.
File metadata
- Download URL: amplitude_data_wrapper-0.5.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe0b23e7f3f5661499afe5de0affdde67d41bc5356703d374a99983e34cba3d9 |
|
MD5 | e1a1d02cd59c0322a897c98bdecb6d91 |
|
BLAKE2b-256 | 7058bc04a7a511fdc2178b08c884d856bccd854dc730327acb3d94b038afcd49 |
File details
Details for the file amplitude_data_wrapper-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: amplitude_data_wrapper-0.5.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b4540ca57ffe3d6183709ada77cf9e55fd32dc7909ba66338d0d51d62dabf46 |
|
MD5 | f3d6452499444d47f38962ec963ba21e |
|
BLAKE2b-256 | 807c246f0333630c500783b243ce3cc7c9f62e3d4397f227a289b5ced8ddbe60 |