Amazon.com Widgets

How To Call Amazon ItemSearch in Flex

Formatting the Service Request


ItemSearch is part of the Amazon E-Commerce Service (ECS) suite that allows remote web sites to search through the Amazon product catalog. In this example, we’ll just look at how to search for books. ItemSearch can be accessed using the REST architectural style with the following syntax:

http://webservices.amazon.com/onca/xml?Service=AWSECommerceService
&SubscriptionId=[Your Subscription ID Here]
&Operation=ItemSearch
&Keywords=[A Keywords String]
&SearchIndex=[A Search Index String]
&Sort=[A Sort String]

In Flex, this translates into the following MXML HTTPService object:

  1. <mx:HTTPService
  2. id=“itemSearchRequest”
  3. url=“http://ecs.amazonaws.com/onca/xml”
  4. useProxy=“false” method=“GET”>
  5. <mx:request xmlns=“”>
  6. <Service>AWSECommerceService</Service>
  7. <AWSAccessKeyId>YOUR Amazon Web Services Key</AWSAccessKeyId>
  8. <Operation>ItemSearch</Operation>
  9. <SearchIndex>Books</SearchIndex>
  10. <Sort>relevancerank</Sort>
  11. <Keywords>{keywords.text}</Keywords>
  12. </mx:request>
  13. </mx:HTTPService>

Note that we’re using the GET request method, and that all of the parameters are hard coded except for the Keywords parameter. We’ll get this from a text input called “keywords”. Also note that, in order for this to work, you must have an Amazon Web Services account and you must include your web services key ID in the AWSAccessKeyId parameter. You could include our key, if you wanted to be nice and send us all the commissions on your web sales through Amazon. In this example, we’re going to search through the Books index and request that the returned items are sorted by relevance.

Pages: 1 2 3


Leave a Comment