Blog

Tutorial: Amazon.com Search API

Posted on
REST Syntax Ctd.

Paging and Sorting Through Responses

The only drawback of having so many items at your fingertips is the possibility of receiving too many in a response. Amazon Associates Web Service handles this problem in several ways:

  • Results are returned on page, generally, up to ten results per page
  • The Sort parameter orders results

Paging Through ResultsIt is possible to create a request that returns many thousands of items in a response. This is problematic for several reasons. Returning all of the item attributes for those items would dramatically impact the performance of Amazon Associates Web Service in a negative way. Also, posting a thousand responses on a web page is impractical. For that reason, Amazon Associates Web Service developed the strategy of returning results a little at a time. The good news is that you can return any page of results. For example, the first request can return the last page of results. To do that, you have to specify the desired page of results using one of the parameters that enable you to return result pages. Use the appropriate paging parameter in the request. Operations have their own paging parameters. For example, the following ItemSearch request uses ItemPage to ask for the fourth page of results.

http://ecs.amazonaws.com/onca/xml?
Service=AWSECommerceService&
AWSAccessKeyId=[AWS Access Key ID]&
Operation=ItemSearch&
Keywords=Potter&
SearchIndex=Books&
ItemPage=4

The following snippet of the response shows that the fourth page of results has been returned.

  4
  Potter
  Books

9729
973