Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

amazon-sp-api

amz-tools38.8kMIT1.1.6TypeScript support: included

Amazon Selling Partner API client

amazon, sellingpartner, sp, sellercentral, amazon sellingpartner api, amazon sp api, selling partner, amazon sp api client, amazon selling partner, amazon selling partner api, mws, amazon mws

readme

amazon-sp-api (client for the Amazon Selling Partner API)

The client handles calls to the Amazon Selling Partner API. It wraps up all the necessary stuff such as requesting access tokens and providing (a simplified!) way of calling the API, but also provides some convenience, i.e. a wrapper for requesting and downloading reports and an internal handling of rate limits when calls are throttled.

- Please note: There are a few breaking changes if you are
- upgrading from version 0.x.x to 1.x.x. Please see the link below.

List of breaking changes when upgrading to version 1.x.x

Contents

Prerequisites

Make sure that you followed the Selling Partner API Developer Guide and have successfully completed the steps Registering as a developer, Registering your application and have a valid refresh token (if you use the client only for your own seller account the easiest way is using the self authorization as described in the developer guide).

Installation

npm install amazon-sp-api

Getting Started

Before you can use the client you need to add your app client and secret.

Setting credentials from environment variables

Setting credentials from file

Instead of setting the credentials via environment variables you may load them from a credentials file. The default path to the file is ~/.amzspapi/credentials (path can be changed when creating a client) and you add the credentials one per line:

SELLING_PARTNER_APP_CLIENT_ID=<YOUR_APP_CLIENT_ID>
SELLING_PARTNER_APP_CLIENT_SECRET=<YOUR_APP_CLIENT_SECRET>

Setting credentials from constructor config object

Although the most convenient and recommended way of setting the credentials is via environment variables or config file it is also possible to pass the credentials inside the config object when creating an instance of the client (i.e. if you have no means of using env vars or a config file). The structure of the constructor config object will be explained below.

Usage

Require library:

// commonjs
const SellingPartner = require('amazon-sp-api');

// esm
import {SellingPartner} from 'amazon-sp-api';

Create client and call API:

(async () => {
  try {
    const spClient = new SellingPartner({
      region: 'eu', // The region to use for the SP-API endpoints ("eu", "na" or "fe")
      refresh_token: '<REFRESH_TOKEN>' // The refresh token of your app user
    });
    let res = await spClient.callAPI({
      operation: 'getMarketplaceParticipations',
      endpoint: 'sellers'
    });
    console.log(res);
  } catch (e) {
    console.log(e);
  }
})();

Config params

The class constructor takes a config object with the following structure as input:

{
  region:'<REGION>',
  refresh_token:'<REFRESH_TOKEN>',
  access_token:'<ACCESS_TOKEN>',
  endpoints_versions:{
    ...
  },
  credentials:{
    SELLING_PARTNER_APP_CLIENT_ID:'<APP_CLIENT_ID>',
    SELLING_PARTNER_APP_CLIENT_SECRET:'<APP_CLIENT_SECRET>'
  },
  options:{
    credentials_path:'~/.amzspapi/credentials',
    auto_request_tokens:true,
    auto_request_throttled:true,
    version_fallback:true,
    use_sandbox:false,
    only_grantless_operations:false,
    user_agent:'amazon-sp-api/<CLIENT_VERSION> (Language=Node.js/<NODE_VERSION>; Platform=<OS_PLATFORM>/<OS_RELEASE>)',
    debug_log:false,
    timeouts:{
      ...
    },
    retry_remote_timeout:true,
    https_proxy_agent:<HttpsProxyAgent>
  }
}

Valid properties of the config object:

Name Type Default Description
region
required
string - The region to use for the SP-API endpoints.
Must be one of: eu, na or fe
refresh_token
optional
string - The refresh token of your app user.
Required if only_grantless_operations option is set to false.
access_token
optional
string - The temporary access token requested with the refresh token of the app user.
endpoints_versions
optional
object - Defines the version to use for an endpoint as key/value pairs, i.e. "reports":"2021-06-30". If none given the client is using the first (meaning the oldest) version for an endpoint.
Call .endpoints on class instance to retrieve a complete list of all endpoints, versions and operations supported by the client.
credentials
optional
object - The app client credentials. Must include the two credentials properties SELLING_PARTNER_APP_CLIENT_ID and SELLING_PARTNER_APP_CLIENT_SECRET
NOTE: Should only be used if you have no means of using environment vars or credentials file!
options
optional
object - Additional options, see table below for all possible options properties.

Valid properties of the config options:

Name Type Default Description
credentials_path
optional
string ~/.amzspapi/credentials A custom absolute path to your credentials file location.
auto_request_tokens
optional
boolean true Whether or not the client should retrieve new access token if non given or expired.
auto_request_throttled
optional
boolean true Whether or not the client should automatically retry a request when throttled.
version_fallback
optional
boolean true Whether or not the client should try to use an older version of an endpoint if the operation is not defined for the desired version.
use_sandbox
optional
boolean false Whether or not to use the sandbox endpoint.
only_grantless_operations
optional
boolean false Whether or not to only use grantless operations.
user_agent
optional
string amazon-sp-api/<CLIENT_VERSION> (Language=Node.js/<NODE_VERSION>; Platform=<OS_PLATFORM>/<OS_RELEASE>) A custom user-agent header (see desired format in docs).
debug_log
optional
boolean false Whether or not the client should print console logs for debugging purposes.
timeouts
optional
object - Allows to set timeouts for requests. Valid keys are response, idle and deadline. Please see detailed information in the Timeouts section.
retry_remote_timeout
optional
boolean true Whether or not the client should retry a request to the remote server that failed with an ETIMEDOUT error
https_proxy_agent
optional
object - Possibility to add your own HTTPS Proxy Agent. Please see detailed information in the Using Proxy Agent section.

Use a proxy agent

If you are behind a firewall and would like to use a proxy server then you can pass a custom proxy agent to the options object. See the following example:

const {HttpsProxyAgent} = require('hpagent');
const agent = new HttpsProxyAgent({proxy: 'http://x.x.x.x:zzzz'});
const spClient = new SellingPartner({
  region: 'eu',
  refresh_token: '<REFRESH_TOKEN>',
  options: {
    https_proxy_agent: agent
  }
});

Exchange an authorization code for a refresh token

If you already have a refresh token you can skip this step. If you only want to use the API for your own seller account you can just use the self authorization to obtain a valid refresh token.

If you want to exchange an authorization code of a seller you can use the .exchange() function of the client. The neccessary authorization code is returned to your callback URI as spapi_oauth_code when a seller authorizes your application (see authorization workflow in docs).

Once you have obtained the authorization_code you can exchange it for a refresh token:

const spClient = new SellingPartner({
  region: 'eu',
  options: {
    only_grantless_operations: true
  }
});
let res = await spClient.exchange('<SELLER_AUTHORIZATION_CODE>');
console.log(res.refresh_token);

NOTE: You will have to create a new class instance once you have obtained the refresh_token and pass it inside the constructor in order to make calls to the API.

Request access token

If you only provide the region and refresh_token parameters the client will automatically request an access_token for you (with a TTL of 1 hour) and reuse it for future api calls for the class instance.

Instead of having the client handle the access_token requests automatically, you may also refresh them manually:

const spClient = new SellingPartner({
  region: 'eu',
  refresh_token: '<REFRESH_TOKEN>',
  options: {
    auto_request_tokens: false
  }
});
await spClient.refreshAccessToken();

If you want to use the same credentials for multiple instances you can retrieve them via getters and use them as input for a new instance:

let access_token = spClient.access_token;

const spClient = new SellingPartner({
  region: 'eu',
  refresh_token: '<REFRESH_TOKEN>',
  access_token: access_token
});

Call the API

All calls to the SP-API will be triggered by using the .callAPI() function, which takes an object with the following structure as input:

{
  operation:'<OPERATION_TO_CALL>',
  endpoint:'<ENDPOINT_OF_OPERATION>',
  path:{
    ...
  },
  query:{
    ...
  },
  body:{
    ...
  },
  api_path:'<FULL_PATH_OF_OPERATION>',
  method:'GET',
  headers:{
    ...
  },
  restricted_data_token:'<RESTRICTED_DATA_TOKEN>',
  options:{
    version:'<OPERATION_ENDPOINT_VERSION>',
    restore_rate:'<RESTORE_RATE_IN_SECONDS>',
    raw_result:false,
    timeouts:{
      ...
    }
  }
}

Valid properties of the object:

Name Type Default Description
operation
optional
string - The operation you want to request, see SP API Developer Guide.
May also include endpoint as shorthand dot notation.
Call .endpoints on class instance to retrieve a complete list of all endpoints, versions and operations supported by the client.
Required if api_path is not defined.
endpoint
optional
string - The endpoint of the operation, (see Endpoints).
Call .endpoints on class instance to retrieve a complete list of all endpoints, versions and operations supported by the client.
Required if endpoint is not part of operation as shorthand dot notation and api_path is not defined.
path
optional
object - The input paramaters added to the path of the operation.
query
optional
object - The input paramaters added to the query string of the operation.
body
optional
object - The input paramaters added to the body of the operation.
api_path
optional
string - The full api path of an operation. Can be used to call operations that are not yet supported or have a new version that is not yet supported by the client.
Required if operation is not defined.
method
optional
string - The HTTP method to use.
Required only if api_path is defined.
Must be one of: GET, POST, PUT,DELETE or PATCH.
headers
optional
object - Additional headers that will be added to the call.
restricted_data_token
optional
string - A token received from a createRestrictedDataToken operation. Neccessary to include PII (Personally Identifiable Informaton) for some restricted operations, see Tokens API use case guide for a list of restricted operations.
NOTE: Your developer account must be approved for PII by Amazon in order to be able to receive PII, otherwise the token will have no effect, meaning the result of restricted operations will not include PII.
options
optional
object - Additional options, see table below for all possible options properties.

Valid properties of the config options:

Name Type Default Description
version
optional
string - The endpoint's version that should be used when calling the operation. Will be preferred over an endpoints_versions setting.
NOTE: The call might still use an older version of the endpoint if the operation is not available for the specified version and version_fallback is set to true.
restore_rate
optional
number - The restore rate (in seconds) that should be used when calling the operation. Will be preferred over the default restore rate of the operation.
raw_result
optional
boolean false Whether or not the client should return the "raw" result, which will include the raw body, buffer chunks, statuscode and headers of the result and also the request object with method, hostname, path, headers and body of the request.
NOTE: Setting raw_result to true will skip the internal formatting or error checking, but might be helpful when you need additional information besides the payload or when the client encounters JSON.parse errors.
timeouts
optional
object - Allows to set timeouts for requests. Valid keys are response, idle and deadline. Please see detailed information in the Timeouts section.

Examples

To call an operation of an API endpoint you pass in the operation and the endpoint it belongs to. See the following example:

let res = await spClient.callAPI({
  operation: 'getMarketplaceParticipations',
  endpoint: 'sellers'
});

Instead of using the endpoint property you may also prepend the endpoint to the operation as shorthand dot notation:

let res = await spClient.callAPI({
  operation: 'sellers.getMarketplaceParticipations'
});

Here are a few examples that use some more properties:

let res = await spClient.callAPI({
  operation: 'getOrderMetrics',
  endpoint: 'sales',
  query: {
    marketplaceIds: ['A1PA6795UKMFR9'],
    interval: '2020-10-01T00:00:00-07:00--2020-10-01T20:00:00-07:00',
    granularity: 'Hour'
  }
});
let res = await spClient.callAPI({
  operation: 'catalogItems.getCatalogItem',
  path: {
    asin: 'B084J4QQFT'
  },
  query: {
    marketplaceIds: ['A1PA6795UKMFR9']
  },
  options: {
    version: '2022-04-01'
  }
});
let res = await spClient.callAPI({
  operation: 'createReport',
  endpoint: 'reports',
  body: {
    reportType: 'GET_FLAT_FILE_OPEN_LISTINGS_DATA',
    marketplaceIds: ['A1PA6795UKMFR9']
  }
});
let res = await spClient.callAPI({
  operation: 'finances.listFinancialEvents',
  query: {
    PostedAfter: '2020-03-01T00:00:00-07:00',
    PostedBefore: '2020-03-02T00:00:00-07:00'
  },
  options: {
    raw_result: true
  }
});
try {
  let res = await spClient.callAPI({
    operation: 'getCompetitivePricing',
    endpoint: 'productPricing',
    query: {
      Asins: ['B00Z7T970I', 'B01BHHE9VK'],
      ItemType: 'Asin',
      MarketplaceId: 'A1PA6795UKMFR9'
    },
    options: {
      version: 'v0',
      raw_result: true,
      timeouts: {
        response: 5000,
        idle: 10000,
        deadline: 30000
      }
    }
  });
} catch (err) {
  if (err.code) {
    if (err.code === 'API_RESPONSE_TIMEOUT')
      console.log('SP-API ERROR: response timeout: ' + err.timeout + 'ms exceeded.', err.message);
    if (err.code === 'API_IDLE_TIMEOUT')
      console.log('SP-API ERROR: idle timeout: ' + err.timeout + 'ms exceeded.', err.message);
    if (err.code === 'API_DEADLINE_TIMEOUT')
      console.log('SP-API ERROR: deadline timeout: ' + err.timeout + 'ms exceeded.', err.message);
  }
}

Endpoints

The exact endpoint's name of an operation will be the references name (see SP API Developer Guide) without API and all spaces removed and continued with a capital letter. So the Catalog Items API endpoint's name will be catalogItems, Fulfillment Inbound API will be fulfillmentInbound, Sellers API will be sellers and so on. You can also retrieve the endpoint names and their operations and versions by calling spClient.endpoints.

Versions

Every operation belongs to an endpoint that consists of one or more versions and each version consists of one or more operations. You will find a complete list of the endpoints with all versions and operations in the SP API Developer Guide. For a complete list of all currently by the client supported endpoints with versions and operations you can just call spClient.endpoints.

Version specific operation implementations

The client uses the first (in fact the oldest) endpoint version if no version is provided since new versions of some operations are not backward compatible. So in order to prevent breaking changes we can't enable latest endpoint versions by default. I.e. the two different implementations of the getCatalogItem operation (see catalogItemsV0 vs. catalogItems_2020-12-01) expect different input parameters and return different results.

The implementation of the getCatalogItem operation in the v0 version expects an asin and a MarketplaceId as input:

let res = await spClient.callAPI({
  operation: 'getCatalogItem',
  endpoint: 'catalogItems',
  query: {
    MarketplaceId: 'A1PA6795UKMFR9'
  },
  path: {
    asin: 'B084DWG2VQ'
  },
  options: {
    version: 'v0'
  }
});

In contrast, the implementation of the getCatalogItem operation in the 2020-12-01 version expects an asin, a marketplaceIds array and an includedData array as input:

let res = await spClient.callAPI({
  operation: 'getCatalogItem',
  endpoint: 'catalogItems',
  query: {
    marketplaceIds: ['A1PA6795UKMFR9'],
    includedData: ['identifiers', 'images', 'productTypes', 'salesRanks', 'summaries', 'variations']
  },
  path: {
    asin: 'B084DWG2VQ'
  },
  options: {
    version: '2020-12-01'
  }
});

Trying to call the new 2020-12-01 version without explicitly setting it would result in an InvalidInput error as the required MarketplaceId parameter is missing.

Defining endpoints versions on class level

There are different ways of specifying the version to use for endpoints and their corresponding operations. You can specify the version directly inside the options object of the .callAPI() function as seen in the examples above. But you can also enable a newer version for all operations of an endpoint by using the endpoints_versions setting in the constructor config object. I.e. you can tell the class instance to use the new 2020-12-01 version for the catalogItems endpoint and thus enabling it for all operations of the endpoint throughout the class instance like this:

const spClient = new SellingPartner({
  region: 'eu',
  refresh_token: '<REFRESH_TOKEN>',
  endpoints_versions: {
    catalogItems: '2020-12-01'
  }
});

By doing so you can skip setting the version inside the options object each time when you are using .callAPI() with the new version of the getCatalogItem operation.

Fallback

If trying to call an operation that is not part of the endpoint's version you specified, the client will automatically try to find the operation in an earlier endpoint's version and use that implementation if version_fallback is set to true (which is the default). I.e. the listCatalogCategories operation is not part of the new catalogItems endpoint version. So if the new version was set as in the example code above, the following call would still work, because it will automatically fallback to the operation's implementation in version v0:

let res = await spClient.callAPI({
  operation: 'listCatalogCategories',
  endpoint: 'catalogItems',
  query: {
    MarketplaceId: 'A1PA6795UKMFR9',
    ASIN: 'B084DWG2VQ'
  }
});

Unsupported endpoints/versions/operations

The newest client version should always have full support for all endpoints, versions and operations on release, however it might lack support for very recently added new endpoints, versions or operations. If you need an endpoint/version/operation that is not yet supported you can still call it by using the api_path parameter. I.e. if the new catalogItems version 2020-12-01 would not be supported yet we could still use the new implementation of the getCatalogItem operation by using the api_path and method properties:

let res = await spClient.callAPI({
  api_path: '/catalog/2020-12-01/items/B084DWG2VQ',
  method: 'GET',
  query: {
    marketplaceIds: ['A1PA6795UKMFR9'],
    includedData: ['identifiers', 'images', 'productTypes', 'salesRanks', 'summaries', 'variations']
  }
});

NOTE: If your api_path includes special characters that require encoding (i.e. an SKU that contains UTF-8 characters) you will have to encode these characters manually before passing your api_path to .callAPI().

Grantless operations

Some operations don't require an explicit authorization by a seller, see list of grantless operations. A grantless operation needs another access token than other operations and as such a grantless token is NOT the access_token you can provide in the constructor config object. However if the auto_request_tokens option is set to true the client should handle everything for you.

If you do the token request manually you need to create a grantless token by calling refreshAccessToken with the scope of the corresponding endpoint. Currently there are only two different scopes: sellingpartnerapi::notifications for notifications endpoint and sellingpartnerapi::client_credential:rotation for application management endpoint.

If you don't need or have a refresh token you may use the client with the only_grantless_operations option set to true which allows you to create an instance of the client without a refresh_token.

To sum up, please see the following example that will return the destinations for your notifications.

First create a class instance that only allows to call grantless operations (no refresh_token included):

const spClient = new SellingPartner({
  region: 'eu',
  options: {
    auto_request_tokens: false,
    only_grantless_operations: true
  }
});

Then request a grantless token with the scope needed for the operation you want to call:

await spClient.refreshAccessToken('sellingpartnerapi::notifications');

Finally call the grantless operation:

let res = await spClient.callAPI({
  operation: 'getDestinations',
  endpoint: 'notifications'
});

Restore rates

If you set the auto_request_throttled option in the class constructor config object to true (which is the default), the client will automatically retry the call if its throttled. It will either use the restore rate from the result header field x-amzn-ratelimit-limit if given (see Usage Plans and Rate Limits), or the value of restore_rate option in .callAPI() function if given, or otherwise use the default restore rate of the operation. For testing purposes you can also set debug_log to true, which will trigger a console log every time the client retries a call. If you set auto_request_throttled to false the client will throw a QuotaExceeded error when a request is throttled.

NOTE: If you are using the same operation with the same seller account across multiple class instances the restore rate logic might NOT work correct or, even worse, result in an infinite quota exceeded loop. So if you're planning to do that you should probably set auto_request_throttled to false, catch the QuotaExceeded errors and handle the restore rate logic on your own.

Timeouts

You may set timeouts to stop requests, i.e. to prevent scripts from "hanging" forever because a request is not finishing. The three different timeout types are response, idle and deadline. You may set these inside the class constructor config options to be used for all requests started via .callAPI() or via the config options of the .callAPI() method for that specific call only. The latter will override the timeouts set via class config options.

NOTE: The .download() method will NOT use the timeouts defined in class constructor config options. You have to provide the timeouts to each .download() call inside its options object.

See the table below for valid properties of the timeouts object:

Name Type Default Description
response
optional
number - Timeout (in milliseconds) until a response timeout is fired. If exceeded the request will abort with an API_RESPONSE_TIMEOUT error. Response timeout is the time between sending the request and receiving the first byte of the response. Includes DNS and connection time.
idle
optional
number - Timeout (in milliseconds) until an idle timeout is fired. if exceeded the request will abort with an API_IDLE_TIMEOUT error. Idle is the time between receiving the last chunk of the reponse and waiting for the next chunk to be received. Might be fired if a request is stalled before finished (i.e. when internet connection is lost).
deadline
optional
number - Timeout (in milliseconds) until a deadline timeout is fired. If exceeded the request will abort with an API_DEADLINE_TIMEOUT error. Deadline is the time from the start of the request to receiving the response body in full. If the deadline is too short large responses may not load at all on slow connections.

Download reports

The easiest way of downloading a report is to use the .downloadReport() function that will wrap up all operations needed to request and retrieve a report in a single call. The function internally calls the operations createReport, getReport, getReportDocument and the .download() function that will download the final report document in sequence.

The function takes a config object with the following parameters as input:

Name Type Default Description
body
required
object - Includes the parameters necessary to request the report. These are the parameters usually passed in to the createReport operation (see createReport 2021-06-30). The possible values will be described below.
version
optional
string 2021-06-30 The report endpoint’s version that should be used when retrieving the report.
interval
optional
number 10000 The request interval (in milliseconds) that should be used for re-requesting the getReport operation when the report is still queued or in progress.
cancel_after
optional
number - Cancels a report request after the specified number of retries. Each re-request defined by the interval value counts as one retry.
download
optional
object - Includes optional parameters for the download of the report, i.e. to enable a json result or to additionally save the report to a file. The possible values will be described below.

The body object may include the following properties:

Name Type Default Description
reportType
required
string - The report type.
marketplaceIds
required
< string > array - A list of marketplace identifiers. The report document's contents will contain data for all of the specified marketplaces, unless the report type indicates otherwise.
dataStartTime
optional
string - The start of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this.
dataEndTime
optional
string - The end of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this.
reportOptions
optional
object - Additional information passed to reports. This varies by report type.

The download object may include the following properties:

Name Type Default Description
json
optional
boolean false Whether or not the content should be transformed to json before returning it (from tab delimited flat-file or XML).
unzip
optional
boolean true Whether or not the content should be unzipped before returning it.
file
optional
string - The absolute file path to save the report to.
NOTE: Even when saved to disk the report content is still returned.
charset
optional
string utf8 The charset to use for decoding the content. If not defined, it uses per default the charset returned in content-type header or utf8 if no charset found in content-type header.
NOTE: Is ignored when content is compressed and unzip is set to false.
timeouts
optional
object - Allows to set timeouts for download requests. Valid keys are response, idle and deadline. Please see detailed information in the Timeouts section.

Please see the following example that will request a GET_FLAT_FILE_OPEN_LISTINGS_DATA report for the current report endpoint version 2021-06-30, re-request it every 8 seconds and, once its finished, will download the report, transform it to json and save it to disk:

let res = await sellingPartner.downloadReport({
  body: {
    reportType: 'GET_FLAT_FILE_OPEN_LISTINGS_DATA',
    marketplaceIds: ['A1PA6795UKMFR9']
  },
  version: '2021-06-30',
  interval: 8000,
  download: {
    json: true,
    file: '<ABSOLUTE_FILE_PATH>/report.json'
  }
});

Instead of using the .downloadReport() function you may as well call the necessary operations on your own and use the .download() function to retrieve the final report data. Please see the following information below:

The .download() function takes the download details received from a getReportDocument operation as input, downloads the content, unzips it (if result is compressed), decrypts it and returns it.

Retrieve the download details from a getReportDocument operation:

let report_document = await spClient.callAPI({
  operation: 'getReportDocument',
  endpoint: 'reports',
  path: {
    reportDocumentId: '<REPORT_DOCUMENT_ID>' // retrieve the reportDocumentId from a "getReport" operation (when processingStatus of report is "DONE")
  }
});

The structure of the returned report_document should look like this:

{
  reportDocumentId:'<REPORT_DOCUMENT_ID>',
  compressionAlgorithm:'GZIP', // Only included if report is compressed
  url: '<REPORT_DOWNLOAD_URL>' // Expires after 5 minutes!
}

Call the .download() function to receive the content of the report. The default without any config options will download, decrypt and unzip the content and return it without reformatting or saving it to the disk:

let report = await spClient.download(report_document);

You may also include an options object as a 2nd parameter to the .download() function, i.e. to enable a json result or to additionally save the report to a file. The possible parameters are the same as for the download object for the .downloadReport() function already documented above.

The following call will download the report, transform it to json and save it to disk:

let report = await spClient.download(report_document, {
  json: true,
  file: '<ABSOLUTE_FILE_PATH>/report.json'
});

Some reports may have an encoding other than UTF-8 and require special decoding with a different charset, i.e. the GET_MERCHANT_LISTINGS_ALL_DATA report is encoded as cp1252 for eu region marketplaces. The right charset to use for decoding is taken from the return header content-type, but you may force the use of a specific charset for decoding by passing in the optional charset property:

let report = await spClient.download(report_document, {
  charset: 'cp1252'
});

Download reports as stream

If you have a very extensive report you may use the .downloadReportStream() function. Instead of returning the report content it will return a stream instance allowing you to retrieve the individual buffer chunks:

let resStream = await sellingPartner.downloadReportStream({
  body: {
    reportType: "GET_FLAT_FILE_OPEN_LISTINGS_DATA",
    marketplaceIds: ["A1PA6795UKMFR9"]
  },
  version: "2021-06-30",
  interval: 8000
});
resStream.on("data", (chunk) => {
  // Receiving buffer chunk
});
resStream.on("error", async (err) => {
  // Error while streaming
});
resStream.on("end", () => {
  // Stream finished
});

Please note: For the download object you may only use the unzip property, all other properties (json, file, charset, timeouts) are not available when downloading a report as a stream.

Upload feeds

The .upload() function takes the feed upload details received from a createFeedDocument operation, the feed content and its content type to upload as input and uploads it.

Start by creating a feed object with a contentType and the content either as a string or a file path to a document:

Name Type Default Description
content
optional
string - The content to upload as a string.
Required if file is not provided.
file
optional
string - The absolute file path to the feed content document to upload.
Required if content is not provided.
contentType
required
string - The contentType of the content to upload.
Should be one of text/xml or text/tab-separated-values and the charset of the content, i.e. text/xml; charset=utf-8.

This will create an inventory feed (POST_INVENTORY_AVAILABILITY_DATA) that will update the quantity of a given SKU to 10:

let feed = {
  content: `<?xml version="1.0" encoding="utf-8"?>
    <AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
      <Header>
        <DocumentVersion>1.02</DocumentVersion>
        <MerchantIdentifier>YOUR_MERCHANT_IDENTIFIER</MerchantIdentifier>
      </Header>
      <MessageType>Inventory</MessageType>
      <Message>
        <MessageID>1</MessageID>
        <Inventory>
          <SKU>YOUR_SKU</SKU>
          <Quantity>10</Quantity>
        </Inventory>
      </Message>
    </AmazonEnvelope>`,
  contentType: 'text/xml; charset=utf-8'
};

Before you can upload the feed you need to retrieve the feed upload details from a createFeedDocument operation:

let feed_upload_details = await spClient.callAPI({
  operation: 'createFeedDocument',
  endpoint: 'feeds',
  body: {
    contentType: feed.contentType
  }
});

Call the .upload() function to upload the content of the feed:

let res = await spClient.upload(feed_upload_details, feed);

After uploading the feed you have to trigger the processing of the feed by calling the createFeed operation with the necessary params (marketplaceIds, feedType and inputFeedDocumentId):

let feed_creation_infos = await spClient.callAPI({
  operation: 'createFeed',
  endpoint: 'feeds',
  body: {
    marketplaceIds: ['A1PA6795UKMFR9'],
    feedType: 'POST_INVENTORY_AVAILABILITY_DATA',
    inputFeedDocumentId: feed_upload_details.feedDocumentId // retrieve the feedDocumentId from the "createFeedDocument" operation
  }
});

NOTE: Although uploading and creating the feed was successful it doesn't mean that the processing of the feed itself was also successful. You can check the result of the feed once it has been processed by downloading the processing result with the .download() function quite similar as how to download reports. Use the feedId returned by the createFeed operation and call the getFeed operation, which will include a resultFeedDocumentId if feed processing is already done. The resultFeedDocumentId can be used with a getFeedDocument operation that will return the feed download details needed for the feed result download.

TypeScript Support

All TypeScript related information can be found in lib/typings. Currently types are not yet defined for all operations and/or params, so feel free to add new types following the readme. You are also welcome to create a pull request.

Sandbox mode

You can easily enable sandbox mode by setting use_sandbox in the constructor config options to true. General information on sandbox setup and behaviour can be found in the corresponding section in the Selling Partner API Developer Guide.

When using the sandbox you have to make sure to use the correct request parameters for the operation you want to test. You can find these inside the api models definitions in the docs by searching the corresponding json file for x-amzn-api-sandbox.

For example, this will test the getPricing operation in sandbox mode:

let res = await spClient.callAPI({
  operation: 'getPricing',
  endpoint: 'productPricing',
  query: {
    MarketplaceId: 'TEST_CASE_400'
  }
});

Known Issues

There is an issue with values of arrays as part of the query, when a value contains a ,. Due to Amazon expecting array values in query separated by , it will wrongfully split up values containing a , into two separate values. This is already a known issue communicated to Amazon.

Seller Support

We might be able to support you with everything else that can't be done with the API, i.e. a detailed sales dashboard, review management, automated reimbursements and more. Feel free to visit us at https://getarthy.com.

Breaking Changes

  • Removed refreshRoleCredentials function and the getter for role_credentials. As Amazon has removed the neccessity for signing requests to the SP API, role credentials are not needed anymore.

  • Trying to call an operation without specifying an endpoint now results in a NO_ENDPOINT_GIVEN error. Although deprecated since version 0.4.0 it was still possible to call an operation without an endpoint. This possibility has now been removed. However, it is still perfectly fine to omit the endpoint parameter and add it directly to the operation parameter via shorthand dot notation (i.e. operation: "sellers.getMarketplaceParticipations")

  • The reports and feeds endpoint's version 2020-09-04 is deprecated since 27th June 2023 and has been removed. As a result, encryptionDetails for downloading of reports and uploading of feeds is not returned anymore and all en-/decryption logic for reports and feeds has been removed as well.

changelog

v1.1.6 (2025-04-15)

Full Changelog

Notable changes:

  • Added new downloadReportStream() function
  • Added new operations for endpoints amazonWarehousingAndDistribution, supplySource, vendorDirectFulfillmentShipping, vendorShipments
  • Added new vehicles endpoint
  • Removed deprecated operations from fulfillmentInbound v0 endpoint
  • Added some more missing types (constructor config, .exchange, reports)

Commits:

  • Added updateSupplySourceStatus operation to supplySource endpoint (5047010)
  • Added new vendorShipments operations (e16d8a6)
  • Added createContainerLabel operation to vendorDirectFulfillmentShipping endpoint (2e015dc)
  • Removed deprecated v0 fulfillmentInbound operations (a80e98f)
  • Added new vehicles endpoint (75939b7)
  • Added new AmazonWarehousingAndDistribution operations (226fb96)
  • Added ExchangeResponse type (Fixes #224) (ebee3d1)
  • Added all possible constructor config options to types (also fixes #264) (f57e73a)
  • Added new report types (fixes #311) (6520762)
  • Fix for #310 (06f984a)
  • Added test for downloadReportStream (391ae64)
  • Update Readme to include Download reports as stream (740c2d7)
  • Removed uploadStream for now and added unzip as option to downloadReportStream (identical to downloadReport) (76800e7)
  • Fix the website url. (3b535e5)
  • Using erasable syntax instead of enums (8ea71f7)
  • Added downloadReportStream method (8a8a70c)
  • Changed streamToString to use _getStreamChunks and use existing decoding method, added TODOs to reporting tests (8ecac8c)
  • implement streamDownload() returning a stream (9c471a6)

Merged pull requests:

v1.1.5 (2025-01-23)

Full Changelog

Notable changes:

  • Added new endpoint version: finances (2024-06-19) with listTransactions operation
  • Added searchListingsItems operation to listingsItems (2021-08-01) endpoint
  • Added changelog
  • Added prettier formatting and reformatted all files

Commits:

  • Added prettier to project and reformatted all files (0432e58)
  • Added changelog (0359bee)
  • Added test for searchListingsItems (0324499)
  • Minor reformatting and test for listTransactions operation (954b547)
  • fix tab (6b72598)
  • listings items support searchListingsItems operation (87e9cb1)
  • Add new version of finance api (0d2cb55)
  • Add new version of finance api (5a59634)

Merged pull requests:

v1.1.4 (2024-11-25)

Full Changelog

Notable changes:

  • Minor bugfix for new appIntegrations endpoint not working correct due to missing import

Commits:

v1.1.3 (2024-11-18)

Full Changelog

Notable changes:

  • Added new endpoints: appIntegrations and invoices
  • Added request object to result if raw_result is set to true
  • Added types: productTypeDefinitions, apiPath
  • Extend timeout logic to refreshAccessToken

Commits:

Merged pull requests:

  • Return raw request and improve ReqParams typing #302 (cohlar)
  • feat(types): add typings for productTypeDefinitions #301 (paulwer)
  • Apply timeout options to access_token refresh call #299 (colin-brown)
  • Added TRANSACTION_UPDATE notificationType #298 (tho-masn)

v1.1.2 (2024-10-21)

Full Changelog

Notable changes:

  • Added new operations to fulfillmentInbound endpoint: listPrepDetails and setPrepDetails
  • Modified types: added timeouts (for IReqOptions and DownloadOptions), reportDocumentId (for DownloadDocument)
  • Added request data log when debug_log is true

Commits:

  • Added request data log when debug_log is true (9e42c31)
  • Added timeouts to IReqOptions (6e711e4)
  • Changed ProcessingStatus from enum to type to make it easily exportable (fe8fbd6)
  • Added reportDocumentId optional param, its not used in .download() but when piped through from getReportDocument() its included since Amazon includes it in the response (d107d95)
  • Update feeds.ts (ceee127)
  • Update feeds.ts (775a360)
  • Add new operations (672e26a)
  • Add new endpoints (60a3388)
  • Update baseTypes.ts (55c89fc)
  • Update index.d.ts (c2d0f0c)
  • Update baseTypes.ts (a889f51)

Merged pull requests:

v1.1.1 (2024-09-09)

Full Changelog

Notable changes:

  • Added new operation to sellers endpoint: getAccount
  • Added types: downloadReport, Scope
  • Removed deprecated sellingpartnerapi::migration scope
  • Removed deprecated types for smallAndLight endpoint
  • Minor bugfix for wrong api_path in getDocument operation of dataKiosk endpoint

Commits:

  • Updated depedencies (15de6b3)
  • Added sellers.getAccount operation and added sandbox only warning (7197954)
  • Added downloadReport typings (01cf949)
  • Changed deprecated comment (f1e19d1)
  • Removed deprecated sellingpartnerapi::migration scope (ace659d)
  • Fixed comma issue (37ed42b)
  • Bugfix #285 (bc8f8c5)
  • Fixed issue #279 (c94e2f6)
  • Update reports.ts (8d758cb)
  • fix(data-kiosk): incorrect url for data kiosk documents (a1c3596)
  • fix: add scope to ReqParams (371ebb9)
  • chore: create type Scope (330342b)
  • fix: add sellingpartnerapi::client_credential:rotation scope (653cb84)
  • fix: refreshAccessToken typings (52971d5)
  • allows subscriptions for data kiosk query processing finished notification (d12cab7)

Merged pull requests:

v1.1.0 (2024-07-23)

Full Changelog

Notable changes:

  • Added new endpoints: supplySources, dataKiosk, amazonWarehousingAndDistribution, applicationManagement
  • Added new endpoint version: fulfillmentInbound (2024-03-20)
  • Added new operations oneClickShipment, getAccessPoints, submitNdrFeedback to shipping (v2) endpoint
  • Added new operation sendInvoice to messaging (v1) endpoint
  • Added new operations getEligibleShipmentServicesOld, cancelShipmentOld, getAdditionalSellerInputsOld to merchantFulfillment (v0) endpoint
  • Added new operation deliveryOffers to fulfillmentOutbound (2020-07-01) endpoint
  • Added new operation easyShip to easyShip (2022-03-23) endpoint
  • Removed deprecated endpoints: fbaSmallAndLight, authorization

Commits:

  • Updated dependencies and transformed tests to work with chai 5.x esm-only (c5fecd9)
  • Revert "1.1.0" (fdcd7de)
  • Minor fixes for verbatimModuleSyntax (c8eaf3d)
  • Removed deprecated getInboundGuidance operation (6f0fd08)
  • Removed deprecated fbaSmallAndLight endpoint (8a91c27)
  • Added supplySources endpoint (f10937e)
  • Added more operations to shipping v2 endpoint (cb01907)
  • Removed comment as restore rate is now defined in docs for getMyFeesEstimates (97aa418)
  • Added sendInvoice operation to messaging endpoint (e61ccc8)
  • Removed deprecated merchantFulfillment operations (8afdf4d)
  • Added deliveryOffers operation to fulfillmentOutbound endpoint (f8712cf)
  • Added createScheduledPackageBulk operation to easyShip endpoint (c64090d)
  • Added dataKiosk endpoint (8ff6f10)
  • Added AmazonWarehousingAndDistribution endpoint (ca4e6b5)
  • Added applicationManagement endpoint (c2182f7)
  • Removed deprecated authorization endpoint (b31a9d8)
  • Updated fulfillmentInbound tests for new endpoint (9dd0d5b)
  • Added new 2024-03-20 fulfillmentInbound endpoint (d0de38d)
  • import types excplicitly with verbatimModuleSyntax (966502f)

v1.0.6 (2024-03-12)

Full Changelog

Notable changes:

  • Added new cancel_after option for .downloadReport which allows to cancel a report creation after X retries
  • Removed deprecated getInboundGuidance operation for fulfillmentInbound endpoint
  • Added possibility to use a proxy agent
  • Added types for sellers endpoint

Commits:

  • Added new "cancel_after" option for ".downloadReport" which allows to cancel a report creation after X retries (b30b24e)
  • Removed deprecated getInboundGuidance operation (fe813e7)
  • Some changes how httpsProxyAgent option is implemented (26b428d)
  • Moved GetMarketplaceParticipationsResponse to correct type (f40b117)
  • Added types for Sellers endpoint. (6eb6603)
  • feat: added an additional option to allow the usage of a custom proxy agent (3d69c12)

Merged pull requests:

v1.0.5 (2024-02-05)

Full Changelog

Notable changes:

  • Added updateCredentials function to enable updating credentials after class instantiation

Commits:

  • Added new function to updateCredentials after instantiation (452f693)

v1.0.4 (2024-01-11)

Full Changelog

Notable changes:

  • Gracefully handle ECONNRESET errors

Commits:

  • Gracefully handle ECONNRESET errors (19712f3)

v1.0.3 (2024-01-03)

Full Changelog

Notable changes:

  • Added fix for reports already returned as json

Commits:

  • Updated dev dependencies (ca3590a)
  • Added fix for reports already returned as json (a37e228)

v1.0.2 (2023-12-19)

Full Changelog

Notable changes:

  • Added retry possibility for ENOTFOUND errors

Commits:

  • Added ENOTFOUND handling as ETIMEDOUT is done and also resolve retry to finally fix issue of timeout errors from API (7481ece)

v1.0.1 (2023-12-14)

Full Changelog

Notable changes:

  • Added retry logic when remote server request fails with ETIMEDOUT error
  • Removed deprecated type ListCatalogItem
  • Added getCompetitiveSummary operation to productPricing (2022-05-01) endpoint

Commits:

  • Updated Readme (5c97d6b)
  • Added retry logic when remote server request fails with ETIMEDOUT error (a58dad6)
  • Removed unused interface ListCatalogItem (fix #243) (87cae8c)
  • Added test for getCompetitiveSummary operation (a8f4848)
  • Added getCompetitiveSummary operation to productPricing endpoint (0e67e1b)
  • Fixed getOrderItemsResponse TS Exception - Fixes issue #252 (97c95ed)
  • Added support for xlsx reports (i.e. GET_REMOTE_FULFILLMENT_ELIGIBILITY report) (cf8dad4)
  • Update SellingPartner.js (6b5f36d)

Merged pull requests:

v1.0.0 (2023-10-29)

Full Changelog

Notable changes:

Removed deprecated roleCredentials logic and operations.js Removed deprecated types: RoleCredentials, encryptionDetails for reports/feeds and AWS credentials Removed Signer.js class as signing of requests is deprecated Added new Request.js class and removed old request.js Removed deprecated endpoints versions: reports and feeds (2020-09-04) Fixes/Updates to order types

Commits:

  • Update package.json (13ede1e)
  • Minor changes to Readme (6e4142e)
  • Updated notificationType enum (ff46ac3)
  • Updated dependencies in package.json (1c1f0cc)
  • Updated Readme for 1.0.0 (58f00d8)
  • Updated tests (63320e1)
  • Removed role_credentials, encryptionDetails for reports/feeds and unneccessary credentials (9cf0a58)
  • Removed unused operations.js (1e48882)
  • Removed role_credentials and operations import (5ce7f20)
  • Formatting updates for TimeoutManager and utils (33bcaf2)
  • Added new Request class (30441f5)
  • Removed deprecated crendentials (b09cddd)
  • Removed request.js and Signer.js (be15e6b)
  • Removed deprecated reports and feeds version 2020-09-04 (ac5e5f1)
  • General fixing/updating of order typings (b642516)
  • fixes empty errors array handling in call api method (3903c05)

Merged pull requests:

  • General fixing/updating of orders typings #246 (amogower)
  • Fixes empty errors array handling in call api method #245 (Nifrigel)

v0.8.5 (2023-09-24)

Full Changelog

Commits:

  • Updated reports endpoint tests to work with newest version of endpoint (89db07e)
  • Updated fulfillmentOutbound test for getFeatures operation (4fdb1d7)
  • Removed tests fro deprecated fbaSmallAndLight endpoint (6d53e70)
  • Changed updateFulfillmentOrder to use PUT instead of GET --> Bugfix #242 (44d2e58)
  • Added deprecation date to getEligibleShipmentServicesOld, cancelShipmentOld, and getAdditionalSellerInputsOld operations of merchantFulfillment endpoint (4101937)
  • Added deprecation date for getInboundGuidance operation (b85a397)
  • Added deprecation date for authorization endpoint (61e6d7b)
  • Added deprecated warning to fbaSmallAndLight endpoint (68013f6)
  • Added deprecation warning for feeds and reports endpoints version v2020-09-04 (83da196)
  • option is called endpoints_versions instead of endpoint_versions (9c607de)
  • Update notifications_v1.js (74235de)
  • Add support for createReport types (d7fc9b1)
  • Bugfix: Capitalize properties of Interface GetOrdersQuery (d7060e1)
  • add missing params: endpoint, restricted_data_token to ReqParams interface (bec9e66)
  • added endpoint_versions option to client config (53a5d19)
  • added the new ORDER_CHANGE notification type (4c26544)

Merged pull requests:

v0.8.4 (2023-07-30)

Full Changelog

Commits:

  • Updated to lowered restore_rate for getItemOffersBatch (18cd8cc)
  • Added new replenishment api endpoint (08abe89)
  • Added sandbox-only submitFulfillmentOrderStatusUpdate operation for fulfillmentOutbound endpoint (77953e2)
  • Fixed downloadReport() function not considering the specified version for all steps (da2bd54)
  • Added missing GetItemOffersPath import (41c2e73)
  • Implemented timeoutManager as external class (565ebe7)
  • Updated dependencies (67a9f38)
  • Changed restore rate of confirmShipment to 2 per second (88ef612)
  • Removed hiring from Readme (7460a41)
  • Updated docs to new import structure (4a32949)
  • Changed module exports to work with esm imports, commonjs and also legacy definition via commonjs with SellingPartnerAPI naming (b49240f)
  • More correct response (726584c)
  • getReports (50619bf)
  • Add all report types (b40e019)
  • Update catalog item query (bee6acf)
  • Fixing capitalization in order payload (2db495c)
  • a timeoutManager object (3a8ebdc)
  • Add operation order.confirmShipment (e9e15d3)
  • Export all types for fbaInventory and update getInventorySummariesResponse type to match (d9b3f47)
  • add(type): productPricing.getItemOffers (fee8f03)
  • update(docs): add esm import (9bba19c)
  • feat(named exports): for SellingPartner class (01cc30a)
  • Fix ts is not a constructor (d98d41c)

Merged pull requests:

v0.8.3 (2023-03-14)

Full Changelog

Commits:

  • Added new productPricing endpoint version v2022-05-01 (95c1129)
  • Updated restore rates for orders v0, solicitations v1 and uploads v2020-11-01 (9fb8d34)

v0.8.2 (2023-02-21)

Full Changelog

Commits:

  • Updated Download Reports section in Readme (5621475)
  • Updated downloadReport methods to better fit in with the rest of the library (56dc033)
  • update SellingPartner.js (6ff6439)

Merged pull requests:

v0.8.1 (2023-01-28)

Full Changelog

Commits:

  • Added new headers option to Readme (309c3ea)
  • Added getOrderRegulatedInfo and updateVerificationsStatus orders endpoint operations (a4d6ffa)
  • Added v2 shipping operations (ca62c19)

v0.8.0 (2022-10-23)

Full Changelog

Commits:

  • Added timeouts to .download (ecbd0d1)
  • Updated vendorDirectFulfilmentShipping endpoint with new operations (de82cfb)
  • Changed restore rates according to SP-API Throttling Adjustments (e7be23b)
  • Removed deprecated operations listCatalogItems and getCatalogItem v0 (1bff27b)
  • Merge commit '5a2840f83a9ae878d1f4d01146664105e72c126e' (4e26ae7)
  • Slight productPricing test spec change (76fa00b)
  • Revert "Changed productPricing test spec" (714ca72)
  • Changed productPricing test spec (c8402df)
  • Added tests for timeouts (afa2822)
  • Update Readme to include timeouts section (66e2d99)
  • Changed timeouts to be set globally as well as timeouts object, added idle timeout and restructured the code a bit (41bd13a)
  • Add the new FBA_INVENTORY_AVAILABILITY_CHANGES notification (5a2840f)
  • Removed some artefacts (51a6158)
  • Added test for invalid security token (98ab500)
  • Made x-amz-security-token and AWS_SELLING_PARTNER_ROLE optional (26ca0d7)
  • typo String to string (44b182a)
  • Added response timeout and deadline timeout option support to allow request to be aborted if it takes a lot longer than expected due to network errors. (cf82599)

Merged pull requests:

  • Add the new FBA_INVENTORY_AVAILABILITY_CHANGES notification #173 (ctiospl)
  • Added response timeout and deadline timeout option support #148 (colin-brown)

v0.7.10 (2022-08-12)

Full Changelog

Commits:

  • Updated dependencies (ad123ee)
  • Removed tests for soon to be deprecated operations (a4b5b17)
  • Added deprecation warning to soon to be deprecated catalogItems v0 operations (c4afa2a)
  • Added the following operations to services endpoint: getRangeSlotCapacity, getFixedSlotCapacity, getAppointmentSlotsByJobId, getAppointmentSlots (89a554d)
  • CreateReportResponse unwraps the payload object (f56fdae)
  • Fix TypeScript compilation (641a46f)

Merged pull requests:

v0.7.9 (2022-07-10)

Full Changelog

Commits:

  • Changed information on charset property for download function due to change proposed in issue #144 (26882ad)
  • Charset for decoding reports now taken from content-type header (as proposed in #144) (60c325d)
  • Added additional tests for productPricing endpoint (509730f)
  • Added known issue with commas as part of array value for query (bf18bc2)
  • Implement new doubleEncodeURIComponent function that fixes issue #143 (f819419)

v0.7.8 (2022-07-01)

Full Changelog

Commits:

  • Added new option of qs module called commaRoundTrip that should fix issues with incorrect formatting arrays of length 1 (#138) (fef719d)

v0.7.7 (2022-06-14)

Full Changelog

Commits:

  • Updated fbaSmallAndLight test spec (0839db5)
  • Updated double encode fix #134 (d38e8d7)
  • Add encode query twice option (2890b44)

Merged pull requests:

v0.7.6 (2022-05-29)

Full Changelog

Commits:

  • Changed new AWS_SESSION_TOKEN to be optional in Credentials.js (3673a7c)
  • Updated all external links in README (6c4e55d)
  • Minor README changes (b4eae4d)
  • Updated README to include AWS_SESSION_TOKEN where necessary (f77877b)
  • include session token only if available (80f88c8)
  • add AWS_SESSION_TOKEN to README (e1b2f03)
  • add AWS_SESSION_TOKEN and X-Amz-Security-Token header (0cd3f0d)

Merged pull requests:

v0.7.5 (2022-05-20)

Full Changelog

Commits:

  • Added disclaimer to Readme (b5763c3)
  • Added batch request tests for productPricing endpoint (54fd921)
  • Added new batch operations for productPricing endpoint (5af30c0)
  • Minor change to productPricing endpoint tests (998d6c7)
  • Updated tests for productFees endpoint (d887e98)
  • Added new getMyFeesEstimates operation for productFees endpoint (120482e)
  • Minor formatting changes for new catalogItems version (dc04b53)
  • chore: replace hard code (7765e94)
  • Added catalogItems endpoint 2022-04-01 version test case (2dc5c7f)
  • Added catalogItems endpoint 2022-04-01 version (80315d8)

Merged pull requests:

v0.7.4 (2022-04-17)

Full Changelog

Commits:

  • Updated dependencies (d5b50ad)
  • Change fbaInventory test spec to run for all regions (eb5c56b)
  • Added test spec stub for new endpoints easyShip and vendorDirectFulfillmentSandboxTestData (624799f)
  • Added SKU length issue to Known Issues section in README (Issue #126) (2c8a043)
  • Removed comment as FBAInventory in now globally available (ebbfe09)
  • Added vendorDirectFulfillmentSandboxTestData endpoint (e33f539)
  • added vendorDirectFulfillmentTransactions endpoint 2021-12-28 version (1d6cc22)
  • added vendorDirectFulfillmentShipping endpoint 2021-12-28 version (593c845)
  • Added vendorDirectFulfillmentOrders endpoint 2021-12-28 version (31ca604)
  • Added easyShip endpoint (fda781c)

v0.7.3 (2022-04-06)

Full Changelog

Commits:

  • Minor changes for aplusContent and fbaSmallAndLight tests (42ef312)
  • Minor debug log output change (9fd3c11)
  • Make amazon-sp-api compatible with bundler again (0db7943)
  • add OrderItemsList as payload type for GetOrderItemResponse (d898b8d)

Merged pull requests:

v0.7.2 (2022-03-16)

Full Changelog

Commits:

  • Added missing notificationType enum values (Fix #117) (e4b93fc)
  • comment out unused order types (3ec0ac1)

Merged pull requests:

v0.7.1 (2022-02-24)

Full Changelog

Commits:

  • Added some more debug logs (604ce8f)
  • Added restore_rate support for floating numbers as well as support in combination if usage of api_path (7e7be29)
  • Changed restore_rate type to Number (aa3f90c)
  • use isSafeInteger instead of isFinite (6cf056d)
  • add restore_rate param to callAPI options (c771ce6)

Merged pull requests:

  • add restore_rate param to callAPI options #111 (vhle-ms)

v0.7.0 (2022-02-18)

Full Changelog

Commits:

  • Updated dependencies (c0ce774)
  • Added note to Readme that manual encoding might be necessary before using api_path (29b8d34)
  • Added tests for SKUs with special chars (#+ =,?~_-|/!*?()) (57ea00b)
  • Fixed bug with querystring discussed in #103 (b530017)
  • Changed api_path parts encoding to be done when constructing the api_path in order to be able to make it work with path params including a '/' (i.e. as part of SKUs) (f3352c5)
  • Export all finances interfaces (Typescript support) (708c834)
  • Moved throttling debug log (87c46ed)
  • Changed console_warn_on_request_retry to debug_log to have a more common naming to include other logs (ed02480)
  • add single encoding for req_params.api_path, and double encoding for canonical request (5497799)
  • double encoding fix for AWS Signature v4 (d9b1e5f)
  • Minor changes to description of console_warn_on_request_retry (15f06ef)
  • Add 'console_warn_on_request_retry' param (6451ed2)

Merged pull requests:

v0.6.6 (2022-01-23)

Full Changelog

Commits:

  • Updated dependencies (f9584ae)
  • Encode chars !'()* once when part of query (Fully Fixed Issue #77) (ce413f6)
  • Minor changes to sandbox documentation in Readme (58aa762)
  • Updated getEligibleShippingServices restore rate (10d5573)
  • Changed user_agent documentation in Readme (bdfe4f0)
  • Added user agent to signed headers (bf78ad2)
  • Added default user agent in accordance with docs (707c4c8)
  • Specifying custom user-agent headers for api calls (f27058c)
  • add missing imports in index.d.ts (fef64c3)
  • add getLabels, getBillOfLading, getShipments, getShipmentItemsByShipmentId and getShipmentItems (b64a375)
  • add createRestrictedDataToken (dd6d26b)
  • added use_sandbox property to Options Type in : baseTypes.ts (fc5a29f)
  • options definition added to callApi() method (b7de3f1)

Merged pull requests:

v0.6.5 (2021-12-17)

Full Changelog

Commits:

  • Added new updateShipmentStatus operation (6d25fbd)
  • Minor fix wrong link (2473ad6)
  • add transport operations for fulfillment inbound (6bb502a)

Merged pull requests:

  • Add transport operations for fulfillment inbound #79 (mgecmez)

v0.6.4 (2021-12-07)

Full Changelog

Commits:

  • Encode chars !'()* once when part of api path (Fixed Issue #77) (bca9a59)
  • added upload typings for feeds (0dd97cb)
  • Updated test spec for catalogItems to make sure searchCatalogItems works with whitespace in keywords (a3abd78)

Merged pull requests:

v0.6.3 (2021-11-21)

Full Changelog

Commits:

v0.6.2 (2021-11-18)

Full Changelog

Commits:

  • Bugfix for endpoints export missing first endpoint aplusContent (4fbb145)

v0.6.1 (2021-11-14)

Full Changelog

Commits:

  • Renamed productTypeDefinitions endpoint (90d1ea8)
  • Updated dependencies (fd9eae7)

v0.6.0 (2021-11-06)

Full Changelog

Commits:

  • Fixed issues with UTF-8 chars and whitespace when part of the querystring (Fixed #63) (6b7bf23)
  • Added test for listingsRestrictions (d0cb157)
  • Added new listingsRestrictions endpoint (e5cd83e)
  • Changed endpoints require statements to be more dynamic (0bb9c6a)
  • Minor Readme changes (d810dc8)
  • Update restore_rates in catalogItems and fbaInventory (9ff52e6)
  • Fixed bug with UTF-8 and/or spaces in SKUs when part of the api_path (i.e. getMyFeesExstimateForSKU, see issue amzn/selling-partner-api-docs#742) (8558e6c)
  • Change homepage in package.json (fa3eeab)
  • listingsItems 2021-08-01 (ac9f2c4)

Merged pull requests:

v0.5.6 (2021-10-23)

Full Changelog

Commits:

  • Updated dependencies (12d664d)
  • Changed tokens test spec (74c72d8)
  • Changed TS "Body" interface names to be named according to naming convention in README (ef9ed81)
  • Changed a couple inconsistent body definitions (f843be4)
  • Added support for exchange authorisation code from a seller to a refresh token (934407d)
  • Changes in typescript information: - Added support for specifying credentials in the constructor - Fixed naming of the order file - should be orders - Fixed specification for the reports which had a "body" level too much - Added getter for access_token and role_credentials (f2729ce)

Merged pull requests:

  • Changes in typescript information: #60 (jebirch)

v0.5.5 (2021-09-19)

Full Changelog

Commits:

  • Fixed createFeed bug in new feed version 2021-06-30 (Issue #53) (70c38f4)

v0.5.4 (2021-07-29)

Full Changelog

Commits:

  • Version 2021-06-30 of SP-API renders document encryption optional in feeds and reports (1b51f54)

Merged pull requests:

  • Version 2021-06-30 of SP-API renders document encryption optional in … #45 (brianmhofmeister)

v0.5.3 (2021-07-27)

Full Changelog

Commits:

  • Changed credentials to class structure (b069bdd)
  • Removed aplus endpoint issues from Known Issues section (4707f08)
  • Readded aplus tests (2138bd0)
  • Add reference to TS types in package.json (f2c8e24)
  • add:orderAPI types (1fd9126)
  • fix typo in readme (3ed6083)

Merged pull requests:

v0.5.2 (2021-06-07)

Full Changelog

Commits:

  • Update Known Issues section in Readme (34223fe)
  • Added new tests for new operation searchCatalogItems and new endpoints listingsItems, productTypesDefinitions, shipmentInvoicing (2bcf8d7)
  • Added new shipmentInvoicing endpoint (7480467)
  • Added productTypesDefinitions endpoint (b770829)
  • Added new listingsItems endpoint and HTTP PATCH support (6755c1c)
  • Added new searchCatalogItems operation (7927e33)
  • Updated restore rates for orders, productFees and productPricing (e579891)

v0.5.1 (2021-05-12)

Full Changelog

Commits:

  • Added new vendor endpoints and operations (f4ecf33)
  • Added new services operations (8a2757d)
  • Added possibility of operations without default restore rate (54d1d08)
  • Updated dependencies (93b25e0)

v0.5.0 (2021-05-07)

Full Changelog

Commits:

  • Updated and added tests with new endpoint parameter (cb3d086)
  • Added documentation for LWA authorization code exchange function (141e575)
  • Updated readme to include new endpoint logic (df2f7f0)
  • Added new endpoint parameter to .callAPI() (c69664c)
  • Added console.warn logic to utils (9d0abda)
  • Updated outdated links (99762d8)
  • Added exchange() func to exchange LWA auth_code for a LWA refresh_token (ece51f9)

v0.4.0 (2021-04-11)

Full Changelog

Commits:

  • Added new tests (c6aa763)
  • Added new api_path property (5e29130)
  • Updated comments (432e285)
  • Typofixes (a684507)
  • Readme restructured and updated (4f19ea3)
  • Added support for restricted data tokens endpoint (0df6f5e)
  • Extended new version logic: Added endpoints_versions and version_fallback config options (641f84a)
  • Changed to correct endpoint name (cb941d8)
  • Added endpoints getter (9305204)
  • Added support for multiple operation versions to Sellingpartner class (9f2c0ea)
  • Changed resources to new structure to enable support for multiple versions of endpoints and operations (9502247)
  • Small typos fixed in readme (3bf20f0)
  • Small typos fixed in readme (c9a2517)
  • Small typos fixed in readme (d4ab134)
  • Small typos fixed in readme (1ea51f1)

v0.3.7 (2021-04-03)

Full Changelog

Commits:

  • Updated comments for .callAPI() (c1afa56)
  • Added restore rates information in readme (1c127b5)
  • If given use x-amzn-ratelimit-limit from result header as restore_rate in case of throttling (2a127a2)
  • Updated restore_rate for catalogItems endpoints (7b36742)

v0.3.6 (2021-03-31)

Full Changelog

Commits:

  • Added new raw_result option for .callAPI to readme (746c188)
  • Added new option to .callAPI to return raw result (86dcf9d)
  • Reformatted pagination fix and added comment to API call in resources/fbaInventory.js (92b17b9)
  • Updated incomplete documentation on grantless operations (daefdbc)
  • Added seller support information (b84d4a4)
  • Fixed pagination of getInventorySummaries (931cb69)

Merged pull requests:

v0.3.5 (2021-02-17)

Full Changelog

Commits:

  • Updated .download section in readme (4ff3b7e)
  • Added decoding charset option to report download (aef1435)
  • RateLimit Header TODO added (2da54f3)
  • Added tests for aplus content operations (19393a2)
  • Added new aplus content operations (38021ef)

v0.3.4 (2021-01-28)

Full Changelog

Commits:

  • Added table of contents (896a005)
  • turn off quote detection in report csv to json conversion (0780ae2)

Merged pull requests:

  • Turn off quote detection in report csv to json conversion #22 (mihai9-lab)

v0.3.3 (2021-01-16)

Full Changelog

Commits:

  • Added tests for config errors (992a1d0)
  • Fixed issue with operation allowance for non grantless operations (9a4b61d)
  • Added missing scope for grantless operation error message (f4a1a9a)
  • Added documentation for grantless operations (1bb0094)
  • Added tests for grantless operations (45cac94)
  • Added "only_grantless_operations" option (8fd39a6)
  • Moved operation validation out of callAPI to new function (a1b0153)
  • Restructured access_token and role_credentials validation in new function (4346122)
  • Added scope to refreshAccessToken call when token expired (3d5a4a3)
  • Added grantless token logic to .callAPI (56918e0)
  • Added scope for grantless operations (7b520cb)
  • Added grantless_tokens class var to hold valid tokens for a grantless operation scope (dc6e68b)
  • Added scope parameter for grantless operation to refreshAccessToken (9581647)
  • Updated sandbox comment in SellingPartner to be in line with Readme (b40d0bf)
  • Update README.md (fda7d86)

Merged pull requests:

v0.3.2 (2021-01-09)

Full Changelog

Commits:

  • Minor formatting changes (6ae02f7)
  • Added sandbox mode info (2383e36)
  • Minor restructuring of .callAPI error handling (c927aa1)
  • Minor formatting changes (76aa07f)
  • Added use_sandbox option to Readme (f2ed464)
  • Minor var naming changes (fba026c)
  • Moved _sandbox to options as use_sandbox (88917ac)
  • Updated readme with new credentials option (8f097e3)
  • Fixed path info issue (dc644e4)
  • Added option to load credentials via constructor config object (906218a)
  • Add Sandbox (ae10deb)
  • Add sandbox mode (83c4427)

Merged pull requests:

v0.3.1 (2021-01-07)

Full Changelog

Commits:

Merged pull requests:

v0.3.0 (2021-01-03)

Full Changelog

Commits:

  • Added documentation for .upload() function, which will encrypt and upload feeds (ee30bd2)
  • Added new upload function that encrypts and uploads feed documents (e82951d)
  • FIX: URL not defined in certain NodeJS versions (0939aa2)
  • Add alternate variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (3416fcd)
  • Removed logic of planned TODO for checking not only path but body and querystring params of operations as well --> not neccessary as SP API error messages are meaningful for body and querystring params (0966bc0)
  • fix: Error code example (ac1cb7b)

Merged pull requests:

  • FIX: URL not defined in certain NodeJS versions #13 (ALEXOTANO)
  • Tweak: Add alternate variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY #12 (ghost)
  • fix: Error code example #9 (wangjue666)

v0.2.6 (2020-12-20)

Full Changelog

Commits:

  • Added basic testing for some operations (827ae6d)
  • Added information to getInventorySummaries --> only available in NA region (df44573)

v0.2.5 (2020-12-08)

Full Changelog

Commits:

  • Fixed missing "/" in orders api paths (c036b49)

v0.2.4 (2020-12-07)

Full Changelog

Commits:

  • Fixed "getMyFeesEstimateForASIN" path and minor readme update (57c6f9a)

v0.2.3 (2020-11-28)

Full Changelog

Commits:

v0.2.2 (2020-11-27)

Full Changelog

Commits:

  • Replaced "fs/promises" with standard version with cb to support older node versions (61c1ea9)

v0.2.1 (2020-11-27)

Full Changelog

Commits:

  • Added .download() function for reports --> downloads, decrypts and unzips reports (506c833)

v0.2.0 (2020-11-21)

Full Changelog

Commits:

  • Changed .callAPI to use operation instead of path, added support for retry throttled requests in sync with restore rates (39bea31)

v0.1.1 (2020-11-16)

Full Changelog

Commits:

  • Fixed issue with arrays as part of GET parameters (28da886)

v0.1.0 (2020-11-16)

Full Changelog