Understanding the Amazon Product Advertising API

Product Advertising APIThe Amazon Product Advertising API allows you to to do a lot of stuff. Using their REST interface you can browse the entire catalogue of Amazon products, get the prices pictures, descriptions and reviews for just about everything. It’s also possible to use Amazon’s shopping cart. Using this API it is possible to create you’re own e-commerse website with none of your own inventory, and without having to deal with credit card payments or the hassles that most e-commerse stores deal with.

It would be interesting to come up with you’re own value-add to the Amazon experience and offer that through your own website. Just off the top of my head that might be something like

  • a Digg like site for products where people thumb up things like like
  • A more stream lined webpage for looking at reviews
  • A niche website that finds and sells just a small subset of the products
  • A College specific site with links to the books used for each course

There are a lot of possibilities but to get started you need to understand how Amazon organizes and presents this information.

Once you sign up as an Amazon Associate and get the keys you need to access the service you can build the request URL that will return some XML with the information you asked for or any error messages.

Each REST request will require an Operation argument. Each operation has a number of required and optional arguments. For example the “Operation=ItemSearch” will return the items that match the search criteria. The type of information you get back is determined by the ResponseGroup required argument. You can get back just the images for a product by requesting ResponseGroup=Image, or get the editorial review by requesting ResponseGroup=EditorialReview. There are some product specific response groups such as Tracks that are valid for music albums.

When trying to dig through the available products you need to use Amazons own hierarcy of product categories to find what you want. These are called BrowseNodes. A BrowseNode is identified with a positive integer and given a name. They are created and deleted from the system regularly so you shouldn’t save them in your programs. BrowseNodes are hierarchical so the root node “Books” has many child nodes such as “Mystery” and “Non-Fiction” and those in turn have more children. As you can imagine a product may belong to multiple BrowseNodes and a BrowseNode can have multiple parent nodes.

The SearchIndex is the high level category for a product. This is a fixed list that includes: Books, DVD, Apparel, Music, and Software. By separating a search into a SearchIndex it allows Amazon to better optimize how they query their large catalog of available products. And it will return more relevant results for a search query.

So a REST request to the the Product Advertising API might look something like:

http://ecs.amazonaws.com/onca/xml?
Service=AWSECommerceService&
Operation=ItemSearch&
AWSAccessKeyId=[Access Key ID]&
AssociateTag=[ID]&
SearchIndex=Apparel&
Keywords=Shirt

This will return an XML document that contains a list of Shirts that are available as sell as information about each shirt. Because the SeachIndex is Apparel it will not return any books about Shirts.

You’ll need to reference the API documentation if you want to write anything using this. Be prepared.. the documentation is 600 pages long. It’s available here.

I hope this post gives you an idea about where to start with using Amazons Product Advertising API. I have written a few python scripts now that use it and will be cleaning them up this week to post here so stay tuned for that.