Reputation: 3
Is it possible to get the data from Units download by day or installed via API ? but the problem is hard to find the resources of documentation of it.
this image below is the data I want to have.
https://i.sstatic.net/P3NDF.png
Upvotes: 0
Views: 2123
Reputation: 11
The only problem is that in this report generated by the API, the "Units" column counts the downloads, the "in-app purchases", "re-downloads" or other things, and this causes a difference in the number of units seen in the review on the Apple Connect Store, as @CameronPorter mentioned. However, when reading the documentation, I couldn't find a way to get only the downloads (units without the in-app purchase). See explanations below:
Explanation of the problem cited in the Apple documentation
Link for reference: https://help.apple.com/app-store-connect/#/dev5340bf481
Upvotes: 1
Reputation: 2026
It has several steps to archieve. First you have to follow 2 links here: Create keys: https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api
Create and sign JWT Token https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests
These important keys to get is:
IssuerId
KeyId
VendorId
PrivateKey
If you are using Python, I would suggest using PyJWT to sign it
from datetime import datetime, timezone
import jwt
def sign_appstore_token(issuer_id, key_id, generated_private_key):
bin_private_key = generated_private_key.encode()
current_unix = int(datetime.now(tz=timezone.utc).timestamp())
token = jwt.encode({
"iss": issuer_id,
"iat": current_unix,
"exp": current_unix + 1000,
"aud": "appstoreconnect-v1",
}, key= bin_private_key, algorithm= 'ES256', headers= {
"alg": "ES256",
"kid": key_id,
"typ": "JWT"
})
return token
From generated token, continue following this link https://developer.apple.com/documentation/appstoreconnectapi/download_sales_and_trends_reports
To get the Units, reportType should be SALES
. Also noticed that reportDate and frequency have to consistency each other, if you specify filter[frequency] = YEARLY, then filter[reportDate] = 2021
or filter[frequency] = MONTHLY, then filter[reportDate] = 2021-06
. For more details, please refer to the above link
Sample query here:
https://api.appstoreconnect.apple.com/v1/salesReports?filter[frequency]=YEARLY&filter[reportDate]=2021&filter[reportSubType]=SUMMARY&filter[reportType]=SALES&filter[vendorNumber]=YOUR_VENDOR_ID
Headers: Authorization: Bearer YOUR_ABOVE_TOKEN
You will get binary response if it is success, represented for .gz file as well. Extract gz to get .txt schema deliminated by \t
Columns:
Provider Provider Country SKU Developer Title Version Product Type Identifier Units Developer Proceeds Begin Date End Date Customer Currency Country Code Currency of Proceeds Apple Identifier Customer Price Promo Code Parent Identifier Subscription Period Category CMB Device Supported Platforms Proceeds Reason Preserved Pricing Client Order Type
Python script here returns file content as text, you can do your next step, pandas table, or to model, it is up to you
import requests
import gzip
def download_appstore_objects(token, vendor_id, frequency, reportDate):
link = f'https://api.appstoreconnect.apple.com/v1/salesReports?filter[frequency]={frequency}&filter[reportDate]={reportDate}&filter[reportSubType]=SUMMARY&filter[reportType]=SALES&filter[vendorNumber]={vendor_id}'
response = requests.get(link, headers= {'Authorization': f'Bearer {token}' })
file_content = gzip.decompress(response.content).decode('utf-8')
return file_content
Upvotes: 0