This document discusses Yahoo Query Language (YQL), which allows users to query and retrieve data from structured data sources on the web using SQL-like statements. YQL supports selecting, inserting, updating, and deleting data across web services and Yahoo's cloud storage. It also includes "Open Data Tables" that define mappings between YQL and web APIs, allowing external APIs and data sources to be accessed via YQL. The document provides examples of using YQL to retrieve data from sources like Twitter, insert and delete tweets, and scrape web pages. It presents YQL as a way to more easily build applications by processing data in the cloud rather than in apps.
3. var map = new YMap(document.getElementById('map'));…varcurrentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);… … if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … } … http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
4. var map = new YMap(document.getElementById('map'));…varcurrentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);… … if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … } … http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
5. var map = new YMap(document.getElementById('map'));…varcurrentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);… … if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … } … http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c YQL YQL stmt
6. Why YQL? Thousands of Web Services and sources that provide valuable data Require Developers to read documentation and form URLs/queries. Data is isolated Needs filtering, combining, tweaking, shaping even after it gets to the developer.
7. What is YQL? Cloud web service and SQL-Like Language Familiar to developers Synonymous with Data access Expressive enough to get the right data. Self describing - show, desc table Allows you to query, filter, join and update data across any structured data on the web / web services And Yahoo’s sherpa cloud storage Real time engine
8. YQL Statement Basics show: lists the supported tables desc: describes the structure of a table select: fetches data insert/update/delete: modify data use: use an Open Data Table set: define key-values across Open Data Tables
9. Insert / Update / Delete With INSERT/ UPDATE/ DELETESQL verbs you can modify data on the internet or cloud create tweets, add blog entries, update DBs etc store tables or pieces of code in sherpa Some tables with I/U/D Twitter, Bit.ly shortener Yahoo profile status, application update stream Amazon SimpleDB
22. ODT <execute> element Extends Open Data Tables with server-side code Javascript server-side scripting No DOM, events etc, pure JS scripting E4X support - XML literals, filtering ... YQL no longer performs a GET request to the table binding URL YQL provides additional useful global objects request, response, y.rest, y.include, y.query... Execute tag must return the data that will be the output of the YQL select Move business logic of your application to the cloud
23. What you can do with <execute> access APIs that require authentication Netflix OAuth, FlickrAuth, Google AuthSub join data across services grab New York Times article tags and generate find associated flickr photos combine multiple searches into a single result (twitter, web, news and images) augment data: city/state to APIs that just return zip code create APIs from web page celebrity birthdays scraped from imdb, caltrain data transformation convert the result from xml to Google's kml format
24. hello world <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <meta> <sampleQuery>select * from {table} where a=’hello' and b=’world';</sampleQuery> </meta> <bindings> <select itemPath="" produces="XML"> <urls><url>http://fake.url/{a}</url></urls> <inputs> <key id='a' type='xs:string' paramType='path' required="true" /> <key id='b' type='xs:string' paramType='variable' required="true" /> </inputs> <execute><![CDATA[ // Your javascript goes here. We will run it on our servers response.object = <item> <url>{request.url}</url> <a>{a}</a> <b>{b}</b> </item>; ]]></execute> </select> </bindings> </table>
25. Scraping a page <select produces="XML" itemPath="deals.deal"> <urls><url>http://deals.yahoo.com</url></urls> <execute><![CDATA[ vardealhtml = y.query("select * from html where url='http://deals.yahoo.com' and xpath='//div[contains(@class, quot;product-displayquot;)]'").results; var deals = <deals/>; function compress(object) { if (!object) return ""; return object.toString().replace(/+/, " ") } for each (var div in dealhtml.div) { var deal = <deal/>; deal.name += <name>{compress(div.h3.a.text())}</name>; deal.link += <link>{div.div[0].a.@href}</link>; … deal.description += <description>{compress(div.p[0].*)}</description>; deal.logo += <logo>{compress(div.div[1].*)}</logo>; deals.deal += deal; } response.object = deals; ]]></execute> </select>
29. Conclusion More easily build applications fewer lines of code data processing done away from app consistent and familiar syntax for all data access