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?
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:
Documentation for using the Pull API to export data out of AppsFlyer could be found here: Introduction to Pull API
Examples on pulling Raw Data found here: Pulling Raw Data with the Pull API
Examples on pulling Performance Reports found here: Pulling Performance Reports with the Pull API
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.