

Features for Connection to Amazon Marketplace Web Service (MWS) API
To explore the Amazon MWS API, let’s consider the process of getting a list of orders.
The MWS transmitted data format is not JSON as well as not XML, but this is some unique
format of its own, in which the attachment is done using the delimiter ".". So, if you
need to transfer the key embedded in the key "a", the key "b" with the value "c",
which could be done using json as follows - {"a":{"b":"c"}} , then you will have
to transfer the key "a.b" with the value "c" in MWS. The format of the received data is XML.
The request signature is generated using several parameters: "AWSAccessKeyId" is provided
by Amazon, "SellerId" is a 14-digit unique identifier of the Amazon seller, consisting of
letters and numbers, "MWSAuthToken" is a trusted developer’s token, which will be
described later, "SignatureVersion" is the version of the method of receiving the
signature, for example, "2", "Timestamp" is the date and time the request was sent
in the format "ISO 8601", "Version" is the version of the specific API branch in
the format "YYYY-MM-DD", so for the Orders API this is "2013-09-01", "SignatureMethod"
is a method of obtaining a signature, for example,"HmacSHA256".
As for "SellerId" and "MWSAuthToken", here you need to take into account the specifics
of Amazon to provide developers with access to seller accounts. First, you need to
transfer the account to developer mode. After that, other sellers will be able to
provide the newly created developer access to manage their data via the API. In the
seller’s personal account, there is a list of trusted developers, each of whom is
assigned a special key "MWSAuthToken", which must be provided to the developer for
signing API-queries along with "SellerId". Since the seller, who has become a
developer, does not need to provide access to himself, then when making queries
on its own behalf, the key "MWSAuthToken" with the value "" should be specified.
Amazon does not provide sandbox-mode, and therefore all the work on the connection will
be carried out according to real data. Requests signing debugging can be done under
GET-requests, and if something more complicated happens, there may be a risk of
breakdown. To send requests you need to use the URL
https://mws.amazonaws.com/
.
After the request signature has been debugged, the API can receive some data from
your personal account, for example, a list of orders. All API functionality is
divided into branches by the entities, on which the work is done: Orders, Products,
Fulfillment Inbound Shipments, Fulfillment Outbound Shipments, Feeds, etc. We will
use OrdersAPI,
http://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Overview.html
.
To get a list of orders, you need to use the GET-request at
https://mws.amazonaws.com/Orders/2013-09-01
with the "Action" parameter with the
"ListOrders" value. The "Action" parameter is used in both GET- and POST-queries,
and uniquely determines the current functionality of the API. In addition, filter
parameters can be specified for ListOrders, but the basic request can be made without
them. So, if the request signature is debugged, when executing the request, the XML
with the root element ListOrdersResponse, the first-level element ListOrdersResult and
the second-level element Orders, which groups the list of Order elements, each of which
is an XML API representation of the order in Amazon (Fig. 1 ), should return to the
above-mentioned URL. Pagination is implemented not by any another query-parameter,
but by another value of the "Action" parameter, "ListOrdersByNextToken". So, if the
request for "ListOrders" returned a second-level element "NextToken", the seller has
more than 100 orders. In this case, one more request with the parameters "Action"
with the "ListOrdersByNextToken" value and "NextToken" with the value of "NextToken"
from the last request should be made. All subsequent pagination pages are obtained
through "ListOrdersByNextToken".

Each order has, for example, the string properties AmazonOrderId, PurchaseDate,
OrderStatus and nested ShippingAddress, OrderTotal and others. The order information
itself is quite impractical for use on the website, so to complete the picture, you
need to get related products. To do this, first, make a request with "Action" with the
"GetOrder" value, passing also the parameter "AmazonOrderId" with the value of the
corresponding element "AmazonOrderId" from the response to the request "ListOrders"
or "ListOrdersByNextToken". The response will have a list of products identified by
the value of the ASIN field (Fig. 2). Data on the products themselves must be obtained
from another branch, Products API,
https://mws.amazonaws.com/Products/2011-10-01
, and the following parameters should be specified in the request:
"Action"-"GetMatchingProduct", "ASINList. ASIN.1"- ASIN of the required product.
To optimize the number of queries to API, you can specify up to 10 ASIN products,
passing them respectively as parameter values "ASINList.ASIN.2",
"ASINList.ASIN.3", ..., "ASINList.ASIN.10". For this branch, respectively, the
"2011-10-01" value for the "Version" parameter will be used in the request signature.
The structure of the response can be seen in Fig. 3.


As for the rest, it is necessary to implement error handling and integration with business
logic. Also for each "Action", Amazon has its own limits on the number and frequency of
queries, which, if necessary, must be monitored separately.
As well, in some queries, the "MarketplaceId" parameter, which defines the "submarket",
can be passed. In addition, the market itself is determined by the domain.
So for the USA and Brazil, the domain https://mws.amazonservices.com is used, and the value of the "MarketplaceId" parameter for the USA is "ATVPDKIKX0DER", and for Brazil it is "A2Q3Y263D00KWC", for viewing a full list, see http://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html .
Articles You May Also Be Interested In


Ready to Start? Let Us Know!
Ukraine, Zhytomyr
Vitruka Street, 9V
M-F, 9am — 7pm
Poland, Warsaw, 00-842
Łucka street 15/204
M - F, 9am - 7pm