使用以下代码示例调用API以获取详细报告:
import requests
import json
# Replace with your API key
api_key = "YOUR_API_KEY"
# Replace with the report type and filter format you want to use
report_type = "SALES"
filter = {
"frequency": "DAILY",
"reportType": "SUMMARY",
"version": "VERSION"
}
# Replace with your App Store Connect account number and vendor number
account_number = "YOUR_ACCOUNT_NUMBER"
vendor_number = "YOUR_VENDOR_NUMBER"
# Replace with the date range you want to get the report for
start_date = "2022-01-01"
end_date = "2022-01-02"
# Build the API URL
url = f"https://api.appstoreconnect.apple.com/v1/salesReports/{report_type}/?filter={json.dumps(filter)}&\
vendorNumber={vendor_number}&\
reportDate={start_date}%2F{end_date}&\
saleType=SALES&\
regionCode=WW&\
reportSubType=COUNTRY_DETAIL"
# Make the API call
response = requests.get(url, headers={"Authorization": f"Bearer {api_key}"})
# Process the response
if response.ok:
data = response.json()
#Process the data
else:
print("API call failed: ", response.status_code, response.text)
其中,report_type
、filter
、account_number
和vendor_number
需要替换为相应的值,start_date
和end_date
也需要替换为所需的日期范围。此代码示例使用Python和Requests库进行API调用,需要安装Requests库。
此代码示例调用的是销售报告的详细版本,可以通过更改filter
中的reportType
和reportSubType
来选择报告类型。详细的报告类型和筛选器格式可以在App Store Connect API文档中找到。