Yahoo Query Language
In today’s world major websites offer API to give developer major access to their web services. But it is pretty difficult task as for website have different API’s standards and rules and way of accessing it is also different.
In one of my project, I needed to make use of Yahoo services like search, news and images. While searching I came across YQL. It allows you to make use of 3rd party web services through a single interface with access through query like SQL syntax. For example, the query for getting photos from Flickr with certain term is as follows-
SELECT * FROM flickr.photos.search WHERE text="cat"
You can also do join queries like
select * from flickr.photos.info where photo_id in (select id from flickr.photos.search where text="cat")
I just tried it for getting photos from Flickr, or twitter status updates, it all happened through one single interface. This will help you save your time from learning different API’s for different web services.
The result returned from YQL is available in two formats JSON & XML. The data obtained can be displayed in one of the 2 formats , a simple format showing data with tags and the other one is data with tree format.
As you can notice from the image , it is console, where in you put your query in the top panel and then will be able to see the output in the just below panel. You will notice two options in the query window which allows your get the result in XML or JSON format.
In the right panel, there is one example queries tab, you can click on any of them and see the output of it.
In the another right panel below there are tables listed of different web services, you can select any one of them and see the output from the particular web service.
At the starting of Data Tables there is a option of “Show Community Tables” , If you select this option it will show you tables from different web services like Facebook, Google, Amazon, etc. There are around 900 different tables. If the option is not selected , then by default YQL will show all tables related to Yahoo web services like Flickr, Yahoo News, Yahoo Social.
If you wish to build similar tables for your own web service you can build your own table. Click here to learn more about it.
I have created one sample script in PHP which gets photo and its information from Flickr, it is available at gist
Following points to be considered while using YQL
- By default it gives you 10 results
- You can increase the result limit up to 1000
- Per application limit (Identified by your Access Key): 100,000 calls per day.
- Per IP limit is 1000 calls per hour.
Like this post? or have something to say about YQL? Comment down your opinions.