Paging Through Results
For that reason, Product Advertising API 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.
To page through results
-
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.
<ItemSearch
Request> <ItemPage>4</ItemPage> <Keywords>Potter</Keywords> <SearchIndex>Books</SearchIndex> </ItemSearch
Request> </Request> <TotalResults>9729</TotalResults> <TotalPages>973</TotalPages>
This example shows that 9729 items matched the search criteria. Also, it shows that those results are on 973 (~9729/10) pages. You might try putting in an ItemPage value over 400. If you do, Product Advertising API returns the following error.
<Error> <Code>AWS.ParameterOutOfRange</Code> <Message>The value you specified for ItemPage is invalid. Valid values must be between 1 and 400.</Message> </Error>
So, how do you get that 973rd page? You cannot. A better approach is to submit a new request that is more targeted and yields fewer items in the response.