appstore-connect-sdk 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,2 +1,115 @@
1
- # appstoreconnect-api
2
- An App Store Connect API client for Node.js
1
+ # appstoreconnect-api [![@latest](https://img.shields.io/npm/v/appstore-connect-sdk.svg)](https://www.npmjs.com/package/appstore-connect-sdk)
2
+
3
+ App Store Connect SDK for Nodejs, written in Typescript, supports all APIs based on OpenAPI Generator.
4
+
5
+ ## Kickstart information on the API
6
+
7
+ - [Automate your workflow with the App Store Connect API](https://developer.apple.com/app-store-connect/api/)
8
+ - [App Store Connect API Official Documentation](https://developer.apple.com/documentation/appstoreconnectapi)
9
+ - [WWDC 2018 303 - Automating App Store Connect](https://developer.apple.com/videos/play/wwdc2018/303/) (Video)
10
+
11
+ ## Included in this SDK
12
+
13
+ - [x] Configuration with API Key
14
+ - [x] JWT Logic to sign requests
15
+ - [x] Support custom network libraries for making requests, such as fetch/node-fetch/axios...
16
+ - [x] Supports _all_ requests due to OpenAPI generated requests and entities
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install appstoreconnect-api
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ #### 1. Import `appstore-connect-sdk`
27
+
28
+ ```typescript
29
+ import AppStoreConnectAPI from 'appstore-connect-sdk';
30
+ ```
31
+
32
+ #### 2. Create your API Configuration
33
+
34
+ Go to [App Sotre Connect -> Users and Access -> Keys](https://appstoreconnect.apple.com/access/api) and create your own key. This is also the page to find your `private key ID` and the `issuer ID`.
35
+
36
+ After downloading your private key, you can open the `.p8` file containing the private key in a text editor which will show like the following content:
37
+
38
+ ```
39
+ -----BEGIN PRIVATE KEY-----
40
+ AIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgKEn1VBakCdHIEcdS
41
+ aBWr/9laASzaAbF2LP7wTYjHK52gCgYIKoZIzj0DAQehRANCAAQ/jf2sxRvXEhjn
42
+ srw8kJcHvO0dQ1KmUlxZvATsFsjJbdQ1yAENAWItUoeTV0rhdajcdOQxKl1OPse0
43
+ nNdXXbA4
44
+ -----END PRIVATE KEY-----
45
+ ```
46
+
47
+ Now use this `Private Key` together with the `isuer ID` and the `private key ID` to create your configuration:
48
+
49
+ ```typescript
50
+ const appStoreConnect = new AppStoreConnectAPI({
51
+ issuerId: "<YOUR ISSUER ID>",
52
+ privateKeyId: "<YOUR PRIVATE KEY ID>",
53
+ privateKey: "<YOUR PRIVATE KEY>",
54
+ });
55
+ ```
56
+
57
+ #### 3. Create an API and perform a request
58
+
59
+ You can find all available APIs in [src/openapi/apis](https://github.com/isaced/appstore-connect-sdk/tree/main/src/openapi/apis), these classes are generated according to [App Store Connect API - OpenAPI specification](https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip), if you encounter missing or any problem, please open an [issue](https://github.com/isaced/appstore-connect-sdk/issues).
60
+
61
+ ```typescript
62
+ const api = new AppsApi(appStoreConnect.configuration);
63
+ const res = await api.appsAppEventsGetToManyRelated({ id: APP_ID });
64
+ console.log(res);
65
+ ```
66
+
67
+ #### The complete code example above
68
+
69
+ ```typescript
70
+ import AppStoreConnectAPI from 'appstore-connect-sdk';
71
+ import { AppsApi, AppEventLocalizationsApi } from 'appstore-connect-sdk/dist/openapi/apis';
72
+
73
+ const appStoreConnect = new AppStoreConnectAPI({
74
+ issuerId: "<YOUR ISSUER ID>",
75
+ privateKeyId: "<YOUR PRIVATE KEY ID>",
76
+ privateKey: "<YOUR PRIVATE KEY>",
77
+ });
78
+
79
+ const api = new AppsApi(appStoreConnect.configuration);
80
+ const res = await api.appsAppEventsGetToManyRelated({ id: APP_ID });
81
+ console.log(res);
82
+ ```
83
+
84
+ ### Custom network libraries
85
+
86
+ In order to adapt to different projects, it is supported to configure any network library to take over HTTP requests, just follow the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/fetch) standard specification and set `fetchApi` in the `AppStoreConnectAPI` option.
87
+
88
+ ```typescript
89
+ import AppStoreConnectAPI from 'appstore-connect-sdk';
90
+ import { FetchAPI } from "./../src/openapi/runtime";
91
+ import fetch from 'node-fetch';
92
+
93
+ new AppStoreConnectAPI({
94
+ // ...
95
+ fetchApi: fetch as FetchAPI, // All network requests are made via node-fetch
96
+ });
97
+ ```
98
+
99
+ ## Update OpenAPI generated code
100
+
101
+ Run the following:
102
+
103
+ ```bash
104
+ $ sh gen-openapi.sh
105
+ ```
106
+
107
+ This will generate Typescript code through [OpenAPI Generator](https://openapi-generator.tech/) based on the [OpenAPI specification](https://github.com/isaced/appstore-connect-sdk/blob/fdabb5bb414e9e3c02341ac1fa3238a5bfa15c30/app_store_connect_api_2.2_openapi.json) file officially released by Apple.
108
+
109
+ ## License
110
+
111
+ **appstore-connect-sdk** is available under the MIT license, and uses source code from open source projects. See the [LICENSE](https://github.com/isaced/appstore-connect-sdk/blob/main/LICENSE) file for more info.
112
+
113
+ ## Author
114
+
115
+ This project is originally created by [isaced](https://github.com/isaced) but has a lot of [great contributors](https://github.com/isaced/appstore-connect-sdk/graphs/contributors). We're open for contributions of any kind to make this project even better.
package/dist/main.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { FetchAPI } from "./openapi/runtime";
2
2
  import { Configuration } from "./openapi";
3
3
  interface AppStoreConnectAPIOptions {
4
- apiKey: string;
5
4
  issuerId: string;
5
+ privateKeyId: string;
6
6
  privateKey: string;
7
7
  fetchApi?: FetchAPI;
8
8
  }
package/dist/main.js CHANGED
@@ -5,7 +5,7 @@ const auth_1 = require("./auth");
5
5
  class AppStoreConnectAPI {
6
6
  constructor(options) {
7
7
  this.bearerToken = (0, auth_1.generateAuthToken)({
8
- apiKeyId: options.apiKey,
8
+ apiKeyId: options.privateKeyId,
9
9
  issuerId: options.issuerId,
10
10
  privateKey: options.privateKey,
11
11
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appstore-connect-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "An App Store Connect API client for Node.js",
5
5
  "keywords": [
6
6
  "appstore connect",
@@ -40,4 +40,4 @@
40
40
  "email": "isaced@163.com"
41
41
  },
42
42
  "homepage": "https://github.com/isaced/appstore-connect-sdk"
43
- }
43
+ }