Calls to the API require authorization, so before we get started, you obtain keys to create the tokens from your organization’s App Store Connect account. See Creating API Keys for App Store Connect API to create your keys and tokens.
Connection
Connection is the core class of Applaud, it holds a connection between client and remote service, generate a new token before it expires.
from applaud.connection import Connection
# Create a connection object using API keys
connection = Connection(APPSTORE_ISSUER_ID, APPSTORE_KEY_ID, APPSTORE_PRIVATE_KEY)
In most of cases, all tasks you'd like to perform on remote service should be initiated from a Connection object. Connection has a bunch of functions help you create …Endpoint objects:
# Return an AppListEndpoint object
connection.apps()
Endpoint
A …Endpoint class encapsulates all operations you can perform on a specific resource. For example, this snippet fetches first two (sort by app name) apps that "ready for sale" and have game center enabled versions:
The get() operation initiates a HTTP GET request on the endpoint's path. For example, the URL of List Apps service endpoint is:
GET https://api.appstoreconnect.apple.com/v1/apps
The corresponding code in Applaud:
# Return an AppsResponse object
response = connection.apps().get()
for app in response.data:
print(f'{app.attributes.name}: {app.attributes.bundle_id}')
Unlike other operations (create(), update() and delete()), get() operation can be chained by query parameters functions:
filter()
You use filter() function to extract matching resources. For example:
filter[bundleId] Attributes, relationships, and IDs by which to filter.
[string]
The corresponding code in Applaud:
response = connection.apps().filter(
bundle_id="com.exmaple.app1"
).get()
# or
connection.apps().filter(
bundle_id=["com.exmaple.app1", "com.exmaple.app2"]
).get()
for app in response.data:
print(f'{app.attributes.name}: {app.attributes.bundle_id}')
include()
You use include() function to ask relationship data to include in the response. For example:
include Relationship data to include in the response.
[string] Possible values: appClips, appInfos, appStoreVersions,
availableTerritories, betaAppLocalizations,
betaAppReviewDetail, betaGroups, betaLicenseAgreement,
builds, ciProduct, endUserLicenseAgreement,
gameCenterEnabledVersions, inAppPurchases, preOrder,
preReleaseVersions, prices
You use fields() function to ask fields data to return for included related resources in a get() operation. Related resources specified in fields() function MUST be included explicitly in include() function, otherwise, the remote service may not return the fields data that you expect. For example:
fields[betaLicenseAgreements] Fields to return for included related types.
[string] Possible values: agreementText, app
You use limit() function to restrict the maximum number of resources to return in a get() operation. For example:
limit Number of resources to return.
integer Maximum Value: 200
The corresponding code in Applaud:
# Return a response contains 10 apps at most
connection.apps().limit(10).get()
# Raise a ValueError exception, the maxinmu allowed value is 200
connection.apps().limit(400).get()
You can also included limit the number of related resources to return, as in fields() function, you MUST also specify the related resources explicitly in include() function. For example:
limit[appStoreVersions] integer
Maximum Value: 50
The corresponding code in Applaud:
# All returned apps have 5 related app store version at most
connection.apps().include(
AppListEndpoint.Include.APP_STORE_VERSIONS
).limit(app_store_versions=5).get()
# Raise a ValueError exception, the maxinmu allowed value is 50
connection.apps().include(
AppListEndpoint.Include.APP_STORE_VERSIONS
).limit(app_store_versions=100).get()
By leverage limit() function with sort() function, your script can be more responsive.
sort()
You use sort() function to sort the returned resources by attributes in ascending or descending order. For example:
sort Attributes by which to sort.
[string] Possible values: bundleId, -bundleId, name, -name, sku, -sku
The delete() operation initiates a HTTP DELETE request on the endpoint's path. For example, the URL of Delete an App Store Version service endpoint is:
For the second case, Applaud raises an EndpointException exception, and attaches all ErrorResponse.Error objects in EndpointException.errors attribute.
Some errors are harmless, for example, App Store Connect has no API for you to tell whether a tester has accepted beta test invitation or not. When you trying to resend invitations to testers, you may encounter an ALREADY_ACCEPTED error, it's safe to just ignore such error:
try:
# Send / resend beta test invitations
response = connection.beta_tester_invitations().create(…)
except EndpointException as err:
already_accepted_error = Falsefor e in err.errors:
if e.code == 'STATE_ERROR.TESTER_INVITE.ALREADY_ACCEPTED':
# silent this error
already_accepted_error = Truebreakifnot already_accepted_error:
raise err
Caveats
Query parameters functions (filter(), include, fields …) play a role only when using with …Endpoint.get(). Though there is no side effects if chain it with …Endpoint.create(), …Endpoint.update() and …Endpoint.delete() operations, it is not adviced.
FAQs
The Python SDK to work with the App Store Connect API from Apple.
We found that applaud demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.