Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Got this to work based on code sample at <a href="http://jjinux.blogspot.com/2009/06/python-amazon-product-advertising-api.html" rel="nofollow noreferrer">http://jjinux.blogspot.com/2009/06/python-amazon-product-advertising-api.html</a> Here is a minor improved version that lets you merge a dict of call specific params with the basic params before making the call. </p> <pre><code>keyFile = open('accesskey.secret', 'r') # I put my secret key file in .gitignore so that it doesn't show up publicly AWS_SECRET_ACCESS_KEY = keyFile.read() keyFile.close() def amz_call(self, call_params): AWS_ACCESS_KEY_ID = '&lt;your-key&gt;' AWS_ASSOCIATE_TAG = '&lt;your-tag&gt;' import time import urllib from boto.connection import AWSQueryConnection aws_conn = AWSQueryConnection( aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=Amz.AWS_SECRET_ACCESS_KEY, is_secure=False, host='ecs.amazonaws.com') aws_conn.SignatureVersion = '2' base_params = dict( Service='AWSECommerceService', Version='2008-08-19', SignatureVersion=aws_conn.SignatureVersion, AWSAccessKeyId=AWS_ACCESS_KEY_ID, AssociateTag=AWS_ASSOCIATE_TAG, Timestamp=time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime())) params = dict(base_params, **call_params) verb = 'GET' path = '/onca/xml' qs, signature = aws_conn.get_signature(params, verb, path) qs = path + '?' + qs + '&amp;Signature=' + urllib.quote(signature) print "verb:", verb, "qs:", qs return aws_conn._mexe(verb, qs, None, headers={}) </code></pre> <p>Sample usage:</p> <pre><code>result = self.amz_call({'Operation' : 'ItemSearch' , 'Keywords' : searchString , 'SearchIndex' : 'Books' , 'ResponseGroup' : 'Small' }) if result.status == 200: responseBodyText = result.read() # do whatever ... </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload