The Two-Minute Tutorial

This tutorial shows you how to run YQL statements and examine the resulting data with the YQL Console.

  1. In your browser, run the YQL Console.
  2. Under "Example Queries", click get 10 flickr "cat" photos. The console calls the YQL Web Service with the following query:

    select * from flickr.photos.search where text="Cat" limit 10

    This SELECT statement requests Flickr photos of cats. The "*" indicates that all fields of the flickr.photos.search table will be returned. In the filter of the WHERE clause, the string "Cat" is the value of the search query.

  3. Note the XML response in the FORMATTED VIEW tab. The information from the flickr.photos.search table is in the results element. To get the response in JSON format, select the JSON radio button and click TEST.
  4. In Your YQL Statement, replace the "*" with the owner and title fields:

    select owner, title from flickr.photos.search where text="Cat" limit 10

    Make sure that owner and title are lowercase. Unlike SQL, in YQL the field and table names are case sensitive.

  5. To run the command in Your YQL Statement, click TEST. The returned photo fields should only have the owner and title attribute fields.
  6. In the console, examine the URL below REST query:

    http://query.yahooapis.com/v1/public/yql?q=select%20owner%2C%20title%20from%20flickr.photos.search%20where%20text%3D%22Cat%22%20limit%2010&format=json&callback=cbfunc

    To call the YQL Web Service, an application would call an HTTP GET method on this URL. The q parameter in the URL matches the SELECT statement displayed under Your YQL Statement (except that characters such as spaces are URL encoded). The COPY URL button copies this URL to your clipboard, so that you can paste it into the source code of an application.

  7. To view YQL's pre-defined tables, expand the Data Tables list on the right side of the console. You can run an example query on each of these tables by clicking the table name.
  8. Advanced: To view the description of a table, under Data Tables, expand the flickr menu to see all of the Flickr tables. Move your mouse cursor over the table name flickr.photos.search, then click desc. On the TREE VIEW tab, take a look at these nodes: "query->results->table". The nodes under the "table" node contain information such as meta-data and search fields (input keys). For more information on input keys, see Remote Filters.

Table of Contents