Appstore Connect SDK ![@latest](https://img.shields.io/npm/v/appstore-connect-sdk.svg)
The App Store Connect SDK for Node.js is written in TypeScript and supports all APIs based on OpenAPI Generator.
English | 简体中文
Kickstart information on the API
Included in this SDK
Installation
npm install appstore-connect-sdk
Usage
1. Import appstore-connect-sdk
import AppStoreConnectAPI from "appstore-connect-sdk";
2. Create your API Configuration
Go to App Sotre Connect -> Users and Access -> Keys and create your own key. This is also the page to find your private key ID
and the issuer ID
.
After downloading your private key, open the .p8
file containing the private key in a text editor. It should look like this:
-----BEGIN PRIVATE KEY-----
AIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgKEn1VBakCdHIEcdS
aBWr/9laASzaAbF2LP7wTYjHK52gCgYIKoZIzj0DAQehRANCAAQ/jf2sxRvXEhjn
srw8kJcHvO0dQ1KmUlxZvATsFsjJbdQ1yAENAWItUoeTV0rhdajcdOQxKl1OPse0
nNdXXbA4
-----END PRIVATE KEY-----
Now use this Private Key
together with the isuer ID
and the private key ID
to create your configuration:
const appStoreConnect = new AppStoreConnectAPI({
issuerId: "<YOUR ISSUER ID>",
privateKeyId: "<YOUR PRIVATE KEY ID>",
privateKey: "<YOUR PRIVATE KEY>",
});
For more information on how JWT works with the App Store Connect API, check out Apple's authentication guides:
3. Create an API and perform a request
You can find all available APIs in src/openapi/apis, these classes are generated according to App Store Connect API - OpenAPI specification, If you encounter any problems, please open an issue.
const res = await client.call(AppsApi).appsGetCollection();
console.log(res);
Here's the complete code example:
import AppStoreConnectAPI from "appstore-connect-sdk";
import {
AppsApi,
AppEventLocalizationsApi,
} from "appstore-connect-sdk/dist/openapi/apis";
const appStoreConnect = new AppStoreConnectAPI({
issuerId: "<YOUR ISSUER ID>",
privateKeyId: "<YOUR PRIVATE KEY ID>",
privateKey: "<YOUR PRIVATE KEY>",
});
const res = await client.call(AppsApi).appsGetCollection();
console.log(res);
Custom network libraries
By default, AppStoreConnectAPI uses its built-in fetch
function for HTTP requests. Note that this function requires Node.js version 18.0.0 or higher.
However, you can also configure any network library that adheres to the Fetch API standard specification by setting the fetchApi
option in the AppStoreConnectAPI constructor.
import AppStoreConnectAPI from "appstore-connect-sdk";
import fetch from "node-fetch";
new AppStoreConnectAPI({
fetchApi: fetch as unknown as FetchAPI,
});
Updating OpenAPI generated code
To update the OpenAPI-generated code, run the following command:
$ sh gen-openapi.sh
This will generate Typescript code through OpenAPI Generator based on the OpenAPI specification file officially released by Apple.
License
appstore-connect-sdk is available under the MIT license, and uses source code from open source projects. See the LICENSE file for more information.
Author
This project was originally created by isaced but has had many great contributors. We're open to contributions of any kind to make this project even better.