1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<div class="intro">
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<img alt="" style="float: right; margin-left: 15px; border: 1px solid #D9D9D9;" src=
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p><a href="http://developer.yahoo.com/yql/">The Yahoo! Query Language</a> (YQL) is an expressive SQL-like
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glasslanguage that lets you query, filter, and join data across
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav GlassWeb services. With YQL, <i>apps run faster with fewer lines
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glassof code and a smaller network footprint.</i></p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>Yahoo! and other websites across the Internet make much
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glassof their structured data available to developers, primarily
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glassthrough Web services. To access and query these services,
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glassdevelopers traditionally endure the pain of locating the
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glassright URLs and documentation to access and query each Web
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>With YQL, developers can access and shape data across
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glassthe Internet through one simple language, eliminating the
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glassneed to learn how to call different APIs.</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass{{>getting-started}}
046ea4d1ee0f22d956cd360e1e0c0b275aa4bbd0Dav Glass<h2 id="query">Making a Query</h2>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>After you find the query you want to run in the Developer Console, just plug it in:</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>The <a href="http://developer.yahoo.com/yql/console/">YQL Developer Console</a> is a nice place to start playing with YQL queries. You can test and inspect queries before you actually use them.</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav GlassYUI().use('yql', function(Y) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass Y.YQL('select * from weather.forecast where location=90210', function(r) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //r now contains the result of the YQL Query
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //use the YQL Developer console to learn
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //what data is coming back in this object
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //and how that data is structured.
046ea4d1ee0f22d956cd360e1e0c0b275aa4bbd0Dav Glass<h2 id="query-reuse">Re-Using A Query</h2>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>Modifying the example above to make it reusable is simple, just save the result of the query and call `send` on it to query for the results again.</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav GlassYUI().use('yql', function(Y) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass var q = Y.YQL('select * from weather.forecast where location=90210', function(r) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //r now contains the result of the YQL Query
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //Sometime later
046ea4d1ee0f22d956cd360e1e0c0b275aa4bbd0Dav Glass<h2>Changing A Re-Used Query</h2>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>Changing a query without creating a new instance can be beneficial for queries that involve the same request but different parameters (like an AutoComplete query).</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>To do this, we need to modify the private param `q` on the YQL instance.</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav GlassYUI().use('yql', function(Y) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass var q = Y.YQL('select * from weather.forecast where location=90210', function(r) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //r now contains the result of the YQL Query
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //Sometime later
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass q._params.q = 'select * from weather.forecast where location=62959';
046ea4d1ee0f22d956cd360e1e0c0b275aa4bbd0Dav Glass<h2 id="tables">Open Data Tables</h2>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>Open Data Tables enable developers to add tables for any data on the Web to YQL's stable of API-specific tables. Using Open Data Tables, anyone can make their data YQL-accessible. If you would like to create an Open Data Table, visit the community page at <a href="http://datatables.org">http://datatables.org</a>.</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>By default, the `YQL` module will include the environment file needed to use all of the publicly available Open Data Tables.</p>
046ea4d1ee0f22d956cd360e1e0c0b275aa4bbd0Dav Glass<h2 id="advoptions">Advanced Options</h2>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass<p>The default configuration for the `YQL` module is designed for the most basic use cases. However, the `YQLRequest` class is designed to give the developer more control over the query, parameters and options used to make the YQL Request.</p>
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav GlassYUI().use('yql', function(Y) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass var q = new Y.YQLRequest('select * from weather.forecast where location=90210', function(r) {
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //r now contains the result of the YQL Query
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass //Optional URL Parameters to add to the request
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass another: 'option'
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass base: '://query.yahooapis.com/v1/yql?', //Different base URL for private data
6cbf89e74d4d69da16fb41d09e3d044bc01b64f1Dav Glass proto: 'https' //Connect using SSL