In this article, I will show you the way to get Units, the term indicates how many downloads on your own application published on App Store, following by days, months, years, using Python script

Make sure you have your own privileges to access App Store Connect and generate below information

Generate API Key, download Private Key,

- Select Users and Access, and then select the API Keys tab.
- Click Generate API Key or the Add (+) button.
- Enter a name for the key. The name is for your reference only and is not part of the key itself.
- Under Access, select the role for the key.
- Click Generate.
- Click "Download API Key" link next to the new API key.
More instruction:

The API Key looks like this format


The Private Key looks like this format

---- Begin Private Key ----
---- End Private Key ----

Also from Connector page, please prepares more 2 Ids to process next step

IssuerId. Ex: 57246542-96fe-1a63-e053-0824d011072a
VendorId. Ex. 1234567
More Instruction:

So, in total, make sure you already kept:

KeyId = API Key

Sign JWT Token

Next, we will use them to create and sign JWT Token, I have created a python function to archieve downloading, if you are using another language or simply RESTful, please follow official instruction here

# pip install pyjwt
# pip install pyjwt[crypto]
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(
    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

Download report

This link provides the method to download report

Be noticed that 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
  • filter[frequency] = MONTHLY, then filter[reportDate] = 2021-06.
    The frequency configuration groups the report to a file, depends on your needs.

Sample query:[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

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'[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

Columns included:

Provider Country    
SKU Developer   
Product Type Identifier 
Developer Proceeds  
Begin Date  
End Date    
Customer Currency   
Country Code    
Currency of Proceeds    
Apple Identifier    
Customer Price  
Promo Code  
Parent Identifier   
Period  Category    
Supported Platforms
Proceeds Reason 
Preserved Pricing   

About field types, please refer

Previous Post:
Next Post: