Skip to main content

Adjust.com REST API python implementation

Project description

Welcome to the python-adjust

This is an unofficial Python wrapper for the Adjust.com REST API. I am in no way affiliated with Adjust.com, use at your own risk.

Regards

This project was inspired by adjusty

Documentation

Please find official documentation by: https://help.adjust.com/en/article/kpi-service

QuickStart

Your access to the KPI Service is tied to your Adjust user account. Each user account has an associated user token, to allow you to individually control access to your KPIs.

You can find your own user token in the dashboard, under Account Settings > Your Data > User Details. This is the user token we’ll be referring to for your authentication below.

pip install python-adjust

Let's retrieve list of applications accessible to you

from adjustapi.api import AdjustApi

api = AdjustApi('USER_TOKEN')

apps = api.list_apps()

print(apps[0].name, apps[0].token, apps[0].id)
# Prints something like: "MyTestApp ft5popkfebns com.mytest.app"

This is how KPI API works

kpis_api = api.kpi_service(trackers=trackers,
                           start_date=start_date,
                           end_date=end_date,
                           countries=countries,
                           app_tokens=app_tokens,
                           kpis=kpis)
print(str(kpis_api.fetch_kpi()))
# prints: KpiResult(result_parameters=ResultParameters(kpis=['revenue'], start_date=datetime.date(2020, 4, 4), end_date=datetime.date(2020, 5, 4), sandbox=False, countries=['us'], events=None, trackers=[TrackerResultParameters(token='tsrdag', name='Facebook Installs::Expired Attributions', currency=None, has_subtrackers=False)], grouping=['trackers'], period=None, attribution_type='click', utc_offset='00:00', cohort_period_filter=None, day_def=None, attribution_source='dynamic'), result_set={'token': 'thomki', 'name': 'Facebook Installs', 'currency': 'USD', 'trackers': [{'token': 'tsodkg', 'kpi_values': [3627.54]}]})

print(str(kpis_api.fetch_events()))
# prints: KpiResult(result_parameters=ResultParameters(kpis=['revenue'], start_date=datetime.date(2020, 4, 4), end_date=datetime.date(2020, 5, 4), sandbox=False, countries=['us'], events=[EventParameter(name='com.test.subscription.name', token='s6p2ub'), EventParameter(name='event_name', token='eakvze'), EventParameter(name='event.name.2', token='5a6u7u'), EventParameter(name='event_name_3', token='e34v0e')], trackers=[TrackerResultParameters(token='6tcrta', name='Facebook Installs::Expired Attributions', currency=None, has_subtrackers=False)], grouping=['trackers', 'event_types'], period=None, attribution_type='click', utc_offset='00:00', cohort_period_filter=None, day_def=None, attribution_source='dynamic'), result_set={'token': 'thamsi', 'name': 'Facebook Installs', 'currency': 'USD', 'trackers': [{'token': 'tsrdta', 'events': [{'token': 'e6e2v1', 'kpi_values': [1149.77]}, {'token': 'ea3vpe', 'kpi_values': [95.88]}, {'token': 'e34v0e', 'kpi_values': [17.99]}, {'token': 'eovy8e', 'kpi_values': [147.63]}}]}]})

print(str(kpis_api.fetch_cohorts()))
# KpiResult(result_parameters=ResultParameters(kpis=['revenue'], start_date=datetime.date(2020, 4, 4), end_date=datetime.date(2020, 5, 4), sandbox=False, countries=['us'], events=None, trackers=[TrackerResultParameters(token='csodbh', name='Facebook Installs::Expired Attributions', currency=None, has_subtrackers=False)], grouping=['trackers', 'periods'], period='day', attribution_type='click', utc_offset='00:00', cohort_period_filter=None, day_def='24h', attribution_source='dynamic'), result_set={'token': 'chamsh', 'name': 'Facebook Installs', 'currency': 'USD', 'trackers': [{'token': 'cscoth', 'periods': [{'period': '0', 'kpi_values': [109.89]}}]}]})

But most of the time you need these data as table, so you can retrieve it as pandas Dataframe

kpis_api = api.kpi_service(trackers=trackers,
                           start_date=start_date,
                           end_date=end_date,
                           countries=countries,
                           app_tokens=app_tokens,
                           kpis=kpis)
print(str(kpis_api.fetch_kpi(as_df=True)))

# '  tracker_token                             tracker_name  revenue
# 0        tsrdag  Facebook Installs::Expired Attributions  3627.54'

For more check out the documentation.

If you have any questions feel free to add issues or write to me.

TODO: Add link to Airflow hook and operator for AdjustApi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

python_adjust-1.0.3-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file python_adjust-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: python_adjust-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for python_adjust-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b8e165017147417712aff59f8398c93b851bd62589d9637cc38485e312427ba9
MD5 135fdc5284ec7336a29190c2f804914e
BLAKE2b-256 c06d62658c478af7bc4e679aa77fff5738489247fb1df390d2754edc20739577

See more details on using hashes here.

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