Hey there, I want to fetch all the reviews from an app of mine. Seems like the limit is 200 per request. How can I get all the reviews and not just 200?
i don't want to scrape the web and prefer to use the API I wasn't able to do that following this guide.
this is my code:
def generate_token(key_id: str, issuer: str, private_key: str):
"""this function creates a token to access Apple's App Store API"""
# get current and expiration time
# note:apple will ban every request with an expiration time > 20 minutes
current_time = int(time.time())
expiration_time = current_time + 900
# prepare the jtw headers
headers = {
"alg": "ES256",
"kid": key_id,
"typ": "JWT",
}
# prepare the payload
payload = {
"iss": issuer,
"iat": current_time,
"exp": expiration_time,
"aud": "appstoreconnect-v1",
}
# generate the token
token = jwt.encode(
payload,
private_key,
algorithm="ES256",
headers=headers,
)
# print and retutn
print(token)
return token
def app_store_reviews(app_id: str, key_id: str, issuer: str, private_key: str):
"""this function returns all the reviews of an app on the app store."""
# prepare API request
url = f"https://api.appstoreconnect.apple.com/v1/apps/{app_id}/customerReviews?limit=200"
token = generate_token(key_id, issuer, private_key)
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
# Make the GET request
response = requests.get(url, headers=headers)
# request is successful
if response.status_code == 200:
reviews_data = response.json()
print(reviews_data)
# request failed
else:
print(response.text)
Cheers, Flippo