|
|
London Ruby User Group:Abstractions For Website APIs
Abstractions For Website APIs
Paul Mison is going to do a short talk on libraries and abstractions for website APIs. Specifically how he thinks they should be written (and how he thinks they shouldn't be). The talk will mostly focus on Flickr, so an understanding of Flickr's API and the existing abstractions might be of use.
Review:
In this LRUG session, Paul Mison talks about avoiding API library anti-patterns. Flickr, the photo sharing site, allows raw API documentation. Thankfully, people have written Fickr libraries to help further manipulation, but several of them have not been updated. Taking an example of one library that needs updating, Paul shows that it requires correcting each method individually - this is a problem with API abstractions. Updating involves a long and laborious process.
Thankfully there is a solution: first, the Request can be fixed from the convenience method (since all of them are documented). Then the response can be fixed. Flickr returns JSON (where O = Object) hence the response is an object. To return an API response in JSON format, one simply needs to send a parameter “format” in the request with a value “JSON”, and Flickr raw does that. Plus, you have the added benefit of getting extra parameters with JSON. The key is to offer simple access wrappers to users and make it well documented; to let Ruby do the work; and to use JSON, not XML, in your return format so you’ll always get something back.
Review by: Micky Mollallegn
ABOUT PAUL MISON
|
Paul is a web developer who's been using Macs since 1996. His servers run Linux. He only uses Windows when...
More about Paul Mison
|
|
PODCAST ABSTRACTIONS FOR WEBSITE APIS
|
|
|