mws-zodane-advanced
Version:
fixed throtal resend
344 lines (333 loc) • 19.8 kB
HTML
<html>
<head>
<meta charset="utf-8">
<base data-ice="baseUrl" href="../">
<title data-ice="title">Manual | mws-advanced</title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
<script src="script/prettify/prettify.js"></script>
<script src="script/manual.js"></script>
</head>
<body class="layout-container manual-root" data-ice="rootContainer">
<header>
<a href="./">Home</a>
<a href="identifiers.html">Reference</a>
<a href="source.html">Source</a>
<div class="search-box">
<span>
<img src="./image/search.png">
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
</span>
<ul class="search-result"></ul>
</div>
</header>
<nav class="navigation" data-ice="nav"><div class="manual-toc-root">
<div data-ice="manual">
<ul class="manual-toc">
<li data-ice="manualNav" class="indent-h1" data-link="manual/getting-started.html"><a href="manual/getting-started.html" data-ice="link">Getting Started</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/getting-started.html"><a href="manual/getting-started.html#prerequisites" data-ice="link">Prerequisites</a></li>
<li data-ice="manualNav" class="indent-h3" data-link="manual/getting-started.html"><a href="manual/getting-started.html#getting-your-mws-credentials" data-ice="link">Getting your MWS credentials</a></li>
<li data-ice="manualNav" class="indent-h3" data-link="manual/getting-started.html"><a href="manual/getting-started.html#official-mws-api-documentation" data-ice="link">Official MWS API documentation</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/getting-started.html"><a href="manual/getting-started.html#installation" data-ice="link">Installation</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/getting-started.html"><a href="manual/getting-started.html#creating-the-connection-to-mws" data-ice="link">Creating the connection to MWS</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/getting-started.html"><a href="manual/getting-started.html#calling-mws-advanced-apis" data-ice="link">Calling mws-advanced APIs</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/getting-started.html"><a href="manual/getting-started.html#calling-mws-apis-directly" data-ice="link">Calling MWS APIs directly</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/getting-started.html"><a href="manual/getting-started.html#using-your-api-access-for-a-different-amazon-seller--authtoken-" data-ice="link">Using your API access for a different Amazon Seller (authToken)</a></li>
</ul>
</div>
<div data-ice="manual">
<ul class="manual-toc">
<li data-ice="manualNav" class="indent-h1" data-link="manual/usage.html"><a href="manual/usage.html" data-ice="link">Usage</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/usage.html"><a href="manual/usage.html#basic-usage" data-ice="link">Basic Usage</a></li>
<li data-ice="manualNav" class="indent-h3" data-link="manual/usage.html"><a href="manual/usage.html#async-await-example" data-ice="link">async/await Example</a></li>
<li data-ice="manualNav" class="indent-h3" data-link="manual/usage.html"><a href="manual/usage.html#promises-example" data-ice="link">Promises Example</a></li>
<li data-ice="manualNav" class="indent-h3" data-link="manual/usage.html"><a href="manual/usage.html#example-of-passing-parameters-in-as-an-object" data-ice="link">Example of passing parameters in as an object</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/usage.html"><a href="manual/usage.html#obtaining-marketplace-values" data-ice="link">Obtaining Marketplace Values</a></li>
<li data-ice="manualNav" class="indent-h2" data-link="manual/usage.html"><a href="manual/usage.html#advanced-usage" data-ice="link">Advanced Usage</a></li>
<li data-ice="manualNav" class="indent-h3" data-link="manual/usage.html"><a href="manual/usage.html#using-an-authtoken-to-operate-on-someone-else--39-s-mws-account" data-ice="link">Using an authToken to operate on someone else's MWS account</a></li>
<li data-ice="manualNav" class="indent-h3" data-link="manual/usage.html"><a href="manual/usage.html#report-processing" data-ice="link">Report Processing</a></li>
</ul>
</div>
</div>
</nav>
<div class="content" data-ice="content"><div class="github-markdown" data-ice="content"><h1 id="getting-started">Getting Started</h1><h2 id="prerequisites">Prerequisites</h2><h3 id="getting-your-mws-credentials">Getting your MWS credentials</h3><p>To use the MWS API, you will need to obtain your MWS API credentials. Amazon will supply three
items that you will need to provide: Access Key Id, Secret Access Key, and Merchant ID.</p>
<p>If you do not have an Amazon Seller Central "Professional" account, you will need that to get
started. Signing up for Seller Central and information related to that is beyond the scope of this
manual, see <a href="http://sellercentral.amazon.com">Amazon Seller Central</a> for specifics.</p>
<p>When your Amazon Seller Central account is setup, navigate to the Settings menu (upper-right-corner)
and select "User Permissions" from the drop-down menu. After a few moments of waiting for the
entire page to finish loading, you should see a section titled "Amazon MWS Developer Permissions".
Note your Seller ID under the "Your Account Information" heading. Then, under the
"Current Authorizations" heading, you should see as the first line, your Developer ID, Store Name,
the date you created your API authorization, and a link titled "View your credentials".</p>
<p>Click "View your credentials", and a pop-up will appear with your Access Key ID. Make note of this,
then click "View" next to the "Secret Key" field. Make note of your Secret Access Key.</p>
<p>Now that you have your Access Key Id, Secret Access Key, and Merchant ID, you can begin using the
MWS API.</p>
<h3 id="official-mws-api-documentation">Official MWS API documentation</h3><p>You may find yourself wanting to refer to the official Amazon documentation, to determine how, when,
or why to use an API, or to find out information about what it returns, or what it is used for:</p>
<p><a href="https://developer.amazonservices.com/gp/mws/docs.html">Amazon MWS Web Service API Documentation</a></p>
<h2 id="installation">Installation</h2><p>As mws-advanced is still under heavy initial development, it is not currently available from the
global npm repository. You should install it from the github repo, as:</p>
<pre><code><code class="source-code prettyprint">npm install --save github:ericblade/mws-advanced</code>
</code></pre><h2 id="creating-the-connection-to-mws">Creating the connection to MWS</h2><p>Before you are able to use the mws-advanced API, you must initialize it with your MWS credentials.</p>
<pre><code><code class="source-code prettyprint">mws.init({
accessKeyId: 'Your Amazon MWS Access Key ID',
secretAccessKey: 'Your Amazon MWS Secret Access Key',
merchantId: 'Your Amazon MWS Merchant ID',
});</code>
</code></pre><h2 id="calling-mws-advanced-apis">Calling mws-advanced APIs</h2><p>mws-advanced implements several wrappers around the actual MWS API, which parse and process the XML
responses from MWS into a response format that is more easily readable in Javascript.</p>
<pre><code><code class="source-code prettyprint">(async function() {
const result = await mws.getMarketplaces();
console.log(result);
})();</code>
</code></pre><p>will return data that should look something like this sample data from an account that is registered
in the United States and Canadian markets:</p>
<pre><code><code class="source-code prettyprint">{
"markets": [
{
"MarketplaceId": "A2EUQ1WTGCTBG2",
"DefaultCountryCode": "CA",
"DomainName": "www.amazon.ca",
"Name": "Amazon.ca",
"DefaultCurrencyCode": "CAD",
"DefaultLanguageCode": "en_CA"
},
{
"MarketplaceId": "ATVPDKIKX0DER",
"DefaultCountryCode": "US",
"DomainName": "www.amazon.com",
"Name": "Amazon.com",
"DefaultCurrencyCode": "USD",
"DefaultLanguageCode": "en_US"
}
],
"marketParticipations": [
{
"MarketplaceId": "A2EUQ1WTGCTBG2",
"SellerId": "A3VRRE5P0AL2IX",
"HasSellerSuspendedListings": "No"
},
{
"MarketplaceId": "ATVPDKIKX0DER",
"SellerId": "A3VRRE5P0AL2IX",
"HasSellerSuspendedListings": "No"
}
],
"marketDetails": {
"A2EUQ1WTGCTBG2": {
"MarketplaceId": "A2EUQ1WTGCTBG2",
"DefaultCountryCode": "CA",
"DomainName": "www.amazon.ca",
"Name": "Amazon.ca",
"DefaultCurrencyCode": "CAD",
"DefaultLanguageCode": "en_CA",
"SellerId": "A3VRRE5P0AL2IX",
"HasSellerSuspendedListings": "No"
},
"ATVPDKIKX0DER": {
"MarketplaceId": "ATVPDKIKX0DER",
"DefaultCountryCode": "US",
"DomainName": "www.amazon.com",
"Name": "Amazon.com",
"DefaultCurrencyCode": "USD",
"DefaultLanguageCode": "en_US",
"SellerId": "A3VRRE5P0AL2IX",
"HasSellerSuspendedListings": "No"
}
}
}</code>
</code></pre><p>This looks, in my opinion, far, far better than the raw result data that results from calling MWS
"ListMarketplaceParticipations" directly, which you will see an example for in the next section.</p>
<h2 id="calling-mws-apis-directly">Calling MWS APIs directly</h2><p>For APIs that have not been wrapped, or if you wish to receive the raw data output from a direct
MWS API call for some reason, you can do that with the callEndpoint function:</p>
<pre><code><code class="source-code prettyprint">(async function() {
const result = await mws.callEndpoint('ListMarketplaceParticipations');
console.log(result);
})();</code>
</code></pre><p>For the same user that we called in the above "getMarketplaces" API, we receive the following data
back:</p>
<pre><code><code class="source-code prettyprint">{
"ListMarketplaceParticipationsResponse": {
"$": {
"xmlns": "https://mws.amazonservices.com/Sellers/2011-07-01"
},
"ListMarketplaceParticipationsResult": [
{
"ListParticipations": [
{
"Participation": [
{
"MarketplaceId": [
"A1MQXOICRS2Z7M"
],
"SellerId": [
"A3VRRE5P0AL2IX"
],
"HasSellerSuspendedListings": [
"No"
]
},
{
"MarketplaceId": [
"A2EUQ1WTGCTBG2"
],
"SellerId": [
"A3VRRE5P0AL2IX"
],
"HasSellerSuspendedListings": [
"No"
]
},
{
"MarketplaceId": [
"A2ZV50J4W1RKNI"
],
"SellerId": [
"A3VRRE5P0AL2IX"
],
"HasSellerSuspendedListings": [
"No"
]
},
{
"MarketplaceId": [
"ATVPDKIKX0DER"
],
"SellerId": [
"A3VRRE5P0AL2IX"
],
"HasSellerSuspendedListings": [
"No"
]
}
]
}
],
"ListMarketplaces": [
{
"Marketplace": [
{
"MarketplaceId": [
"A1MQXOICRS2Z7M"
],
"DefaultCountryCode": [
"CA"
],
"DomainName": [
"siprod.stores.amazon.ca"
],
"Name": [
"SI CA Prod Marketplace"
],
"DefaultCurrencyCode": [
"CAD"
],
"DefaultLanguageCode": [
"en_CA"
]
},
{
"MarketplaceId": [
"A2EUQ1WTGCTBG2"
],
"DefaultCountryCode": [
"CA"
],
"DomainName": [
"www.amazon.ca"
],
"Name": [
"Amazon.ca"
],
"DefaultCurrencyCode": [
"CAD"
],
"DefaultLanguageCode": [
"en_CA"
]
},
{
"MarketplaceId": [
"A2ZV50J4W1RKNI"
],
"DefaultCountryCode": [
"US"
],
"DomainName": [
"sim1.stores.amazon.com"
],
"Name": [
"Non-Amazon"
],
"DefaultCurrencyCode": [
"USD"
],
"DefaultLanguageCode": [
"en_US"
]
},
{
"MarketplaceId": [
"ATVPDKIKX0DER"
],
"DefaultCountryCode": [
"US"
],
"DomainName": [
"www.amazon.com"
],
"Name": [
"Amazon.com"
],
"DefaultCurrencyCode": [
"USD"
],
"DefaultLanguageCode": [
"en_US"
]
}
]
}
]
}
],
"ResponseMetadata": [
{
"RequestId": [
"9994df75-e1ec-4a59-ae71-68538df26b65"
]
}
]
}
}</code>
</code></pre><p>... what a big difference, right?</p>
<h2 id="using-your-api-access-for-a-different-amazon-seller--authtoken-">Using your API access for a different Amazon Seller (authToken)</h2><p>Amazon provides the ability to use the MWS API for different Amazon sellers, provided that they
have authorized you with the ability to access their API account, and have provided you with an
Authorization Token to do so. They can do this authorization via the same page that you received
your credentials from in the section titled "Getting your MWS Credentials". Once they provide you
with the Authorization Token and THEIR Merchant ID, then you can use mws-advanced to access their
account:</p>
<pre><code><code class="source-code prettyprint">mws.init({
accessKeyId: 'Your Amazon MWS Access Key ID',
secretAccessKey: 'Your Amazon MWS Secret Access Key',
merchantId: 'THEIR MWS Merchant ID',
authToken: 'THEIR authorization token for you',
});</code>
</code></pre></div>
</div>
<footer class="footer">
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.0.4)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>
<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>