mws-sdk
SDK for Amazon Marketplace Web Services
Getting started
npm install --save @bizon/mws-sdk
Usage
const MWSClient = require('@bizon/mws-sdk')
const client = new MWSClient({
accessKeyId: '',
secretAccessKey: '',
sellerId: '',
mwsToken: '',
mwsRegion: ''
})
Region and Marketplaces
The MWS documentation defines a list of regions and marketplaces available in each region.
The marketplaces in a region do not all share a common API endpoint, so this library defines a new concept of MWS region, based on the API endpoint. Here’s the list of the available MWS regions:
Generic MWS regions:
Region | API Endpoint | Name |
---|
na | mws.amazonservices.com | North America |
eu | mws-eu.amazonservices.com | Europe |
fe | mws-fe.amazonservices.com | Far East |
Country specific MWS regions:
Region | API Endpoint | Name |
---|
ca | mws.amazonservices.ca | Canada |
mx | mws.amazonservices.com.mx | Mexico |
ae | mws.amazonservices.ae | United Arab Emirates |
in | mws.amazonservices.in | India |
jp | mws.amazonservices.jp | Japan |
au | mws.amazonservices.com.au | Australia |
This library also allows to specify a list of marketplaces (either 2 letter country codes or Marketplaces IDs) so you can restrict API calls to your marketplace participations:
const client = new MWSClient({
accessKeyId: '',
secretAccessKey: '',
sellerId: '',
mwsToken: '',
marketplaces: [
'A1F83G8C2ARO7P',
'fr'
]
})
Keep in mind that the specified marketplaces will have to be in the same MWS region, otherwise an error will be thrown.
Error handling
Whenever the MWS API returns a non 200 HTTP status, a MWSError
will be thrown. Use error.body
to inspect the contents of the error, and error.response
to access the raw HTTP response.
const {MWSError} = '@bizon/mws-sdk'
try {
const result = await client.products.getLowestPricedOffersForSku({
marketplaceId: 'A1F83G8C2ARO7P',
sellerSku: 'some-sku',
itemCondition: 'new'
})
} catch (error) {
if (error instanceof MWSError) {
console.log(error.body)
console.log(error.response.statusCode)
}
}
API
Finances
listFinancialEvents
const result = await client.finances.listFinancialEvents({
})
Options:
Name | Type | Default |
---|
maxResultsPerPage | Number | 100 |
amazonOrderId | String | |
financialEventGroupId | String | |
postedAfter | Date | |
postedBefore | Date | |
nextToken | String | |
listFinancialEventGroups
const result = await client.finances.listFinancialEventGroups({
})
Options:
Name | Type | Default |
---|
maxResultsPerPage | Number | 100 |
financialEventGroupStartedAfter | Date | |
financialEventGroupStartedBefore | Date | |
nextToken | String | |
FulfillmentInboundShipment
getBillOfLading
const result = await client.fulfillmentInboundShipment.getBillOfLading({
})
Options:
Name | Type | Default |
---|
shipmentId | String | |
listInboundShipments
const result = await client.fulfillmentInboundShipment.listInboundShipments({
})
Options:
Name | Type | Default |
---|
shipmentStatusList | Array<String> | |
shipmentIdList | Array<String> | |
lastUpdatedAfter | Date | |
lastUpdatedBefore | Date | |
nextToken | String | |
listInboundShipmentItems
const result = await client.fulfillmentInboundShipment.listInboundShipmentItems({
})
Options:
Name | Type | Default |
---|
shipmentId | Array<String> | |
lastUpdatedAfter | Date | |
lastUpdatedBefore | Date | |
nextToken | String | |
FulfillmentInventory
listInventorySupply
const result = await client.fulfillmentInventory.listInventorySupply({
})
Options:
Name | Type | Default |
---|
sellerSkus | Array<String> | |
queryStartDateTime | Date | |
responseGroup | String | |
marketplaceId | String | |
nextToken | String | |
Orders
getOrders
const result = await client.orders.getOrders({
})
Options:
Name | Type | Default |
---|
amazonOrderIds | Array<String> | |
listOrders
const result = await client.orders.listOrders({
})
Options:
Name | Type | Default |
---|
createdAfter | Date | |
createdBefore | Date | |
lastUpdatedAfter | Date | |
lastUpdatedBefore | Date | |
orderStatus | String | |
marketplaceId | Array<String> | Selected region’s marketplaces |
fulfillmentChannel | String | |
paymentMethod | String | |
buyerEmail | String | |
sellerOrderId | String | |
maxResultsPerPage | Number | 100 |
tfmShipmentStatus | String | |
nextToken | String | |
listOrderItems
const result = await client.orders.listOrderItems({
})
Options:
Name | Type | Default |
---|
amazonOrderId | String | |
nextToken | String | |
Products
listMatchingProducts
const result = await client.products.listMatchingProducts({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
query | String | |
queryContextId | String | |
getMatchingProduct
const result = await client.products.getMatchingProduct({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
asinList | Array<String> | |
getMatchingProductForId
const result = await client.products.getMatchingProductForId({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
idType | String | |
idList | Array<String> | |
getMyPriceForAsin
const result = await client.products.getMyPriceForAsin({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
asinList | Array<String> | |
itemCondition | String | |
getMyPriceForSku
const result = await client.products.getMyPriceForSku({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
sellerSkuList | Array<String> | |
itemCondition | String | |
getLowestPricedOffersForAsin
const result = await client.products.getLowestPricedOffersForAsin({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
asin | String | |
itemCondition | String | |
getLowestPricedOffersForSku
const result = await client.products.getLowestPricedOffersForSku({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
sellerSku | String | |
itemCondition | String | |
Reports
requestReport
const result = await client.reports.requestReport({
})
Options:
Name | Type | Default |
---|
reportType | String | |
startDate | Date | |
endDate | Date | |
marketplaces | Array<String> | |
reportOptions | String | |
getReportRequestList
const result = await client.reports.getReportRequestList({
})
Options:
Name | Type | Default |
---|
reportRequestIdList | Array<String> | |
reportTypeList | Array<String> | |
reportProcessingStatusList | Array<String> | |
maxCount | Number | 100 |
requestedFromDate | Date | |
requestedToDate | Date | |
nextToken | String | |
getReportList
const result = await client.reports.getReportList({
})
Options:
Name | Type | Default |
---|
maxCount | Number | 100 |
reportTypeList | Array<String> | |
acknowledged | Boolean | |
reportRequestIdList | Array<String> | |
availableFromDate | Date | |
availableToDate | Date | |
nextToken | String | |
getReport
const result = await client.reports.getReport({
})
Options:
Name | Type | Default |
---|
reportId | String | |
format | Enum[raw, base64] | |
Sellers
listMarketplaceParticipations
const result = await client.sellers.listMarketplaceParticipations({
})
Options:
Name | Type | Default |
---|
nextToken | String | |
Subscriptions
registerDestination
const result = await client.subscriptions.registerDestination({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
sqsQueueUrl | String | |
deregisterDestination
const result = await client.subscriptions.deregisterDestination({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
sqsQueueUrl | String | |
sendTestNotificationToDestination
const result = await client.subscriptions.sendTestNotificationToDestination({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
sqsQueueUrl | String | |
createSubscription
const result = await client.subscriptions.createSubscription({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
sqsQueueUrl | String | |
isEnabled | Boolean | true |
notificationType | String | |
deleteSubscription
const result = await client.subscriptions.deleteSubscription({
})
Options:
Name | Type | Default |
---|
marketplaceId | String | |
sqsQueueUrl | String | |
notificationType | String | |
parseNotification
const result = await client.subscriptions.parseNotification('<any-xml />')
Options: Takes an XML string.
The following notifications are supported:
Test
AnyOfferChanged
FeedProcessingFinished
ReportProcessingFinished
Common
All entities except reports
support a getServiceStatus
method to retrieve the API status.
License
MIT
Miscellaneous
╚⊙ ⊙╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝
╚═(███)═╝