Yahoo Query Language: Difference between revisions

Content deleted Content added
Rescuing 0 sources and tagging 1 as dead.) #IABot (v2.0.9.5) (LeapTorchGear - 22831
 
(42 intermediate revisions by 36 users not shown)
Line 1:
{{Redirect-distinguish|YQL|Lethbridge Airport}}
'''Yahoo! query language''' ('''YQL''') is an [[SQL]]-like [[query language]] created by [[Yahoo!]] as part of their [[Yahoo! Developer Network|Developer Network]]. YQL is designed to retrieve and manipulate data from [[API]]s through a single Web interface, thus allowing [[mashup (digital)|mashups]] that enable developers to create their own applications.<ref>{{cite news |url=http://www.pcworld.com/businesscenter/article/164067/yahoo_extends_yql_web_data_query_platform.html |work=[[PC World (magazine)|PC World]] |title=Yahoo Extends YQL Web Data Query Platform |date=April 29, 2009 |last=Perez |first=Juan Carlos }}</ref>
{{short description|SQL-like query language}}
'''Yahoo! queryQuery languageLanguage''' ('''YQL''') is an [[SQL]]-like [[query language]] created by [[Yahoo!]] as part of their [[Yahoo! Developer Network|Developer Network]]. YQL is designed to retrieve and manipulate data from [[API]]s through a single Web interface, thus allowing [[mashup (digital)|mashups]] that enable developers to create their own applications.<ref>{{cite news |url=httphttps://www.pcworld.com/businesscenter/article/164067/yahoo_extends_yql_web_data_query_platform.html |work=[[PC World (magazine)|PC World]] |title=Yahoo Extends YQL Web Data Query Platform |date=April 29, 2009 |last=Perez |first=Juan Carlos }}{{Dead link|date=February 2025 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> using [[Yahoo! Pipes]] online tool.
 
Initially launched in October 2008 with access to Yahoo APIs,<ref>{{cite news |url=http://www.eweek.com/c/a/Application-Development/Yahoo-Launches-YQL-Execute-Updates-YSlow-660481/ |archive-url=https://archive.today/20120731002123/http://www.eweek.com/c/a/Application-Development/Yahoo-Launches-YQL-Execute-Updates-YSlow-660481/ |url-status=dead |archive-date=July 31, 2012 |work=[[eWeek]] |title=Yahoo Launches YQL Execute, Updates YSlow |last=Kolakowski |first=Nicholas |date=April 29, 2009 }}</ref> February 2009 saw the addition of open [[data table]]s from third parties such as [[Google Reader]], the ''[[Guardian newspaper|Guardian]]'', and ''[[The New York Times]]''.<ref name="rww"/> Some of these APIs still require an [[API key]] to access them. On April 29th29 of 2009, Yahoo introduced the capability to execute the tables of data built through YQL using [[JavaScript]] run on the company's servers for free.<ref name="rww">{{cite news |url=http://www.readwriteweb.com/archives/theres_a_great_amount_of.php |work=[[ReadWriteWeb]] |last=O'Dell |first=Jolie |date=May 2, 2009 |title=Developers: Never Mind the APIs, Here's YQL Execute }}</ref> On January 3, 2019, Yahoo retired the YQL API service.
==YQL Page Scraping==
One of the most common use of YQL is getting data from any page on the internet(page scraping), thats why some of the people say yql can do
<pre>
"Select * from internet"
</pre>
 
==Examples==
For example to get data from this page you can do some thing like this
Filter RSS feeds
<pre>
<syntaxhighlight lang="sql">select title, link from rss where url = 'https://www.engadget.com/rss.xml'</syntaxhighlight>
 
Convert CSV to JSON or XML
select * from html where url="http://en.wikipedia.org/wiki/Yahoo!_query_language" and
<syntaxhighlight lang="sql">select * from csv where url='http://download.finance.yahoo.com/d/quotes.csv?s=YHOO,GOOG,AAPL&f=sl1d1t1c1ohgv&e=.csv' and columns='symbol,price,date,time,change,col1,high,low,col2'</syntaxhighlight>
xpath='//div[@id="bodyContent"]'
 
Extract HTML via CSS Selectors
</pre>
<syntaxhighlight lang="sql">SELECT * FROM data.html.cssselect WHERE url='http://www.w3.org/' AND css='ul.theme'</syntaxhighlight>
All data from YQL can be consumed in form of [[JSON]] or [[XML]]
Here is sample html and JavaScript Code which is using YQL Rest API
<pre>
<nowiki><HTML>
<HEAD>
<TITLE>YQL DEMO</TITLE>
<STYLE type="text/css">
body{text-align: center;background:#c0c0c0;}
#mycontent{margin-left: auto;margin-right: auto;width: 780px;font-size:80%;background:#ffffff; border: 1em solid #fff;}
</STYLE>
<SCRIPT type="text/javascript">
function ren(o) {
var d = document.getElementById("main");
var h = "";
var i;
var c;
if (d) {
if (o.results[0]) {
c = o.results.length;
for (i = 0; i < c; i++) {
h = h + o.results[i] + '><br/' + '>';
}
d.innerHTML = h;
} else if (o.results) {
d.innerHTML = o.results;
} else {
d.innerHTML = 'failed';
}
}
}
</SCRIPT>
</HEAD>
<BODY>
<DIV id="mycontent">
<H1 id="titletext">Yahoo! query language - Wikipedia, the free encyclopedia</H1>
<HR>
<DIV id="main">
Loading YQL JSON...
</DIV>
</DIV>
<script src="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A//en.wikipedia.org/wiki/Yahoo%21_query_language%22%20and%0A%20%20%20%20%20%20xpath%3D'//div%5B@id%3D%22bodyContent%22%5D/p%5B1%5D'&format=xml&diagnostics=true&callback=ren">
</script>
</BODY>
</HTML>
</nowiki>
</pre>
One the example page where this data is scrapped is [http://www.purplegene.com/mashup?yql=select%2520*%2520from%2520html%2520where%2520url%253D%2522http%253A//en.wikipedia.org/wiki/Yahoo%2521_query_language%2522%2520and%250A%2520%2520%2520%2520%2520%2520xpath%253D'//div%255B@id%253D%2522bodyContent%2522%255D/p%255B1%255D'%26format%3Dxml%26diagnostics%3Dtrue%26callback%3Dren&t=Yahoo!%20query%20language%20-%20Wikipedia,%20the%20free%20encyclopedia here]
 
Get AppLinks meta data
==References==
<syntaxhighlight lang="sql">SELECT * from applinks WHERE url IN ('movietickets.com', 'pinterest.com')</syntaxhighlight>
<references/>
 
Parse any XML source
==External links==
<syntaxhighlight lang="sql">select Status.presence from xml where url = 'http://mystatus.skype.com/pjjdonnelly.xml' and Status.presence.lang = 'en'</syntaxhighlight>
* [http://developer.yahoo.com/yql/ Official site], including the YQL console
 
==Rate limits==
Use of the YQL should not exceed reasonable request volume.<ref>{{cite web|title=YQL|url=https://developer.yahoo.com/yql/|ref=yql}}</ref> Access is limited as below:
* Per application limit (identified by your Access Key): 100,000 calls per day;
* Per IP limits: /v1/public/*: 2,000 calls per hour; /v1/yql/*: 20,000 calls per hour.
 
==See also==
* [[SQL]]
*[[WSO2 Mashup Server]]
*[[Yahoo! Pipes]]
 
==References==
{{Reflist}}
 
==External links==
* [http://developer.yahoo.com/yql/ Official site], including the YQL console
{{Oath Inc.}}
{{Yahoo! Inc.}}
{{Query languages}}
 
[[Category:Yahoo!|query language]]
[[Category:Query languages]]
[[Category:Web scraping]]