Getting Started

In this section, you will learn to use the API to search for items on Amazon using our Javascript client. We will do that by creating a sample page to display the search results for "Headphones".

Step 1

Create a blank HTML file. Then add jQuery and CommerceDNA scripts to your HTML file:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script src="https://amazon.commercedna.com/sign?awsId=****&&awsSecret=****&redirect=/search/js/client.js"></script>

Fork this code »

Replace awsId and awsSecret in the CommerceDNA script with your Amazon associate credentials.

Step 2

Lets initialize CommerceDNA to search for "headphones":

<script type="text/javascript"> searchAPI = CommerceDNA.itemSearch({keywords:'headphones'}); jQuery('body').append(JSON.stringify(searchAPI)); </script>

Fork this code »

If you are able to see the "search filters" on the webpage, your credentails are correct and working fine with the script.

Step 3

Now, you can fetch the results for "headphones:"

searchAPI.getPage(1).then(function(rslt){ jQuery('body').append('<pre>'+JSON.stringify(rslt, null, 2)+'</pre>'); });

Fork this code »

You should be able to see the results as JSON on your webpage.

Implementing Search page »