Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

An Introduction to the Yahoo! Query Language Platform

Yahoo! has released a base platform that opens up Yahoo! user data via web standard APIs and also provides a framework for how developers, publishers, and advertisers can build applications on and off Yahoo!.


advertisement
ne of Yahoo!'s key goals is to become more open through the Yahoo! Open Strategy (Y!OS). At the heart of Y!OS is an open and extensible platform that allows developers to rapidly access Yahoo! network data and develop applications with access control using an open authentication standard.

Yahoo! makes structured data available to developers through its web services, such as Flickr and Yahoo! Local, and through other sources like RSS feeds or CSV documents. There are also numerous external web services and APIs outside of Yahoo! that provide valuable data. For example, Programmableweb.com shows more than a thousand APIs available on topics ranging from project management to the Bible.

These disparate services require developers to locate the correct URLs for accessing the APIs and the documentation for querying them. Data remains isolated and separated, requiring developers to combine and work on the data after it's returned to them.



What Is YQL?

The Yahoo! Query Language (YQL) platform provides a mediator service that enables developers to query, filter, and combine data across the web. YQL exposes a SQL-like SELECT syntax that is both familiar to developers and expressive enough for getting the right data. Through YQL's SHOW and DESC commands, Yahoo! attempts to make YQL self-documenting, enabling developers to discover the available data sources and structure without opening another web browser or reading a manual.

The SELECT statement is the primary verb for YQL and borrows much from a SQL-like syntax:

SELECT what FROM table WHERE filter

"Tables" in YQL refer to external data sources that often contain very large collections of structured data. You can think of each item in a table as a "row" in a more traditional relational database. All data in YQL is treated as XML, and if the underlying table source does not provide XML, it converts into an XML-like representation.

You can join any table or data source with another data source through sub-selects—if each table has a matching value—similar to a foreign key in SQL.

Consider the following YQL statement:

SELECT filename,thumbnail_url FROM search.images(50) WHERE query="hat" AND mimetype LIKE "%jpeg%"
AND height<400 AND width<400 LIMIT 2

This returns the thumbnail URL and filename of up to two results FROM the search.image table for images of "hats" that are jpeg encoded and under a certain size:

<?xml version="1.0" encoding="UTF-8"?> <query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="2" yahoo:created="2008-12-02T12:50:59Z"
yahoo:lang="en-US" yahoo:updated="2008-12-02T12:50:59Z" yahoo:uri="http:// query.yahooapis.com/v1/
yql?q=select+filename%2C+thumbnail_url+from+search.images%2850%29+where+query%3D%22hat%22+and+mimetype+like+%22%25jpeg
%25%22+and+height%3C400+and+width%3C400+LIMIT+2"> <diagnostics> <url execution-time="258">http://boss.yahooapis.com/ysearch/images/v1/hat?count=50&start=0&format=xml <user-time>320</user-time> <service-time>258</service-time> <build-version>2008.12.01.15:20</build-version> </diagnostics> <results> <result xmlns="http://www.inktomi.com/"> <filename>RedHat4151.jpg</filename> <thumbnail_url>http://ac4.yt-thm-a01.yimg.com/image/45b413c52b2d4a88</thumbnail_url> </result> <result xmlns="http://www.inktomi.com/"> <filename>red-hat-tshirt-p-lg.jpg</filename> <thumbnail_url>http://ac4.yt-thm-a01.yimg.com/image/239a055f9d7c0fb8</thumbnail_url> </result> </results> </query>

You can run this query by simply copying the following URL into your browser:

http://query.yahooapis.com/v1/public/yql? q=select%20filename%2C%20thumbnail_url%20from%20search.images(50)
%20where%20query%3D%22hat%22%20and%20mimetype%20like%20%22%25jpeg%25%22%20and%20height%3C400%20and%20width%3C400%20
LIMIT%202&format=xml



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap