@amazon-sp-api-release/amazon-sp-api-sdk-js 1.0.0-rc2 → 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,4 +1,112 @@
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)
1
3
 
4
+ <!-- youtube video is under creating -->
5
+ <!-- [![Video Thumbnail](docs/video-thumbnail.png)](https://www.youtube.com/watch?v=OmYTAA80V_4)
2
6
 
7
+ *Click on the image to watch the video.* -->
8
+
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.
10
+
11
+ * [Learn more about Selling Partner API](https://developer.amazonservices.com/)
12
+ * [Selling Partner API Documentation](https://developer-docs.amazon.com/sp-api/)
13
+
14
+ ### Getting started
15
+
16
+ #### Credentials
17
+
18
+ Before you can use the SDK, you need to be registered as a Selling Partner API developer. If you haven't done that yet, please follow the instructions in the [SP-API Registration Overview](https://developer-docs.amazon.com/sp-api/docs/sp-api-registration-overview).
19
+ You also need to register your application to get valid credentials to call SP-API. If you haven't done that yet, please follow the instructions in [Registering your Application](https://developer-docs.amazon.com/sp-api/docs/registering-your-application).
20
+ If you are already registered successfully, you can find instructions on how to view your credentials in [Viewing your Application Information and Credentials](https://developer-docs.amazon.com/sp-api/docs/viewing-your-application-information-and-credentials).
21
+
22
+ #### Minimum requirements
23
+
24
+ To run the SDK you need Node version 14 or higher.
25
+
26
+ #### Install the SDK
27
+
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 [npm](#using-npm), [yarn](#using-yarn) and [Add as an package dependency](#add-as-an-package-dependency) below).
30
+
31
+
32
+ ##### Using npm:
33
+ ```bash
34
+ npm install @amazon-sp-api-release/amazon-sp-api-sdk-js
35
+ ```
36
+
37
+ ##### Using yarn:
38
+ ```bash
39
+ yarn add @amazon-sp-api-release/amazon-sp-api-sdk-js
40
+ ```
41
+
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"
46
+ ```
47
+
48
+ ### Use the SDK
49
+
50
+ In order to call one of the APIs included in the Selling Partner API, you need to:
51
+ 1. Configure credentials (Note: Use your individual credentials for `clientId`, `clientSecret` and `refreshToken`)
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.
54
+ 3. Call an operation
55
+
56
+ For an example, refer to the following sample code for connecting to Sellers API:
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';
97
+ ```
98
+
99
+ ### Additional documentation
100
+
101
+ For detailed API documentation and examples, please refer to our [API Reference](https://developer-docs.amazon.com/sp-api/docs/sp-api-reference).
102
+
103
+ ### Giving Feedback
104
+
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:
106
+
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
108
+ Articulate your feature request or upvote existing ones on our [Issues][sdk-issues] page
109
+
110
+ [sdk-issues]: https://github.com/amzn/selling-partner-api-sdk-js/issues
3
111
 
4
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-rc2",
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(