@sp-api-sdk/product-pricing-api-v0 1.8.2 → 1.8.6
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
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
The Selling Partner API for Pricing helps you programmatically retrieve product pricing and offer information for Amazon Marketplace products.
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@sp-api-sdk/product-pricing-api-v0)
|
|
6
|
+
[](https://github.com/xojs/xo)
|
|
7
|
+
|
|
8
|
+
## Documentation
|
|
9
|
+
|
|
10
|
+
Learn more about this Selling Partner API by visiting the [official documentation](https://github.com/amzn/selling-partner-api-docs/tree/main/references/product-pricing-api/productPricingV0.md).
|
|
11
|
+
|
|
12
|
+
Also, see the [generated documentation](https://bizon.github.io/selling-partner-api-sdk/modules/_sp_api_sdk_product_pricing_api_v0.html) for this API client.
|
|
13
|
+
|
|
5
14
|
## Installing
|
|
6
15
|
|
|
7
16
|
```sh
|
|
@@ -19,26 +28,25 @@ import {SellingPartnerApiAuth} from '@sp-api-sdk/auth'
|
|
|
19
28
|
import {ProductPricingApiClient} from '@sp-api-sdk/product-pricing-api-v0'
|
|
20
29
|
|
|
21
30
|
const auth = new SellingPartnerApiAuth({
|
|
22
|
-
clientId:
|
|
23
|
-
clientSecret:
|
|
24
|
-
refreshToken: '',
|
|
25
|
-
secretAccessKey: '',
|
|
31
|
+
clientId: process.env.LWA_CLIENT_ID,
|
|
32
|
+
clientSecret: process.env.LWA_CLIENT_SECRET,
|
|
33
|
+
refreshToken: 'Atzr|…',
|
|
26
34
|
accessKeyId: '',
|
|
27
|
-
|
|
35
|
+
secretAccessKey: '',
|
|
28
36
|
role: {
|
|
29
|
-
arn: '',
|
|
30
|
-
}
|
|
37
|
+
arn: 'arn:aws:iam::…',
|
|
38
|
+
},
|
|
31
39
|
})
|
|
32
40
|
|
|
33
41
|
const client = new ProductPricingApiClient({
|
|
34
42
|
auth,
|
|
35
|
-
region: 'eu'
|
|
43
|
+
region: 'eu',
|
|
36
44
|
})
|
|
37
45
|
```
|
|
38
46
|
|
|
39
|
-
##
|
|
47
|
+
## Rate Limiting
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
In order to retry rate limited requests (HTTP 429), you can configure the API client as such:
|
|
42
50
|
|
|
43
51
|
```javascript
|
|
44
52
|
const client = new ProductPricingApiClient({
|
|
@@ -46,13 +54,28 @@ const client = new ProductPricingApiClient({
|
|
|
46
54
|
region: 'eu',
|
|
47
55
|
rateLimiting: {
|
|
48
56
|
retry: true,
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
// Optionally specify a callback that will be called on every retry.
|
|
58
|
+
onRetry: (retryInfo) => {
|
|
59
|
+
console.log(retryInfo)
|
|
60
|
+
},
|
|
61
|
+
},
|
|
51
62
|
})
|
|
52
63
|
```
|
|
53
64
|
|
|
54
|
-
The
|
|
65
|
+
The rate limits used for each route are specified in the [API documentation]((https://github.com/amzn/selling-partner-api-docs/tree/main/references/product-pricing-api/productPricingV0.md)).
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT
|
|
55
70
|
|
|
56
|
-
##
|
|
71
|
+
## Miscellaneous
|
|
57
72
|
|
|
58
|
-
|
|
73
|
+
```
|
|
74
|
+
╚⊙ ⊙╝
|
|
75
|
+
╚═(███)═╝
|
|
76
|
+
╚═(███)═╝
|
|
77
|
+
╚═(███)═╝
|
|
78
|
+
╚═(███)═╝
|
|
79
|
+
╚═(███)═╝
|
|
80
|
+
╚═(███)═╝
|
|
81
|
+
```
|
package/dist/cjs/src/client.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProductPricingApiClient = exports.
|
|
3
|
+
exports.ProductPricingApiClient = exports.clientRateLimits = void 0;
|
|
4
4
|
/* eslint-disable prefer-regex-literals */
|
|
5
5
|
const common_1 = require("@sp-api-sdk/common");
|
|
6
6
|
const api_model_1 = require("./api-model");
|
|
7
7
|
const error_1 = require("./error");
|
|
8
|
-
exports.
|
|
8
|
+
exports.clientRateLimits = [
|
|
9
9
|
{
|
|
10
10
|
method: 'get',
|
|
11
11
|
urlRegex: new RegExp('^/products/pricing/v0/price$'),
|
|
@@ -33,20 +33,23 @@ exports.RATE_LIMITS = [
|
|
|
33
33
|
];
|
|
34
34
|
class ProductPricingApiClient extends api_model_1.ProductPricingApi {
|
|
35
35
|
constructor(parameters) {
|
|
36
|
-
const
|
|
36
|
+
const config = common_1.sellingPartnerRegions[parameters.region];
|
|
37
|
+
if (!config) {
|
|
38
|
+
throw new error_1.ProductPricingApiError(`Unknown region: ${parameters.region}`);
|
|
39
|
+
}
|
|
37
40
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
38
|
-
const axiosParameters = {
|
|
41
|
+
const axiosParameters = {
|
|
42
|
+
...clientParameters,
|
|
43
|
+
region: config.awsRegion,
|
|
44
|
+
};
|
|
39
45
|
if (rateLimiting?.retry) {
|
|
40
|
-
axiosParameters.rateLimits = exports.
|
|
46
|
+
axiosParameters.rateLimits = exports.clientRateLimits;
|
|
41
47
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
42
48
|
}
|
|
43
49
|
const axiosInstance = (0, common_1.createAxiosInstance)(axiosParameters);
|
|
44
50
|
const configuration = new api_model_1.Configuration();
|
|
45
51
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
46
|
-
const endpoint =
|
|
47
|
-
if (!endpoint) {
|
|
48
|
-
throw new error_1.ProductPricingApiError(`Unknown region : ${region}`);
|
|
49
|
-
}
|
|
52
|
+
const endpoint = config.endpoints[environment];
|
|
50
53
|
super(configuration, endpoint, axiosInstance);
|
|
51
54
|
}
|
|
52
55
|
}
|
package/dist/es/src/client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable prefer-regex-literals */
|
|
2
|
-
import {
|
|
2
|
+
import { sellingPartnerRegions, createAxiosInstance } from '@sp-api-sdk/common';
|
|
3
3
|
import { Configuration, ProductPricingApi } from './api-model';
|
|
4
4
|
import { ProductPricingApiError } from './error';
|
|
5
|
-
export const
|
|
5
|
+
export const clientRateLimits = [
|
|
6
6
|
{
|
|
7
7
|
method: 'get',
|
|
8
8
|
urlRegex: new RegExp('^/products/pricing/v0/price$'),
|
|
@@ -30,20 +30,23 @@ export const RATE_LIMITS = [
|
|
|
30
30
|
];
|
|
31
31
|
export class ProductPricingApiClient extends ProductPricingApi {
|
|
32
32
|
constructor(parameters) {
|
|
33
|
-
const
|
|
33
|
+
const config = sellingPartnerRegions[parameters.region];
|
|
34
|
+
if (!config) {
|
|
35
|
+
throw new ProductPricingApiError(`Unknown region: ${parameters.region}`);
|
|
36
|
+
}
|
|
34
37
|
const { rateLimiting, ...clientParameters } = parameters;
|
|
35
|
-
const axiosParameters = {
|
|
38
|
+
const axiosParameters = {
|
|
39
|
+
...clientParameters,
|
|
40
|
+
region: config.awsRegion,
|
|
41
|
+
};
|
|
36
42
|
if (rateLimiting?.retry) {
|
|
37
|
-
axiosParameters.rateLimits =
|
|
43
|
+
axiosParameters.rateLimits = clientRateLimits;
|
|
38
44
|
axiosParameters.onRetry = rateLimiting.onRetry;
|
|
39
45
|
}
|
|
40
46
|
const axiosInstance = createAxiosInstance(axiosParameters);
|
|
41
47
|
const configuration = new Configuration();
|
|
42
48
|
const environment = parameters.sandbox ? 'sandbox' : 'production';
|
|
43
|
-
const endpoint = endpoints[environment]
|
|
44
|
-
if (!endpoint) {
|
|
45
|
-
throw new ProductPricingApiError(`Unknown region : ${region}`);
|
|
46
|
-
}
|
|
49
|
+
const endpoint = config.endpoints[environment];
|
|
47
50
|
super(configuration, endpoint, axiosInstance);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -317,7 +317,7 @@ export declare class ProductPricingApi extends BaseAPI {
|
|
|
317
317
|
* @throws {RequiredError}
|
|
318
318
|
* @memberof ProductPricingApi
|
|
319
319
|
*/
|
|
320
|
-
getCompetitivePricing(requestParameters: ProductPricingApiGetCompetitivePricingRequest, options?: any): Promise<import("axios").AxiosResponse<GetPricingResponse>>;
|
|
320
|
+
getCompetitivePricing(requestParameters: ProductPricingApiGetCompetitivePricingRequest, options?: any): Promise<import("axios").AxiosResponse<GetPricingResponse, any>>;
|
|
321
321
|
/**
|
|
322
322
|
* Returns the lowest priced offers for a single item based on ASIN. **Usage Plans:** | Plan type | Rate (requests per second) | Burst | | ---- | ---- | ---- | |Default| 5 | 10 | |Selling partner specific| Variable | Variable | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
323
323
|
* @param {ProductPricingApiGetItemOffersRequest} requestParameters Request parameters.
|
|
@@ -325,7 +325,7 @@ export declare class ProductPricingApi extends BaseAPI {
|
|
|
325
325
|
* @throws {RequiredError}
|
|
326
326
|
* @memberof ProductPricingApi
|
|
327
327
|
*/
|
|
328
|
-
getItemOffers(requestParameters: ProductPricingApiGetItemOffersRequest, options?: any): Promise<import("axios").AxiosResponse<GetOffersResponse>>;
|
|
328
|
+
getItemOffers(requestParameters: ProductPricingApiGetItemOffersRequest, options?: any): Promise<import("axios").AxiosResponse<GetOffersResponse, any>>;
|
|
329
329
|
/**
|
|
330
330
|
* Returns the lowest priced offers for a single SKU listing. **Usage Plans:** | Plan type | Rate (requests per second) | Burst | | ---- | ---- | ---- | |Default| 5 | 10 | |Selling partner specific| Variable | Variable | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
331
331
|
* @param {ProductPricingApiGetListingOffersRequest} requestParameters Request parameters.
|
|
@@ -333,7 +333,7 @@ export declare class ProductPricingApi extends BaseAPI {
|
|
|
333
333
|
* @throws {RequiredError}
|
|
334
334
|
* @memberof ProductPricingApi
|
|
335
335
|
*/
|
|
336
|
-
getListingOffers(requestParameters: ProductPricingApiGetListingOffersRequest, options?: any): Promise<import("axios").AxiosResponse<GetOffersResponse>>;
|
|
336
|
+
getListingOffers(requestParameters: ProductPricingApiGetListingOffersRequest, options?: any): Promise<import("axios").AxiosResponse<GetOffersResponse, any>>;
|
|
337
337
|
/**
|
|
338
338
|
* Returns pricing information for a seller\'s offer listings based on seller SKU or ASIN. **Usage Plans:** | Plan type | Rate (requests per second) | Burst | | ---- | ---- | ---- | |Default| 10 | 20 | |Selling partner specific| Variable | Variable | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
|
339
339
|
* @param {ProductPricingApiGetPricingRequest} requestParameters Request parameters.
|
|
@@ -341,5 +341,5 @@ export declare class ProductPricingApi extends BaseAPI {
|
|
|
341
341
|
* @throws {RequiredError}
|
|
342
342
|
* @memberof ProductPricingApi
|
|
343
343
|
*/
|
|
344
|
-
getPricing(requestParameters: ProductPricingApiGetPricingRequest, options?: any): Promise<import("axios").AxiosResponse<GetPricingResponse>>;
|
|
344
|
+
getPricing(requestParameters: ProductPricingApiGetPricingRequest, options?: any): Promise<import("axios").AxiosResponse<GetPricingResponse, any>>;
|
|
345
345
|
}
|
|
@@ -62,4 +62,4 @@ export declare const toPathString: (url: URL) => string;
|
|
|
62
62
|
*
|
|
63
63
|
* @export
|
|
64
64
|
*/
|
|
65
|
-
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration | undefined) => (axios?: AxiosInstance, basePath?: string) => Promise<import("axios").AxiosResponse<any>>;
|
|
65
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration | undefined) => (axios?: AxiosInstance, basePath?: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ClientConfiguration, RateLimit } from '@sp-api-sdk/common';
|
|
1
|
+
import type { ClientConfiguration, SellingPartnerRegion, RateLimit, OnRetryHandler } from '@sp-api-sdk/common';
|
|
3
2
|
import { ProductPricingApi } from './api-model';
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const clientRateLimits: RateLimit[];
|
|
5
4
|
export interface ClientParameters extends Omit<ClientConfiguration, 'rateLimits' | 'onRetry'> {
|
|
5
|
+
region: SellingPartnerRegion;
|
|
6
6
|
rateLimiting?: {
|
|
7
7
|
retry: boolean;
|
|
8
|
-
onRetry?:
|
|
8
|
+
onRetry?: OnRetryHandler;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
export declare class ProductPricingApiClient extends ProductPricingApi {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sp-api-sdk/product-pricing-api-v0",
|
|
3
3
|
"author": "Vincent Mesquita <vincent.mesquita@bizon.solutions>",
|
|
4
4
|
"description": "The Selling Partner API for Pricing helps you programmatically retrieve product pricing and offer information for Amazon Marketplace products.",
|
|
5
|
-
"version": "1.8.
|
|
5
|
+
"version": "1.8.6",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
7
7
|
"module": "dist/es/index.js",
|
|
8
8
|
"types": "dist/types/index.d.ts",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"test": "NODE_ENV='test' yarn jest"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@sp-api-sdk/auth": "^1.9.
|
|
29
|
-
"@sp-api-sdk/common": "^1.7.
|
|
30
|
-
"axios": "^0.
|
|
28
|
+
"@sp-api-sdk/auth": "^1.9.7",
|
|
29
|
+
"@sp-api-sdk/common": "^1.7.9",
|
|
30
|
+
"axios": "^0.24.0"
|
|
31
31
|
},
|
|
32
32
|
"repository": {
|
|
33
33
|
"type": "git",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"sp sdk",
|
|
49
49
|
"product pricing api"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "dd52e8a895f590c62d06f19f4d8715eb7740df66"
|
|
52
52
|
}
|