Basic AWIS (Alexa / Amazon Web Information Services) with Python’s boto

December 12, 2010

I wanted to use AWIS from Python. It’s surprisingly straight forward. Firstly, make sure you setup your boto config. Here is a simple example of how to create a connection, and run a query:

>>> import boto.connection
>>> conn = boto.connection.AWSQueryConnection(host='awis.amazonaws.com', is_secure=False)
>>> conn.APIVersion='2005-07-11'
>>> response = conn.make_request('UrlInfo', params={'Url':"http://youporn.com", 'ResponseGroup':'TrafficData'})
>>> # response is a httplib.HTTPResponse instance
>>> response.read() #Returns an XML response