Generating Best Selling Items with Amazon Product Advertising API

As part of a side project that I have been working on in my spare time, I've created a website called Deal Hammer which can be used to search the depths of Amazon for discounted items and free super saver delivery etc.

One of the features i wanted to add to my site was to be able to pull a list of the best selling items back from the API. Now with the Amazon Product Advertising API, there is, as some of you will know, no option or quick way to pull back these items.

You could head over to the affiliate site and use their tool to generate a custom link with your associates tag to 1 specific item (repeat for how ever many items you want link for) and update them every week or so, but that defeats the point of making a dynamic website, plus it would be a massive time waster also!

Another option is to use their RSS feed and parse the XML, which works quite well, but you don't really have much control over the data you display, the issue i found was that Amazon brought back a HTML description of each item, which you could happily just print out, but playing about with that data meant having to override the CSS and you couldn't really alter the text or the content, without really putting some work into it. This is also pretty bad if you intend to get ranked on the search engines, since you are just posting duplicate data and not adding any real value to your site.



So with this in mind, I decided to use the API to do this programmatically...

My Solution

As i mentioned above, there is no easy or at least quick way to pull back the best selling items (Or at least I don't think there are!) Personally I don't know why Amazon didn't include a feature to pull back best selling items by passing in a category (Browse Node) for example, but that's just the way it is.

First get the BrowseNode IDs

Anyway to get the best selling items, you need to first perform a BrowseNodeLookup and pass in the category (Browse Node). For my project I am using PHP to issue a signed request to Amazons servers, your might be using a different language, but regardless it should look similar to the following:
'Operation' => 'BrowseNodeLookup', 'BrowseNodeId' => '1025616', 'ResponseGroup' => 'TopSellers'

Where 1025616 is the UK Category - Video Games. This should return back the 10 most popular items  for that category. You might think, well that's all i need, BUT Amazon only returns the ASIN amongst a few other things, but if you want to show a Title, price, image or anything else you will need to perform an ItemLookup with your ASIN's.

Perform an ItemLookup with your returned ASIN's

The next thing to do is perform an ItemLookup using the list of ASIN's you got back from the BrowseNodeLookup.

The ItemLookup allows you to search up to 10 items at once, (you should really be doing this as apposed to doing a separate lookup for each item as this saves on API calls and is more efficient).

You need to let Amazon know that you intend to do a lookup based on the ASIN, so you'll need to pass that in as a parameter.

In order to do multiple lookups in one request, just pass in an comma separated list of ASIN's. You can supply up to 10 ASIN's in one go.

10,20,30,40,50 etc...

Below is an example of the request you would send to Amazon:
'Operation' => 'ItemLookup',
 'ItemId' => 'LIST OF ASIN's HERE (UPTO 10)',
 'IdType' => 'ASIN',
 'ResponseGroup' => 'Images,ItemAttributes,Offers'
You can replace the ResponseGroup with whichever options you prefer and this should bring you back the 10 best selling items based on the category you supplied!

All you need to do now is present them in a orderly fashion to your viewers.

Hope that helps!

Comments

Popular posts from this blog

Error Using Python Requests Library - TypeError: 'dict' object is not callable

Setting the path on Google Cookie Choices