I spent a few days last week in New York City at Yahoo’s Open Hack All-stars event. At this hack day, I was mentoring a team of 3 students from the University of Texas who set out to create a hack that allows you to control a media experience on your TV by using your iPad.
For this hack, they needed to talk to search APIs from 4 different services (Youtube, Justin.tv, Flickr, Netflix), parse the results, and display a thumbnail for each item with a link to play/view it. Traditionally, this would be a rather bulky iPad application where you’d have to include all the code and logic to communicate with the various JSON, XML, & ATOM service APIs, parse the results, combine them, and finally render the content. Likely, the HTTP calls would be synchronous, which would certainly present some issues as you get to 5+ APIs and you have to wait for one response to return before making the next.
Alternatively, you could create an API service that will do all of this for you. When that option was presented, I immediately realized YQL would be perfect for this task. Why?
- It can communicate with any HTTP-based APIs, asyncronously, so your response time is always as fast as the slowest API you have to talk to
- Reduces the number of requests your client makes to a single HTTP request
The beauty of this YQL datatable is that you have now created a fully-functional high-performance API server without the need for a server of your own to run it on.
Here’s a JSFiddle of the script in action. Click the play button to see the combined search results.
You can also toy around with the query in the YQL console here.