1

Basically, I want to use Appsflyer API by Python to get metrics. I tried to find some documentation about this but It seems like there is no support for this. If it possible please give me an example of how to use Python to get metrics on Appsflyer?

Key Jun
  • 440
  • 3
  • 8
  • 18
  • What have you tried so far? – Klaus D. Dec 25 '18 at 03:05
  • I searched on google how to use Python to get metrics from Appsflyer but there was no result – Key Jun Dec 25 '18 at 03:08
  • You don't have a single line of code yet? – Klaus D. Dec 25 '18 at 03:15
  • Of course not. Do you understand my question? I do not know how to get started. Now I am asking for directions – Key Jun Dec 25 '18 at 03:18
  • Unluckily SO is not a platform for giving directions. It is for specific answer to specific questions. And it is expected that you have written some code or at least have done intensive research on the topic. Just a few Google queries is not enough. – Klaus D. Dec 25 '18 at 03:40

2 Answers2

4

There are several different APIs AppsFlyer offers to get metrics. These include Push API, Pull API, and Master API. Below is an explanation on how to get metrics using the Pull API including a sample Python script.

Review this documentation found in the AppsFlyer Help Center:

Here is an example of a url you could paste into the browser that would generate a csv file:

https://hq.appsflyer.com/export/<APP ID HERE>/installs_report/v5?api_token=<API TOKEN HERE>&from=<FROM DATE HERE>&to=<TO DATE HERE>
  • Both from_date and to_date should be entered in this format 'yyyy-mm-dd' (without the quotes)

  • The app_id and api_token are available via the AppsFlyer dashboard, (app_id is also available outside of the dashboard)

  • Other examples could be found in the links provided above.

Here is a sample version of a script in Python:

import requests
import os
import json
import urllib

def main():

    #ENTER PARAMETERS BELOW
    api_endpoint = "https://hq.appsflyer.com/export/"
    api_token = "" #Enter API Token here ; found under "Integration" > "API Access" in the platform
    app_id = ""         #Enter app id here ; Apple IDs look like id123456789 ; Andriod IDs look like com.myapp
    report_name = ""    #Enter name here ; e.g. "installs_report"

    from_dt = ""    #e.g. "2019-01-01"
    to_dt ""        #e.g. = "2019-01-07"

    #NO NEED TO MODIFY CODE BELOW
    query_params = {
        "api_token": api_token,
        "from": str(from_dt),
        "to": str(to_dt)
        }


    query_string = urllib.parse.urlencode(query_params)

    request_url = api_endpoint + app_id + "/" report_name + "/v5?" + query_string

    print(request_url)

    resp = urllib.request.urlopen(request_url)

    with open("appsflyer_installs_data.csv","wb") as fl:
        fl.write(resp.read())

if __name__ == "__main__":
    main()

Once you configure the parameters correctly, you can use the above script to generate a file called "appsflyer_installs_data.csv".

There are other parameters you can add to get additional fields and filter the data. Information on this could be found in the article shared above. These queries are also held to an API Policy.

As a reminder, this is just one example of how you could get data out of AppsFlyer. For others make sure to review support.appsflyer.com.

Michael I
  • 76
  • 5
1

As of today, there is no official Python SDK for AppsFlyer, but on Github, you can find unofficial API-clients:

nocibambi
  • 2,065
  • 1
  • 16
  • 22