Flipy, a new Python library for Flickr

In the past day or so I’ve written a new Python library for Flickr. It came from some frustration using other Python libraries. They’re all great, but none of them work quite how I want.

My goal was to have a library that feels like Python and the Flickr API at the same time. I think it’s worked out pretty well so far. You can make calls using the standard Flickr API calls as documented on the Flickr site, but the response objects feel like normal Python objects. For example you can do something like this:

from flipy import Flipy
flickr = Flipy(MY_API_KEY)
me = flickr.people.findByUsername(username='ianloic')
me_info = flickr.people.getInfo(user_id=me.nsid)
print 'My name is %s. I have %s photos at %s.' % (me_info.realname, me_info.photos.count, me_info.photosurl)

I’ve put more details about the mapping in the README.

Beyond simple mapping of methods to responses I’m working on decorating certain important response objects such as users and photos with more object oriented methods. For example right now if you have a user object you can call user.photos() and get a iterator for of a user’s photos. My code takes care of all of the paging behind the scenes.

Since I haven’t implemented authentication or uploading yet so right now it’s mostly useful for simple mashup-style applications, but I’ll get uploads and authentication complete when I get back from Jordan next week.

Check out the code on github and let me know what you think.

2 replies on “Flipy, a new Python library for Flickr”

  1. It’d be nice if these higher-level APIs could be generated from one of the web service description languages. WSDL looks pretty lame to me; Google’s protocol buffer stuff has a quite nice high-level language for describing messages. I wonder..

    1. Automatic binding never seems to give native-feeling interfaces. Look at SWIG or any of the SOAP (ie: WDSL) libraries. I haven’t played with the Google Protocol Buffer stuff but I bet that binding one language (eg: Java) to another (eg: Python) won’t give you a natural feeling API. What I found was that it didn’t take much work to map the conventions of the Flickr API onto the conventions of Python programming. It took a few opinionated decisions and then some implementation. The core code to do the binding is less than 100 lines. The rest is just fluff and tests. Of course this only works because Flickr’s APIs are relatively well designed and internally consistent.

Comments are closed.