This is a post using my next project, called GenX which I’ll be describing in the next few weeks. Here’s a some information about a band called U2. I just bought a reissued CD/DVD combo of Under a Blood Red Sky, so it seems appropriate. (Note: post updated)
October 19, 2008
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.