YQL

YQL or Yahoo Query Language allows developers to query, join and filter data from multiple data sources on the web who have made their data available through the YQL interface. Since YQL is an expressive SQL like language, developers familiar with the SQL interface should feel comfortable with the interface.

YQL provides the developers a consistent way to access online services which are otherwise dispersed across a range of formats. It hides the implementation of the various data sources on the web and make it easier to query the data.

YQL is both a service and a language. The service is through which external web services can make their data available for developers to consume through the yahoo query ‘language’.

Understanding the language of YQL

If you are familiar with the SQL, you will feel at home with YQL. This language allows developers to use SQL syntax to extract data from the service. It can return the results in either XML format or in JSON format.

Yahoo has provided a YQL Console for developers to test their queries.

For example, if the application wants to search from YouTube and display a list of results, the developer can use a simple query like below and get the information from the web service.

The output of the above query in XML format is below. Adding ‘limit 1’ will limit the output to the top 1 result.

Similar to SQL, YQL also let the developer query for individual columns. The developer can limit what is returned from the service by specifying the data that should be returned as in the below example.

Which returns just those 4 columns that are requested.

Using the YQL Service

Let’s look at the usage of these services. Let us say, for example, an application wants to list out the current popular music charts.

Head over to the YQL Console and put your query as below:

yql_1

Click on TEST button. The console will show the output in the format that you selected, either XML or in JSON format.

yql_2

Once you are satisfied with the results, head to the bottom area of the console to grab the complete URL.

yql_3

The resulting query:

http://query.yahooapis.com/v1/public/yql?q=%20SELECT%20*%20FROM%20music.artist.popular%20limit%205&diagnostics=true

The application can post this query to get the response and the response being in XML or JSON consistently across the web services makes this interface very luring to use.

Other Useful Links

Complete YQL Documentation
http://developer.yahoo.com/yql/docs/

YQL Screencast from the Yahoo! Developer Network
http://developer.yahoo.com/yos/screencasts/yql_screencast.html