The most commonly used operation of the Amazon Product Advertising API is ItemSearch. This operation is used to return products that match your search criteria which can include keywords, titles, authors, artists, and publisher to name only a few.

For instance if we wanted to search for books that have been written by Jim Butcher then we could do an ItemSearch by Author with a SearchIndex of “Books”. When getting started it is important to note that you must specify a valid criteria and search index or no search will be performed and the Amazon Product Advertising API will return an error.

// Setup and Configure API
$api = new AmazonProductAPI();
... //set public,private, and associate key/id

// Setup Request
$request = new AmazonProduct_Request();
$request->Operation = AmazonProduct_Operation::ITEM_SEARCH;
$request->Author = "Jim Butcher";
$request->SearchIndex = AmazonProduct_SearchIndex::BOOKS;

// Send Request
$response = $api->search( $request );

// verify and use the response
if( $response->isSuccess() ) {
    foreach( $response->Items as $item ) {
        //consume Item
        echo $item->ASIN;

The ItemSearch operation is a very useful tool but it is only as helpful as the criteria you input, be specific. Specify as much information you know on the product including they type (Book, DVD, CD, etc) this way you get relevant results and not hundreds of useless ones.

Setting the Operation to ItemSearch

To set the operation you can either specify “ItemSearch” as a string or use the ITEM_SEARCH constant of the AmazonProduct_Operation class.

$request->Operation = "ItemSearch";

$request->Operation = AmazonProduct_Operation::ITEM_SEARCH;

Setting the Search Criteria

You’re results are only as good as the search criteria you send to the Amazon Product Advertising API therefore be as specific as you can. You can specify an Author, Artist, Title, Manufacturer and Keywords in addition to other options. For a full list visit the Search Index and ItemSearch Parameters Combinations page of the Amazon Developer’s Guide.

$request->Author = "Jim Butcher";
$request->Keywords = "Dresden Files,Codex Alera"

Setting the SearchIndex

Most of the time you will find yourself searching for products of a particular type e.g. books, dvds, etc. The SearchIndex allows you to specify the category or type of product you want to search in. There are a multitude of indexes which are all defined in the AmazonProduct_SearchIndex class.

$request->SearchIndex = "Books";

$request->SearchIndex= AmazonProduct_SearchIndex::BOOKS;

Specifying your desired response types

The ItemLookup operation returns by default a product’s ASIN, DetailPageURL, Manufacturer, ProductGroup, and ItemAttributes (including Title). However if you wanted to return the product’s images or similar products you can specify that in the ResponseGroup variable by providing a comma delimited list of response groups. Also it is possible for their to be more than 10 results returned therefore you will need to iterate over the results. For a full overview on how to iterate or page through the results then please read the tutorial: How to Iterate through Amazon Product Results

$request->ResponseGroup = "MEDIUM," . AmazonProduct_ResponseGroup::IMAGES;

Full ItemSearch Documentation

To review the full set of options that can be utilized when performing an ItemSearch please visit the ItemSearch page of the Amazon Product Advertising API.

Comments & Questions

Add Your Comment