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")
Metadata
Release files for amplitude-data-wrapper 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| amplitude_data_wrapper-0.6.2.tar.gz | 10.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| amplitude_data_wrapper-0.6.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.5 kB
Release files / amplitude_data_wrapper-0.6.2.tar.gz
| Download URL | amplitude_data_wrapper-0.6.2.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35a5e228ee7d391342b80e37f0f9878c2b4c8287ab8aba0abd57df3c4571f86d
|
|
BLAKE2b-256 checksum How to use checksums |
487ca585901a4d144713356f534d59dfefb2b1f7307a3b156d694dda02089421
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / amplitude_data_wrapper-0.6.2-py3-none-any.whl
| Download URL | amplitude_data_wrapper-0.6.2-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7c4b74ed29753c63a4829a94238dd8a501e8123706b0d72fbfb379239822e3a
|
|
BLAKE2b-256 checksum How to use checksums |
72131cfe584632224e8cebabd610c2cd4bb01243033149271d644ca02c17da40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|