You may already know that Flickr provides RSS and Atom feeds for every user’s photo stream. (There a link at the bottom of each user’s main photo page - here’s my page and a link to my RSS feed.) But what you may not know is that Flickr supports output in quite a few formats besides RSS2.0 and Atom - just change the value of the “format” tag in any feed URL. I don’t think Flickr posts an official document describing the supported formats, but all of the following seem to work fine: php_serial, csv, json, rdf, sql, yaml.
Why is this important, you ask? What could one possibly do with these? Why would you want anything other than RSS or Atom?
Well, for starters, consider JSON. Using an existing JSON parser (such as BSJSONAdditions!) you can easily turn Flickr’s JSON output into an NSDictionary… And once you have a dictionary, you can easily access all the data via key paths… And access via key paths means you can create a fairly complete UI using just bindings and almost zero code! What do I mean by almost zero? Well, here’s a sample app - FlickrFeedReadr - that takes a user’s NSID and provides a very basic photo feed reading capability. Total lines of code? 16. Yes, sixteen. And considering that I added 4 of those to decode the &-encoded HTML entities, I think that’s a pretty good code-to-feature ratio.
Some of Flickr’s other output formats also invite creative solutions - SQL, for example. It’s not too hard to imagine somebody creating a feed database full of photo info that can be easy searched or sorted from any number of clients without needing to build any sort of Flickr API code or XML parsing.
In addition to the sample app here, you can download the Xcode project and the code here. Of course, 16 lines of code doesn’t get you a NetNewsWire replacement. (No error handling, no refreshing…) However, it does show how easy it can be to work with JSON - especially when it comes to bindings and Cocoa.
Enjoy!