The neat things with datatables is that once you have one complete, you now have an API service that you can pass dynamic data to via the querystring. Think the REST URL YQL uses is too long and ugly? Use YQL's Console to create a query alias. So for example, here is an API service that searches YouTube, Justin.TV, Flickr, and Netflix for the specified term in the querystring, http://query.yahooapis.com/v1/public/yql/derek/mediasearch?query=kittens. The best part is, you don't thave to worry about hosting it. Let Yahoo worry about that.
Within YQL, there's a little-known feature, the
<execute> sub-element. Inside of
<execute>, you start with 2 global objects
Note, there's also a 3rd global (request), but that won't be very useful for Executor. So ignore it for now.
Let's start with the important one first,
response. There's really not much to it aside from
response.object which is the property you assign your output to. This will be the data received by the client making the YQL request. This is just about the most basic example of an
response.object = <items> <item>foo</item> <item>bar</item> </items>;
Now, if you really want to take advantage of
<execute> and earn some gold stars, you'll want to investigate the
y object a little more closely. This object contains really useful things like:
y.log(string)- Log messages to
y.rest(url)- Execute HTTP requests
y.query(query)- Execute YQL queries
y.crypto.encodeMd5(string)- Generate an MD5
y.xmlToJson(object)- Converts an E4X/XML object into a JSON object
There are quite a few more methods, but those are the most commonly used ones.
This was hacked together in about 10 hours by @derek at a Y! HackU event in Berkeley on Sept 23rd/24th 2011.