While working on another project (announcement soon) I discovered that the “pyamazon” API to Amazon E-Commerce Services no longer works (update: and is now called Amazon Associates Web Service). As I’m looking for a way to look up authors and books on Amazon, I decided to have a look at project and what was wrong.
As it turns out, the Amazon API has undergone quite a bit of evolution in the last few years and the old API has been abandoned. I initially tried to upgrade Mark Pilgrim and Mike Josephson‘s code but after a few minutes I decided a new, more class and iterator-oriented approach would be better.
After a few hours of coding, here’s the result: the PyECS project on Google Code. There’s no tarball or setup.py yet, but we’ll put that together soon. If you want to help, hey, leave a comment.
I’ve only implemented a few lookups, though the general “iter” method will pretty well get anything you want just by passing in a couple of parameters.
Here’s an example of how to use it to look up of all of U2′s albums:
a = ecs.AmazonECS(AccessKeyID = 'YOUR_AMAZON_ECS_LICENSE_KEY')
for d in a.iterMusicByArtist('U2'):
pprint.pprint(d)
That’s all there is to it: no need to worry about what page of results or whatever you are on. The results are returned as a Python dictionary of lists, dictionaries, and strings: the usual JSON-like thing. If you want an exact transcription of the XML objects, that’s available but by default we do a little compression to make the results more usable.
How does this compare or improve on pyaws (http://pyaws.sourceforge.net)
I haven’t tested either framework but wanted to learn some Python or and thought doing a project with Amazon ECS (AAWS now I guess) would be fun.
Hi Paul,
Honestly, I never saw this one! If it supports the up-to-date API, I’m sure it’s great; there’s really not a whole lot of cleverness to implementing this API. I only implemented what I needed and provided a generic access function, so please choose the version that works best for you. The main difference, I think, is that I choose a pure “JSON-like” data structure for storing data (dict, list and base types) whereas PyAWS uses classes, etc.. Again, this may prove to be a matter of style.
[...] This will probably end up replacing PyECS! [...]