Skip to content

kaskadi/mws-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Actions workflows status

Build workflow status Publish workflow status

CodeClimate


Installation

npm i mws-client

API documentation

Modules

Module Description
mws-client Creates a new client to communicate with MWS API

Classes

Name Description
Section A section of MWS API. Note: all sections and associated endpoints are generated automatically when instanciating a new client

Typedefs

Name Description
MWSResponse Response received from MWS API
Options Options for the new MWS client instanciation
MWS MWS client

mws-client

Creates a new client to communicate with MWS API

Returns: MWS - MWS client

Param Type Description
opts Options Options to be passed to instanciate a new client

Example

const MWS = require('mws-client')({
  AWSAccessKeyId: process.env.YOUR_AWS_ACCESS_KEY,
  SellerId: process.env.YOUR_SELLER_ID,
  MWSAuthToken: process.env.YOUR_MWS_AUTH_TOKEN
})

Section

A section of MWS API. Note: all sections and associated endpoints are generated automatically when instanciating a new client

Kind: global class

Section.endpoint(opts)

Send a request to the given endpoint

Kind: static method of Section
Returns: MWSResponse - Response received from MWS API

Param Type Description
opts Object Parameters for the API call. See here for details regarding parameters for every endpoints. Note: list parameters are not supporting Array type yet. You will have to build them in the same way as they appear in the query string of the signed request to MWS API (i.e. param.1=foo&param.2=bar)

Example

// retrieves inventory from given date for the German marketplace
const list = await MWS.fulfillmentInventory.listInventorySupply({
  QueryStartDateTime: new Date(d).toISOString(),
  ResponseGroup: 'Basic',
  _marketplace: 'DE'
})

// retrieve status of the fullfillmentInventory API for the German marketplace
const status = await MWS.fulfillmentInventory.getServiceStatus({ _marketplace: 'DE' })

MWSResponse

Response received from MWS API

Kind: global typedef
Properties

Name Type Description
headers Object Headers of the response received from the MWS API. Those are typical Headers as you would find in the Fetch API.
status number Response status code
body Object Parsed body from MWS API response

Options

Options for the new MWS client instanciation

Kind: global typedef
Properties

Name Type Default Description
AWSAccessKeyId string AWS access key ID
MWSAuthToken string MWS authentication token
SellerId string Seller ID
[SignatureVersion] string '2' Signature version used for signing to request URL
[SignatureMethod] string 'HmacSHA256' Signature method used for signing to request URL
[userAgent] string 'kaskadi-mws-client/VERSION (Language=node.js)' User agent used when sending request
[parserType] string 'xml' Parser used for the response received from MWS. Accepted values: 'xml', 'text'

MWS

MWS client

Kind: global typedef
Properties

Name Type Description
Section Section MWS API section

Notes

Throttling

This client does not include throttling handling. The reason being that our internal implementation uses Lambda functions which are not persistent and therefore instantiate a new client at each function call. This makes a throttling handled via client irrelevant since multiple clients may be instantiated in a short period of time (or even in parallel) to call the same endpoint which leads to a client throttling state not reflecting the actual throttling state of the MWS API.

We encourage you to implement your own throttling handling in your infrastructure so that it fits your implementation. You can refer to MWS API documentation for more information on this.

Reminder: response headers are exposed via the mws-client return value so you may use those to handle an hourly capped endpoint.

Client implementation

This client uses signed requests to communicate with the MWS API. See docs here and there for more details.

Available sections & endpoints

All items listed here point to the MWS API docs