Home Reference Source
import MwsAdvanced from '@ericblade/mws-advanced'
public class | source

MwsAdvanced

Static Method Summary

Static Public Methods
public static

async callEndpoint(args: ...*): *

public static

getLowestPricedOffersForAsin(params: ...*): *

public static

getLowestPricedOffersForSku(params: ...*): *

public static

getMarketplaces(params: ...*): *

public static

getMatchingProductForId(params: ...*): *

public static

getMyFeesEstimate(params: ...*): *

public static

getOrder(params: ...*): *

public static

getProductCategoriesForAsins(params: ...*): *

public static

getProductCategoriesForSkus(params: ...*): *

public static

getReport(params: ...*): *

public static

getReportList(params: ...*): *

public static

getReportListAll(params: ...*): *

public static

getReportListByNextToken(params: ...*): *

public static

getReportRequestList(params: ...*): *

public static

getReportScheduleList(params: ...*): *

public static

init(args: ...*): *

public static

listFinancialEvents(params: ...*): *

public static

listInventorySupply(params: ...*): *

public static

listMatchingProducts(params: ...*): *

public static

listOrderItems(params: ...*): *

public static

listOrders(params: ...*): *

public static

manageReportSchedule(params: ...*): *

public static

parseEndpoint(args: ...*): *

public static

requestAndDownloadReport(params: ...*): *

public static

requestReport(params: ...*): *

public static

updateReportAcknowledgements(params: ...*): *

Constructor Summary

Public Constructor
public

constructor(rest: object): MWSAdvanced

Create a new instance of MWSAdvanced, calling init(), and binding this instance of callEndpoint to this instance of MWSAdvanced.

Member Summary

Public Members
public

mws: *

Method Summary

Public Methods
public

async callEndpoint(name: string, callOptions: object, opt: object): any

Call a known endpoint at MWS, returning the raw data from the function.

public

async doRequest(requestData: *, options: {}): *

public

getLowestPricedOffersForASIN

public

getLowestPricedOffersForSKU

public

getMarketplaces(params: ...*): MarketDetail

Call MWS ListMarketplaceParticipations, return parsed results

public

getMatchingProductForId(options: Object): Product[]

Returns a list of products and their attributes, based on a list of ASIN, GCID, SellerSKU, UPC, EAN, ISBN, or JAN values

public

Get an estimate of fees for an item, based on listing and shipping prices.

public

getOrder(options: object, options: string[]): object

Return orders by ID, i.e.

public

return product categories for multiple asins

public

return product categories for multiple SKUs

public

getReport(options: object): Array | object

Download a specific report identified by the ReportId and return it

public

getReportList(params: ...*): *

TODO: write documentation for getReportList

public

getReportListAll(params: ...*): *

TODO: write documentation for getReportListAll (or see comment on getReportListByNextToken)

public

getReportListByNextToken(params: ...*): *

TODO: write documentation for getReportListByNextToken (or just roll getReportList and getReportListByNextToken into the same wrapper) (that wrapper might be getReportListAll, and just rename it)

public

getReportRequestList(options: object, ReportRequestIdList: string[], ReportTypeList: string[], ReportProcessingStatusList: string[], MaxCount: number, RequestedFromDate: Date, RequestedToDate: Date): GetReportRequestListResult[]

Returns a list of report requests that you can use to get the ReportRequestId for a report After calling requestReport, you should call this function occasionally to see if/when the report has been processed.

public

getReportScheduleList(params: ...*): *

TO DO: WRITE DOCUMENTATION

public

init(config: object): mws-simple

Initialize mws-advanced with your MWS access keys, merchantId, optionally authtoken, host, port If accessKeyId, secretAccessKey, and/or merchantId are not provided, they will be read from the environment variables MWS_ACESS_KEY, MWS_SECRET_ACCESS_KEY, and MWS_MERCHANT_ID respectively

public
public

listInventorySupply(options: object): {nextToken: string, supplyList: object[]}

Return information about the availability of a seller's FBA inventory

public

listMatchingProducts(options: object): Product[]

Return a list of products and their attributes, based on a text query and contextId.

public

Returns order items based on the AmazonOrderId that you specify.

public

listOrders(options: object): object

Return orders created or updated during a specific time frame see https://docs.developer.amazonservices.com/en_UK/orders-2013-09-01/Orders_ListOrders.html At least ONE of the search options (and maybe more depending on which ones you select) must be specified.

public

manageReportSchedule(params: ...*): *

TO DO: WRITE DOCUMENTATION

public

parseEndpoint(outParser: *, inParser: *): *

public

requestAndDownloadReport(params: ...*): *

TODO: Document requestAndDownloadReport

public

requestReport(options: object, MarketplaceId: string[]): ReportRequestInfo

Request a report from MWS Many optional parameters may be required by MWS! Read ReportType for specifics!

public

updateReportAcknowledgements(params: ...*): *

TO DO: WRITE DOCUMENTATION

Static Public Methods

public static async callEndpoint(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public static getLowestPricedOffersForAsin(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getLowestPricedOffersForSku(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getMarketplaces(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getMatchingProductForId(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getMyFeesEstimate(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getOrder(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getProductCategoriesForAsins(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getProductCategoriesForSkus(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getReport(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getReportList(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getReportListAll(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getReportListByNextToken(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getReportRequestList(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static getReportScheduleList(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static init(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public static listFinancialEvents(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static listInventorySupply(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static listMatchingProducts(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static listOrderItems(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static listOrders(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static manageReportSchedule(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static parseEndpoint(args: ...*): * source

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public static requestAndDownloadReport(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static requestReport(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public static updateReportAcknowledgements(params: ...*): * source

Params:

NameTypeAttributeDescription
params ...*

Return:

*

Public Constructors

public constructor(rest: object): MWSAdvanced source

Create a new instance of MWSAdvanced, calling init(), and binding this instance of callEndpoint to this instance of MWSAdvanced.

Params:

NameTypeAttributeDescription
rest object

passed on to @see #init

Return:

MWSAdvanced

new instance of MWSAdvanced

Public Members

public mws: * source

Public Methods

public async callEndpoint(name: string, callOptions: object, opt: object): any source

Call a known endpoint at MWS, returning the raw data from the function. Parameters are transformed and validated according to the rules defined in lib/endpoints

Params:

NameTypeAttributeDescription
name string

name of MWS API function to call

callOptions object
  • optional

named hash object of the parameters to pass to the API

callOptions.feedContent string
  • optional

if calling a function that submits a feed, supply the feed data here

callOptions....rest any
  • optional

other parameters will be passed through validation and into the API

opt object
  • optional

options for callEndpoint

opt.noFlatten boolean
  • optional

do not flatten results

opt.returnRaw boolean
  • optional

return only the raw data (may or may not be flattened)

opt.saveRaw string
  • optional

filename to save raw data to (may or may not be flattened)

opt.saveParsed string
  • optional

filename to save final parsed data to (not compatible with returnRaw, since parsing won't happen)

opt.maxThrottleRetries int
  • optional
  • default: 2

maximum number of retries for throttling

Return:

any

Results of the call to MWS

public async doRequest(requestData: *, options: {}): * source

Params:

NameTypeAttributeDescription
requestData *
options {}
  • optional
  • default: {}

Return:

*

public getLowestPricedOffersForAsin(options: object): LowestPricedOffers source

getLowestPricedOffersForASIN

Calls GetLowestPricedOffersForASIN, reformats results, and returns the data

Params:

NameTypeAttributeDescription
options object

see https://docs.developer.amazonservices.com/en_UK/products/Products_GetLowestPricedOffersForASIN.html

options.MarketplaceId string

Marketplace ID to search

options.ASIN string

ASIN to search for

options.ItemCondition string

Listing Condition: New, Used, Collectible, Refurbished, Club

public getLowestPricedOffersForSku(options: object): LowestPricedOffers source

getLowestPricedOffersForSKU

Calls GetLowestPricedOffersForSKU, reformats results, and returns the data

Params:

NameTypeAttributeDescription
options object

see https://docs.developer.amazonservices.com/en_UK/products/Products_GetLowestPricedOffersForASIN.html

options.MarketplaceId string

Marketplace ID to search

options.SellerSKU string

SKU to search for

options.ItemCondition string

Listing Condition: New, Used, Collectible, Refurbished, Club

public getMarketplaces(params: ...*): MarketDetail source

Call MWS ListMarketplaceParticipations, return parsed results

Params:

NameTypeAttributeDescription
params ...*

Return:

MarketDetail

Example:

const marketplaces = (async () => await mws.getMarketplaces())();
(async function() {
   const result = await mws.getMarketplaces();
   console.log(result);
})();

public getMatchingProductForId(options: Object): Product[] source

Returns a list of products and their attributes, based on a list of ASIN, GCID, SellerSKU, UPC, EAN, ISBN, or JAN values

Params:

NameTypeAttributeDescription
options Object

see https://docs.developer.amazonservices.com/en_UK/products/Products_GetMatchingProductForId.html

options.marketplaceId string

Identifier for marketplace (see getMarketplaces)

options.idType string

Type of lookup to perform: ASIN, GCID, SellerSKU, UPC, EAN, ISBN, JAN

options.idList string[]

List of codes to perform lookup on

Return:

Product[]

public getMyFeesEstimate(-: EstimateRequest[]): Object source

Get an estimate of fees for an item, based on listing and shipping prices.

Params:

NameTypeAttributeDescription
- EstimateRequest[]

Array of EstimateRequest items to get fees for

Return:

Object

Object of Estimate items, indexed by EstimateRequest Identifier

public getOrder(options: object, options: string[]): object source

Return orders by ID, i.e. Amazon Order ID. see https://docs.developer.amazonservices.com/en_UK/orders-2013-09-01/Orders_GetOrder.html

Params:

NameTypeAttributeDescription
options object
options string[]

A list of AmazonOrderId values. An AmazonOrderId is an Amazon-defined order identifier, in 3-7-7 format.

Return:

object

A list of orders

public getProductCategoriesForAsins(parameters: object): productCategoryByAsin[] source

return product categories for multiple asins

Params:

NameTypeAttributeDescription
parameters object
parameters.marketplaceId string

marketplace identifier to run query on

parameters.asins string[]

Array of string ASINs to query for

Return:

productCategoryByAsin[]

Array of product category information

public getProductCategoriesForSkus(parameters: object): productCategoryBySku[] source

return product categories for multiple SKUs

Params:

NameTypeAttributeDescription
parameters object
parameters.marketplaceId string

marketplace identifier to run query on

parameters.skus string[]

Array of string SKUs to query for

Return:

productCategoryBySku[]

Array of product category information

public getReport(options: object): Array | object source

Download a specific report identified by the ReportId and return it

Params:

NameTypeAttributeDescription
options object

GetReport options, should contain a [ReportId]

options.ReportId string

Report number from [GetReportList] or [GeneratedReportId] from [GetReportRequestListResult]

Return:

Array | object

Contents of the report to return (format may vary WIDELY between different reports generated, see ReportType)

Example:

mws.getReport({ ReportId: '12660293969017879' });

public getReportList(params: ...*): * source

TODO: write documentation for getReportList

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public getReportListAll(params: ...*): * source

TODO: write documentation for getReportListAll (or see comment on getReportListByNextToken)

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public getReportListByNextToken(params: ...*): * source

TODO: write documentation for getReportListByNextToken (or just roll getReportList and getReportListByNextToken into the same wrapper) (that wrapper might be getReportListAll, and just rename it)

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public getReportRequestList(options: object, ReportRequestIdList: string[], ReportTypeList: string[], ReportProcessingStatusList: string[], MaxCount: number, RequestedFromDate: Date, RequestedToDate: Date): GetReportRequestListResult[] source

Returns a list of report requests that you can use to get the ReportRequestId for a report After calling requestReport, you should call this function occasionally to see if/when the report has been processed.

Params:

NameTypeAttributeDescription
options object
  • optional

Options to pass to GetReportRequestList

ReportRequestIdList string[]
  • optional

List of report request IDs @see requestReport

ReportTypeList string[]
  • optional

List of Report Types @see REQUEST_REPORT_TYPES

ReportProcessingStatusList string[]
  • optional

List of Report Processing Status @see REPORT_PROCESSING_STATUS_TYPES

MaxCount number
  • optional
  • default: 10

Maximum number of report requests to return, max is 100

RequestedFromDate Date
  • optional
  • default: 90-days-past

Oldest date to search for

RequestedToDate Date
  • optional
  • default: Now

Newest date to search for

public getReportScheduleList(params: ...*): * source

TO DO: WRITE DOCUMENTATION

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public init(config: object): mws-simple source

Initialize mws-advanced with your MWS access keys, merchantId, optionally authtoken, host, port If accessKeyId, secretAccessKey, and/or merchantId are not provided, they will be read from the environment variables MWS_ACESS_KEY, MWS_SECRET_ACCESS_KEY, and MWS_MERCHANT_ID respectively

Params:

NameTypeAttributeDescription
config object

Contains your MWS Access Keys/Tokens and options to configure the API

config.accessKeyId string
  • optional
  • default: process.env.MWS_ACCESS_KEY

Your MWS Access Key

config.secretAccessKey string
  • optional
  • default: process.env.MWS_SECRET_ACCESS_KEY

Your MWS Secret Access Key

config.merchantId string
  • optional
  • default: process.env.MWS_MERCHANT_ID

Your MWS Merchant ID

config.authToken string
  • optional

If making a call for a third party account, the Auth Token provided for the third party account

config.region string
  • optional
  • default: 'NA'

One of the Amazon regions as specified in https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html

config.host string
  • optional
  • default: 'mws.amazonservices.com'

Set MWS host server name, see https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html

config.port number
  • optional
  • default: 443

Set MWS host port

Return:

mws-simple

The mws-simple instance used to communicate with the API

Example:

const mws = MWS.init({ region: 'NA', accessKeyId: '1234', secretAccessKey: '2345', merchantId: '1234567890' });
const mws = MWS.init({ region: 'EU', accessKeyId, ... });
const mws = MWS.init({ authToken: 'qwerty', accessKeyId, ...});
const mws = MWS.init({ host: 'alternate-mws-server.com', accessKeyId, ... });

public listFinancialEvents(options: object): object source

https://docs.developer.amazonservices.com/en_UK/finances/Finances_ListFinancialEvents.html

Params:

NameTypeAttributeDescription
options object
options.maxResultsPerPage number

Maximum number of results to return (1 <=> 100)

options.amazonOrderId string

An order number to search for

options.financialEventGroupId string

Type of Financial Event to search for

options.postedAfter Date

When to search for events after

options.postedBefore Date

When to search for events prior to

Return:

object

public listInventorySupply(options: object): {nextToken: string, supplyList: object[]} source

Return information about the availability of a seller's FBA inventory

Params:

NameTypeAttributeDescription
options object
options.sellerSkus String[]

A list of SKUs for items to get inventory info for

options.queryStartDateTime Date

Date to begin searching at

options.responseGroup string

'Basic' = Do not include SupplyDetail, 'Detailed' = Do

options.marketplaceId string

Marketplace ID to search

Return:

{nextToken: string, supplyList: object[]}

public listMatchingProducts(options: object): Product[] source

Return a list of products and their attributes, based on a text query and contextId.

Params:

NameTypeAttributeDescription
options object
options.marketplaceId string

marketplace identifier to search

options.query string

a search string "with the same support as that provided on Amazon marketplace websites"

options.queryContextId string
  • optional

context in which to limit search. Not specified will mean "search everywhere". See https://docs.developer.amazonservices.com/en_UK/products/Products_QueryContextIDs.html

Return:

Product[]

Array of product information

public listOrderItems(AmazonOrderId: string): OrderItemList source

Returns order items based on the AmazonOrderId that you specify.

If you've pulled a list of orders using @see ListOrders, or have order identifiers stored in some other fashion, then to find out what items are actually on the orders, you will need to call ListOrderItems to obtain details about the items that were ordered. The ListOrders call does not give you any information about the items, except how many of them have shipped or not shipped.

If an Order is in the Pending state, ListOrderItems will not return any pricing or promotion information. Once an order has left the Pending state, the following items will be returned:

ItemTax, GiftWrapPrice, ItemPrice, PromotionDiscount, GiftWrapTax, ShippingTax, ShippingPrice, ShippingDiscount

Params:

NameTypeAttributeDescription
AmazonOrderId string

3-7-7 Amazon Order ID formatted string

Return:

OrderItemList

public listOrders(options: object): object source

Return orders created or updated during a specific time frame see https://docs.developer.amazonservices.com/en_UK/orders-2013-09-01/Orders_ListOrders.html At least ONE of the search options (and maybe more depending on which ones you select) must be specified. Error messages may or may not return information on what parameters you are missing. If you are having trouble, see the official parameter documentation above.

Params:

NameTypeAttributeDescription
options object
options.MarketplaceId string[]

Array of Marketplace IDs to search @see MWS_MARKETPLACES

options.CreatedAfter Date
  • optional

Select orders created at or after the given Date

options.CreatedBefore Date
  • optional

Select orders created at or before the given Date

options.LastUpdatedAfter Date
  • optional

Select orders updated at or after the given Date

options.LastUpdatedBefore Date
  • optional

Select orders updated at or before the given Date

options.OrderStatus string
  • optional

OrderStatus, see MWS doc page

options.FulfillmentChannel string
  • optional

AFN for Amazon fulfillment, MFN for merchant

options.PaymentMethod string
  • optional

All, COD, CVS, Other

options.BuyerEmail string
  • optional

Search for orders with given Email address

options.SellerOrderId string
  • optional

Specified seller order ID

options.MaxResultsPerPage string
  • optional
  • default: 100

Max number of results to return, 1 <=> 100

options.TFMShipmentStatus string
  • optional

See MWS doc page

Return:

object

public manageReportSchedule(params: ...*): * source

TO DO: WRITE DOCUMENTATION

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public parseEndpoint(outParser: *, inParser: *): * source

Params:

NameTypeAttributeDescription
outParser *
inParser *
  • optional

Return:

*

public requestAndDownloadReport(params: ...*): * source

TODO: Document requestAndDownloadReport

Params:

NameTypeAttributeDescription
params ...*

Return:

*

public requestReport(options: object, MarketplaceId: string[]): ReportRequestInfo source

Request a report from MWS Many optional parameters may be required by MWS! Read ReportType for specifics!

Params:

NameTypeAttributeDescription
options object
options.ReportType string

Type of Report to Request @see REQUEST_REPORT_TYPES

options.StartDate Date
  • optional

Date to start report

options.EndDate Date
  • optional

Date to end report at

options.ReportOptions object
  • optional

Reports may have additional options available. Please see the ReportType official docs

MarketplaceId string[]
  • optional

Array of marketplace IDs to generate reports covering

public updateReportAcknowledgements(params: ...*): * source

TO DO: WRITE DOCUMENTATION

Params:

NameTypeAttributeDescription
params ...*

Return:

*