@amazon-sp-api-release/amazon-sp-api-sdk-js 1.0.0-rc1 → 1.0.0-rc3

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,15 +1,15 @@
1
- ## Java SDK for Selling Partner API
2
- [![Maven](https://img.shields.io/maven-central/v/software.amazon.spapi/spapi-sdk.svg?label=Maven)](https://central.sonatype.com/artifact/software.amazon.spapi/spapi-sdk)
1
+ ## JavaScript SDK for Selling Partner API
2
+ [![npm version](https://badge.fury.io/js/@amazon-sp-api-release%2Famazon-sp-api-sdk-js.svg)](https://www.npmjs.com/package/@amazon-sp-api-release/amazon-sp-api-sdk-js)
3
3
 
4
- [![Video Thumbnail](docs/video-thumbnail.png)](https://www.youtube.com/watch?v=OmYTAA80V_4)
4
+ <!-- youtube video is under creating -->
5
+ <!-- [![Video Thumbnail](docs/video-thumbnail.png)](https://www.youtube.com/watch?v=OmYTAA80V_4)
5
6
 
6
- *Click on the image to watch the video.*
7
+ *Click on the image to watch the video.* -->
7
8
 
8
- The Selling Partner API SDK for Java enables you to easily connect your Java application to Amazon's REST-based Selling Partner API.
9
+ The Selling Partner API SDK for JavaScript enables you to easily connect your JavaScript/Node.js application to Amazon's REST-based Selling Partner API.
9
10
 
10
11
  * [Learn more about Selling Partner API](https://developer.amazonservices.com/)
11
12
  * [Selling Partner API Documentation](https://developer-docs.amazon.com/sp-api/)
12
- * [JavaDoc](https://www.javadoc.io/doc/software.amazon.spapi/spapi-sdk/latest/index.html)
13
13
 
14
14
  ### Getting started
15
15
 
@@ -21,79 +21,92 @@ If you are already registered successfully, you can find instructions on how to
21
21
 
22
22
  #### Minimum requirements
23
23
 
24
- To run the SDK you need Java 11 or higher.
24
+ To run the SDK you need Node version 14 or higher.
25
25
 
26
- #### Integrate the SDK
26
+ #### Install the SDK
27
27
 
28
28
  1. Find the latest version number [here](https://github.com/amzn/selling-partner-api-sdk/releases).
29
- 2. Add the dependency to your project (see instructions for [Gradle](#gradle) and [Maven](#maven) below).
29
+ 2. Add the dependency to your project (see instructions for [npm](#using-npm), [yarn](#using-yarn) and [Add as an package dependency](#add-as-an-package-dependency) below).
30
30
 
31
- ##### Gradle
32
31
 
33
- Add the following line to the dependencies in your `build.gradle` file:
34
-
35
- ```
36
- implementation 'software.amazon.spapi:spapi-sdk:0.1.0'
32
+ ##### Using npm:
33
+ ```bash
34
+ npm install @amazon-sp-api-release/amazon-sp-api-sdk-js
37
35
  ```
38
36
 
39
- ##### Maven
40
-
41
- Add the following lines to the dependencies in your `maven.pom` file:
37
+ ##### Using yarn:
38
+ ```bash
39
+ yarn add @amazon-sp-api-release/amazon-sp-api-sdk-js
40
+ ```
42
41
 
43
- ```xml
44
- <dependencies>
45
- ...
46
- <dependency>
47
- <groupId>software.amazon.spapi</groupId>
48
- <artifactId>spapi-sdk</artifactId>
49
- <version>0.1.0</version>
50
- </dependency>
51
- ...
52
- </dependencies>
42
+ ##### Add as an package dependency
43
+ Add the following line to the `dependencies` in your `package.json` file:
44
+ ```bash
45
+ "@amazon-sp-api-release/amazon-sp-api-sdk-js": "^1.0.0"
53
46
  ```
54
47
 
55
48
  ### Use the SDK
56
49
 
57
50
  In order to call one of the APIs included in the Selling Partner API, you need to:
58
51
  1. Configure credentials (Note: Use your individual credentials for `clientId`, `clientSecret` and `refreshToken`)
59
- 2. Create an instance for a specific API
52
+ 2. Retrieve `accessToken` using our `LwaAuthClient` helper (Be aware for some APIs, you will need extra step to get `RDT Token`)
53
+ 2. Create an instance for a specific API and API client, then apply `accessToken` to it.
60
54
  3. Call an operation
61
55
 
62
56
  For an example, refer to the following sample code for connecting to Sellers API:
63
- ```java
64
- // Configure your LWA credentials
65
- LWAAuthorizationCredentials lwaAuthorizationCredentials = LWAAuthorizationCredentials.builder()
66
- .clientId("amzn1.application-*********************")
67
- .clientSecret("***********************************")
68
- .refreshToken("Atzr|******************************")
69
- .endpoint("https://api.amazon.com/auth/o2/token")
70
- .build();
71
-
72
- // Create an instance of the Sellers API
73
- SellersApi sellersApi = new SellersApi.Builder()
74
- .lwaAuthorizationCredentials(lwaAuthorizationCredentials)
75
- .endpoint("https://sellingpartnerapi-na.amazon.com") // use Sandbox URL here if you would like to test your applications without affecting production data.
76
- .build();
77
-
78
- // Call operation
79
- GetMarketplaceParticipationsResponse result = sellersApi.getMarketplaceParticipations();
57
+
58
+ ```javascript
59
+ import { LwaAuthClient } from '@amazon-sp-api-release/amazon-sp-api-sdk-js/src/helper/LwaAuthClient.mjs';
60
+
61
+ import {
62
+ SellersApi,
63
+ ApiClient as SellersApiClient,
64
+ } from '@amazon-sp-api-release/amazon-sp-api-sdk-js/sdk/sellers_v1/src/index.js';
65
+
66
+ (async () => {
67
+ const lwaClient = new LwaAuthClient(
68
+ '<YOUR_CLIENT_ID>',
69
+ '<YOUR_CLIENT_SECRET>',
70
+ '<YOUR_REFRESH_TOKEN>'
71
+ );
72
+ const sellerApiClient = new SellersApiClient(
73
+ 'https://sellingpartnerapi-na.amazon.com'
74
+ );
75
+
76
+ const sellerApi = new SellersApi(sellerApiClient);
77
+ sellerApiClient.applyXAmzAccessTokenToRequest(
78
+ await lwaClient.getAccessToken()
79
+ );
80
+ const participations = await sellerApi.getMarketplaceParticipations();
81
+ console.log(
82
+ JSON.stringify(participations, null, ' ') +
83
+ '\n**********************************'
84
+ );
85
+ })();
86
+ ```
87
+
88
+ Alternatively, you can go to `@amazon-sp-api-release/amazon-sp-api-sdk-js/src/sample-node-app` and copy over and modify `index.js` and `app.config.mjs` files and give them a try.
89
+
90
+ ##### Additional Note:
91
+ This Amazon Selling Partner API JavaScript SDK is fully compatible with ECMAScript modules (ESM). You can use modern ES6+ import/export syntax as demonstrated in the example code:
92
+
93
+ ```javascript
94
+ import {
95
+ SellersApi,
96
+ } from '@amazon-sp-api-release/amazon-sp-api-sdk-js/sdk/sellers_v1/src/index.js';
80
97
  ```
81
98
 
82
99
  ### Additional documentation
83
100
 
84
- You can find the JavaDoc for the latest SDK version [here](https://www.javadoc.io/doc/software.amazon.spapi/spapi-sdk/latest/index.html).
101
+ For detailed API documentation and examples, please refer to our [API Reference](https://developer-docs.amazon.com/sp-api/docs/sp-api-reference).
85
102
 
86
103
  ### Giving Feedback
87
104
 
88
105
  We need your help in making this SDK great. Please participate in the community and contribute to this effort by submitting issues, participating in discussion forums and submitting pull requests through the following channels:
89
106
 
90
- Submit [issues](https://github.com/amzn/selling-partner-api-sdk/issues/new/choose) - this is the preferred channel to interact with our team
107
+ Submit [issues](https://github.com/amzn/selling-partner-api-sdk-js/issues/new/choose) - this is the preferred channel to interact with our team
91
108
  Articulate your feature request or upvote existing ones on our [Issues][sdk-issues] page
92
109
 
93
- [sdk-issues]: https://github.com/amzn/selling-partner-api-sdk/issues
94
-
95
-
96
-
97
-
110
+ [sdk-issues]: https://github.com/amzn/selling-partner-api-sdk-js/issues
98
111
 
99
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amazon-sp-api-release/amazon-sp-api-sdk-js",
3
- "version": "1.0.0-rc1",
3
+ "version": "1.0.0-rc3",
4
4
  "type": "module",
5
5
  "description": "This package is sellingpartnerAPI Javascript SDK for nodeJS with LWA library.",
6
6
  "main": "index.js",
@@ -0,0 +1,5 @@
1
+ export const AppConfig = {
2
+ lwaClientId: '<YOUR_CLIENT_ID>',
3
+ lwaClientSecret: '<YOUR_CLIENT_SECRET>',
4
+ lwaRefreshToken: '<YOUR_REFRESH_TOKEN>',
5
+ }
@@ -1,10 +1,10 @@
1
1
  import { AppConfig } from './app.config.mjs';
2
- import { LwaAuthClient } from 'amazon-sp-api-sdk-js/src/helper/LwaAuthClient.mjs';
2
+ import { LwaAuthClient } from '@amazon-sp-api-release/amazon-sp-api-sdk-js/src/helper/LwaAuthClient.mjs';
3
3
 
4
4
  import {
5
5
  SellersApi,
6
6
  ApiClient as SellersApiClient,
7
- } from 'amazon-sp-api-sdk-js/sdk/sellers_v1/src/index.js';
7
+ } from '@amazon-sp-api-release/amazon-sp-api-sdk-js/sdk/sellers_v1/src/index.js';
8
8
 
9
9
  (async () => {
10
10
  const lwaClient = new LwaAuthClient(