Yahoo Query Language
Not sure how YQL (Yahoo Query Language) has escaped my attention for so long, as it seems so useful.
YQL lets you query any of the Yahoo's APIs using a SQL-like syntax. For me this came in handy when I wanted to create a simple stock-tracking mobile app.
In JavaScript I could get the stock quote for Google's stock as JSON, like so:
function getStock(symbol){ var YQL="select * from yahoo.finance.quotes where symbol ='"+symbol+"'"; var URL="http://query.yahooapis.com/v1/public/yql?q=" + escape(YQL) + "&format=json"; //Do an AJAX call to the above URL to get the JSON back. }
To see what the JSON look like see it on the console.
When it comes to using it in mobile apps, if you use Titanium then you can use the YQL wrapper and write code like this:
Titanium.Yahoo.yql( "select * from yahoo.finance.quotes where symbol = 'GOOG'", function(e) { var data = e.data; //Do what you like with the data JSON object } );
All very useful.
Yep -- pretty cool, the services they have available. Used them when I did a bit of webOS development for fun that used Yahoo's YQL quite a bit -- webOS made developing apps like that really easy. Makes me wish, sometimes, that I could do an ajax command for an external website in a web browser. :P
Only sometimes.
Reply
I'm not sure what you meant by "ajax command for an external website". But if you want to get data from other sites with Ajax, you actually can do it. Have you looked into JSONP (JSON with padding)?
If the other site doesn't provide it's services in the JSON format, you can use Yahoo Pipes module Fetch Page to act as a proxy. Then you just grab the output of your pipe in JSON(P).
Reply
Jake, also worth a look is yahoo pipes - pipes.yahoo.com .
Reply