Package: applaud
ApplaudApplaudis a Python client library for accessingApp Store Connect API, generated byApplaudgen.FeaturesSupport App Store Connect API latest version 1.6Supportfilter,fileds,include,limit,sort,existsand other query parametersAll endpoints / paths are implemented, include, but not limited to: App Information, TestFlight, Users and Roles, Sales and FinancesPythonic, allcamelCaseschema fields are represented assnake_caseclass attributesEmbracePython type hintsUsePython Requeststo hanlde HTTP sessionsErrorResponsecan be catched as exceptionInstallationInstall withpip:pip install applaudInstall withPoetry:poetry add applaudInstall withPipenv:pipenv install applaudUsageCalls 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. SeeCreating API Keys for App Store Connect APIto create your keys and tokens.ConnectionConnectionis the core class ofApplaud, it holds a connection between client and remote service,generate a new tokenbefore it expires.fromapplaud.connectionimportConnection# Create a connection object using API keysconnection=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 aConnectionobject.Connectionhas a bunch of functions help you create…Endpointobjects:# Return an AppListEndpoint objectconnection.apps()EndpointA…Endpointclass 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:# Return an AppsResponse objectconnection.apps().filter(app_store_versions_app_store_state=AppStoreVersionState.READY_FOR_SALE).exists(game_center_enabled_versions=True).limit(2).sort(name:SortOrder.ASC).get()…Endpoint.get()Theget()operation initiates a HTTPGETrequest on the endpoint's path. For example, the URL ofList Appsservice endpoint is:GET https://api.appstoreconnect.apple.com/v1/appsThe corresponding code inApplaud:# Return an AppsResponse objectresponse=connection.apps().get()forappinresponse.data:print(f'{app.attributes.name}:{app.attributes.bundle_id}')Unlike other operations (create(),update()anddelete()),get()operation can be chained by query parameters functions:filter()You usefilter()function to extract matching resources. For example:filter[bundleId]  Attributes, relationships, and IDs by which to filter.
        [string]The corresponding code inApplaud:response=connection.apps().filter(bundle_id="com.exmaple.app1").get()# orconnection.apps().filter(bundle_id=["com.exmaple.app1","com.exmaple.app2"]).get()forappinresponse.data:print(f'{app.attributes.name}:{app.attributes.bundle_id}')include()You useinclude()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, pricesThe corresponding code inApplaud:response=connection.apps().include(AppListEndpoint.Include.BETA_LICENSE_AGREEMENT).get()# orresponse=connection.apps().include([AppListEndpoint.Include.BETA_LICENSE_AGREEMENT,AppListEndpoint.Include.PRICES]).get()fields()You usefields()function to ask fields data to return for included related resources in aget()operation. Related resources specified infields()functionMUSTbe included explicitly ininclude()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, appThe corresponding code inApplaud:connection.apps().include(AppListEndpoint.Include.BETA_LICENSE_AGREEMENT).fields(beta_license_agreement=[BetaLicenseAgreementField.AGREEMENT_TEXT,BetaLicenseAgreementField.APP]).get()limit()You uselimit()function to restrict the maximum number of resources to return in aget()operation. For example:limit  Number of resources to return.
integer  Maximum Value: 200The corresponding code inApplaud:# Return a response contains 10 apps at mostconnection.apps().limit(10).get()# Raise a ValueError exception, the maxinmu allowed value is 200connection.apps().limit(400).get()You can also included limit the number of related resources to return, as infields()function, youMUSTalso specify the related resources explicitly ininclude()function. For example:limit[appStoreVersions]  integer
                         Maximum Value: 50The corresponding code inApplaud:# All returned apps have 5 related app store version at mostconnection.apps().include(AppListEndpoint.Include.APP_STORE_VERSIONS).limit(app_store_versions=5).get()# Raise a ValueError exception, the maxinmu allowed value is 50connection.apps().include(AppListEndpoint.Include.APP_STORE_VERSIONS).limit(app_store_versions=100).get()By leveragelimit()function withsort()function, your script can be more responsive.sort()You usesort()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, -skuThe corresponding code inApplaud:connection.apps().sort(name=SortOrder.ASC,bundleId=SortOrder.DESC).get()exists()exists()is a special type of filter – filter by existence or non-existence of related resource. For example:exists[gameCenterEnabledVersions]  [string]The corresponding code inApplaud:connection.apps().exists(game_center_enabled_versions=True).get()…Endpoint.create()Thecreate()operation initiates a HTTPPOSTrequest on the endpoint's path. For example, the URL ofCreate an App Store Versionservice endpoint is:POST https://api.appstoreconnect.apple.com/v1/appStoreVersionsThe corresponding code inApplaud:request=AppStoreVersionCreateRequest(data=AppStoreVersionCreateRequest.Data(relationships=AppStoreVersionCreateRequest.Data.Relationships(app=AppStoreVersionCreateRequest.Data.Relationships.App(data=AppStoreVersionCreateRequest.Data.Relationships.App.Data(id='com.exmaple.app1'))),attributes=AppStoreVersionCreateRequest.Data.Attributes(version_string='1.6',platform=Platform.IOS,copyright=f'Copyright © 2021 Codinn Technologies. All rights reserved.',release_type=AppStoreVersionReleaseType.AFTER_APPROVAL)))# Return an AppStoreVersionResponse objectreponse=connection.app_store_versions().create(request)version=response.dataprint(f'{version.version_string}:{version.created_date},{version.app_store_state}')…Endpoint.update()Theupdate()operation initiates a HTTPPATCHrequest on the endpoint's path. For example, the URL ofModify an App Store Versionservice endpoint is:PATCH https://api.appstoreconnect.apple.com/v1/appStoreVersions/{id}The corresponding code inApplaud:# Get the version id created in previous exampleversion_id=version.data.id# Update version's informationrequest=AppStoreVersionUpdateRequest(data=AppStoreVersionUpdateRequest.Data(id=version.data.id,attributes=AppStoreVersionUpdateRequest.Data.Attributes(version_string='1.6.1',platform=Platform.IOS,copyright=f'Copyright © 2022 Codinn Technologies. All rights reserved.',release_type=AppStoreVersionReleaseType.AFTER_APPROVAL)))# Return an AppStoreVersionResponse objectreponse=connection.app_store_version(version_id).update(request)version=response.dataprint(f'{version.version_string}:{version.copyright},{version.app_store_state}')…Endpoint.delete()Thedelete()operation initiates a HTTPDELETErequest on the endpoint's path. For example, the URL ofDelete an App Store Versionservice endpoint is:DELETE https://api.appstoreconnect.apple.com/v1/appStoreVersions/{id}The corresponding code inApplaud:# Get the version id created in previous exampleversion_id=version.data.idconnection.app_store_version(version_id).delete()Exceptions…Endpoint.get(),…Endpoint.create(),…Endpoint.update()and…Endpoint.delete()may raise two types of exceptions:HTTP request exceptions raised byPython RequestsRemote service returns anErrorResponseFor the second case,Applaudraises anEndpointExceptionexception, and attaches allErrorResponse.Errorobjects inEndpointException.errorsattribute.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 anALREADY_ACCEPTEDerror, it's safe to just ignore such error:try:# Send / resend beta test invitationsresponse=connection.beta_tester_invitations().create(…)exceptEndpointExceptionaserr:already_accepted_error=Falseforeinerr.errors:ife.code=='STATE_ERROR.TESTER_INVITE.ALREADY_ACCEPTED':# silent this erroralready_accepted_error=Truebreakifnotalready_accepted_error:raiseerrCaveatsQuery 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.