How to do a Product Search

Currently the APaPi library only supports ItemSearch, ItemLookup and SimilarityLookup operations of the Amazon Product Advertising API. This brief tutorial will walk you through how to perform a search as well as how to interact with the results.

The AmazonProduct_Request Object

The AmazonProduct_Request object represents the query to be performed against the Amazon Product API. Once it has been populated with your search options it is passed to the AmazonProductAPI which then modifies it with your credentials and sends the request off to the service for processing. The below snippet shows how to generate a request that will search for a book by it’s title.

$request = new AmazonProduct_Request();
$request->Operation = "ItemSearch";
$request->ResponseGroup = "Large";
$request->Title="Wise Man's Fear";

Performing the search

The search is executed by calling the search method of the AmazonProductAPI instance with your instantiated request.

$api = new AmazonProductAPI();
// set configurations
$result = $api->search( $request );

Consuming the Results

The AmazonProduct_Result object is returned by the search and contains all the information returned by the Amazon Product API. The response has been converted into easy to use objects that can be accessed by their name. The below example shows how to get the large image returned for the first product in the results.

 if( $result->isSuccess() ) {
    $image = $result->Items[0]->LargeImage;
    echo '

The Amazon Product Advertising API returns results in pages of 10. To see how you can get all your results go to the tutuorial: How to Iterate through Amazon Product Results.

Comments & Questions

  1. Why does the search box not find known Amazon items.

    For instance Blendtec – Vitamix – Juicer – Blender

    I could go on

    If I search for these on the Amazon site – No Problem

    Only with your plugin

    Please advise

  2. hi,
    I write the same code on my page,but it show some error msg:

    Missing argument 2 for AmazonProductAPI::search(), called in /home/yesnews/public_html/jason/AmazonProductAPI/testAPI.php on line 16 and defined in /home/yesnews/public_html/jason/AmazonProductAPI/AmazonProductAPI.php on line 323

    and the amazon reponse:

    AmazonProduct_Result Object ( [_code:protected] => 200 [_data:protected] =>
    2095a259-c8d4-4f5c-000False1SmallAWS.MissingParametersYour request is missing required parameters. Required parameters include AssociateTag.AWS.MinimumParameterRequirementYour request should have atleast 1 of the following parameters: ‘Keywords’,’Title’,’Power’,’BrowseNode’,’Artist’,’Author’,’Actor’,’Director’,’AudienceRating’,’Manufacturer’,’MusicLabel’,’Composer’,’Publisher’,’Brand’,’Conductor’,’Orchestra’,’TextStream’,’Cuisine’,’City’,’Neighborhood’.

Add Your Comment