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.
Built with requests, aiohttp 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
or
uv add amplitude-data-wrapper
Dashboard Rest API
Results from an existing chart
Get data from EU account by setting region="eu".
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="eu"
)
r.status_code
r.json() # returns data as json
Get data from US account by setting region="us".
r = amp.get_chart(
api_key=api_key, secret=api_secret, chart_id=chart_id_us, region="us"
)
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="eu", 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="eu")
Async chart downloads
You can also download chart data asynchronously. This is more efficient when downloading lots of charts at once. See example-async.py for an example program.
PS! Since this uses asyncio I recommend running asynchronous requests as a separate program, not from a jupyter notebook.
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="eu",
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="eu",
)
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="eu",
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="eu",
)
Taxonomy API
types = amp.get_all_event_types(
api_key=api_key,
secret=api_secret,
region="eu")
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file amplitude_data_wrapper-0.6.2.tar.gz.
File metadata
- Download URL: amplitude_data_wrapper-0.6.2.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35a5e228ee7d391342b80e37f0f9878c2b4c8287ab8aba0abd57df3c4571f86d
|
|
| MD5 |
aa41e20f86f0aa9daaf897dd2483c15e
|
|
| BLAKE2b-256 |
487ca585901a4d144713356f534d59dfefb2b1f7307a3b156d694dda02089421
|
File details
Details for the file amplitude_data_wrapper-0.6.2-py3-none-any.whl.
File metadata
- Download URL: amplitude_data_wrapper-0.6.2-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7c4b74ed29753c63a4829a94238dd8a501e8123706b0d72fbfb379239822e3a
|
|
| MD5 |
ef2bad5505ddad4a613d2e406bebf904
|
|
| BLAKE2b-256 |
72131cfe584632224e8cebabd610c2cd4bb01243033149271d644ca02c17da40
|