Yql Openhackday 2009

  • 2,960 views
Uploaded on

Slides from my YQL (Yahoo Query Language) Talk @ OpenHackDay Bangalore held on 14th/15th Feb '09

Slides from my YQL (Yahoo Query Language) Talk @ OpenHackDay Bangalore held on 14th/15th Feb '09

More in: Technology , Sports
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,960
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
37
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. YQL A Query Language for the Web Nagesh Susarla
  • 2. Agenda Why YQL? YQL Statement Basics Accessing YQL Q&A
  • 3. Application ?
  • 4. Application ?
  • 5. Application ?
  • 6. Application ?
  • 7. Application ?
  • 8. Application =
  • 9. data manipulation Application =
  • 10. data manipulation Application = + data visualization
  • 11. data data
  • 12. data
  • 13. data
  • 14. dev
  • 15. dev
  • 16. dev
  • 17. dev
  • 18. dev
  • 19. dev
  • 20. dev
  • 21. dev
  • 22. dev
  • 23. dev
  • 24. dev
  • 25. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); …
  • 26. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } …
  • 27. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2
  • 28. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 29. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 30. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 31. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 32. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 33. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); ? … … if (flickcurl_prepare(fc, ? quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … ? http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 ? http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 34. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); ? … … if (flickcurl_prepare(fc, ? quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … ? http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 ? http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 35. Yahoo! My Yahoo! Mail Welcome, guest Sign In Search var map = new MY PROJECTS APIs & WEB SERVICES RESOURCES SUPPORT YMap(document.getElementById('map')); YDN Maps Suite AJAX Maps Yahoo! Maps Web Services - AJAX API Getting READY TO GET STARTED? … You aren't signed in Sign In Help Started Guide Get an App ID var currentGeoPoint = new dev Home The Tour Sign Up Explore Search Learn the fundamentals of the Yahoo! Maps AJAX API and start creating your own maps. This page contains: YGeoPoint( _c.Lat, _c.Lon ); Introduction and Prerequisites Yahoo! Maps Cheatsheets Flickr Services RECENT BLOG ARTICLES Yahoo! My Yahoo! Mail Examples Welcome, guest Sign In API Documentation Feeds Your API Keys map.addMarker(currentGeoPoint); Display a Yahoo! Map ? Apply for a new API Key Search Add controls to your Yahoo! Map Leonardo da Vinci: Hacker … January 24, 2009 Add a logger to a Yahoo! Map Place a marker on a Yahoo! Map MY PROJECTS APIs & WEB SERVICES RESOURCES SUPPORT Draw Polylines on a Yahoo! Map Whaddyathink? & the Yahoo! Application flickr.places.getPlaceTypes Place Smart Markers on a Yahoo! Map Platform YDN Weather RSS Feed Add multiple custom markers on Yahoo! Map January 22, 2009 Traffic information overlay Yahoo! Weather RSS Feed Yahoo! Pipes RSS output information overlay Making the new Yahoo! Currency Converter Fetches a list of available place types for Flickr. Yahoo! Pipes JSON output information overlay accessible YMap Local search results overlay The Weather RSS feed enables you to get up-to-date weather information for your location. You can save this January 21, 2009 … Overlay GeoRSS XML data feed in My Yahoo! or your favorite feed aggregator, or incorporate the RSS data into your own web site or client Overlay custom objects at YGeoPoint location application. The Weather RSSRetrievingdynamically-generatedfrom based on zip code or Location ID. feed is a and displaying data feed Authentication Overlay custom objects at YCoordPoint location if (flickcurl_prepare(fc, Wikipedia with YQL Overlay polyline on Yahoo! Map This page describes the format of the 18, 2009 URL and the RSS response for developers. It contains these January request ? Export Yahoo! Map in GeoRSS format This method does not require authentication. quot;flickr.photos.geo.correctLocationquot;, sections: GeoRSS overlay with polyline Get zoom level given radius from center RSS Request Arguments Custom position of controls parameters, count)) { … } Summary Change Marker Images Dynamically Request Parameters Use YMapTypeControl to position map types … api_key (Required) Other Features of the Yahoo! Maps AJAX API RSS Response YEvent, YGeoRSS, YMarker Rate Limit Your API application key. See here for moreTop-Level Elements details. Terms of Service Channel Elements Support & Community Image Elements ? Example Response Item Elements Download all of the cheatsheets and example code in the Yahoo Condition Codes Maps API Reference Bundle. <place_types> Examples For detailed descriptions of the classes and methods in the API, place_type_id=quot;22quot;>neighbourhood</place_type> <place_type Terms of Use check out v3.8 Reference Manual. <place_type place_type_id=quot;7quot;>locality</place_type> http://search.yahooapis.com/ <place_type place_type_id=quot;9quot;>county</place_type> RSS Request <place_type place_type_id=quot;8quot;>region</place_type> Remaining, Supporting Classes ImageSearchService/V1/imageSearch? <place_type place_type_id=quot;12quot;>country</place_type> The Weather RSS feed request follows simple HTTP GET syntax: start with a base URL and then add Introduction and Prerequisites <place_type place_type_id=quot;29quot;>continent</place_type> (?). Multiple parameters are separated by an ampersand (&). parameters and values after a question mark </place_types> appid=YahooDemo&query=Corvette&results=2 The Yahoo! AJAX Maps API lets developers add maps to their web sites using DHTML and JavaScript®. the Weather RSS feed is The base URL for Maps are fully embeddable and scriptable using the JavaScript programming language. Yahoo! Maps AS-Flash API's ? Error Codes built-in geocoder means that you can specify a physical address or latitude/longitude coordinates for your map's http://weather.yahooapis.com/forecastrss location, as you like. In this section, Summary shows how to make an RSS request with different parameters; Request Parameters In order to create and test applications 100: Yahoo! Maps AJAX API, you'll need to use a supported summarizing those parameters. using Invalid API Key shows a table web The API key passed was not valid or has expired. browser: Firefox 2, Internet Explorer 6 or 7, Opera 9 or Safari 3. Newer versions of these browsers are also supported. You can code your JavaScript applications usingcurrently unavailable 105: Service your favorite text editor or IDE. SUMMARY The requested service is temporarily unavailable. An application ID is required to use the Yahoo! Maps AJAX API. You can get an application ID here. 111: Format quot;xxxquot; not found The Weather RSS feed request follows simple HTTP GET syntax: start with a base URL and then add parameters and values after a question mark (?). Multiple parameters are separated by an ampersand (&). For For best results, you should launch your web pagesrequested response format was not found. applications The from a web server. However, it's possible to run the Weather RSS feed there are two parameters: directly from your hard drive by double-clickingMethod This can be donefound 112: on them. quot;xxxquot; not by lowering the security settings in the Internet Explorer browser or by setting the The requested method was not found. p for location. UniversalBrowserRead property in Firefox. u for degrees units (Fahrenheit or Celsius). http://weather.yahooapis.com/ 114: Invalid SOAP envelope The SOAP envelope send in the requestlocationnot be parsed. required. Use this parameter to indicate the location for the weather forecast as a The could parameter p is Displaying a Yahoo! Map zip code or Location ID. forecastrss?p=FRXX0076&u=c 115: Invalid XML-RPC Method Call All the API classes and methods necessary to interact with Yahoo! Mapsdocument couldyour application when The XML-RPC request are availablehttp://weather.yahooapis.com/forecastrss?p=location to not be parsed. you include Yahoo! Maps AJAX API library in your web page.This example uses the demonstration application ID quot;YD-eQRpTl0_JX2E95l_xAFs5UwZUlNQhhn7lj1Hquot;; you cannot use this Application Forand must requestweather for Yahoo! Headquarters in Sunnyvale, CA, use the zip code for Sunnyvale ID example, to get one API Explorer here. (94089): API Explorer : flickr.places.getPlaceTypes <html> http://weather.yahooapis.com/forecastrss?p=94089 <head> Or use the Location ID for Sunnyvale (USCA1116): <b><script type=quot;text/javascriptquot; src=quot;http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=YD-
  • 36. YQL
  • 37. var map = new YMap(document.getElementById('map')); … var currentGeoPoint = new dev YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint); … … if (flickcurl_prepare(fc, quot;flickr.photos.geo.correctLocationquot;, parameters, count)) { … } … http://search.yahooapis.com/ ImageSearchService/V1/imageSearch? appid=YahooDemo&query=Corvette&results=2 http://weather.yahooapis.com/ forecastrss?p=FRXX0076&u=c
  • 38. dev YQL
  • 39. dev YQL
  • 40. dev Bindings YQL
  • 41. dev Bindings YQL
  • 42. dev Bindings YQL YQL stmt
  • 43. dev Bindings YQL YQL stmt select
  • 44. dev Bindings YQL YQL stmt select desc
  • 45. dev Bindings YQL YQL stmt select desc show
  • 46. Motivation Thousands of Web Services that provide valuable data Requires developers to read documentation and form URLs/queries. Data is isolated Needs combining, tweaking, shaping even after it gets to the developer.
  • 47. YQL SQL-Like Language Synonymous with Data access Familiar to developers Expressive enough to get the right data. Self Describing - show, desc table Allows you to query, filter and join data across WebServices.
  • 48. YQL Statement Basics Verbs show: lists the supported tables desc: describes the structure of a table select: fetches data use: use an Open Data Table *new* show tables desc social.contacts
  • 49. YQL Statement Syntax SELECT what FROM collection WHERE filter condition IN (sub-select) LIMIT n OFFSET n
  • 50. YQL Statement Basics Syntax -> Select -> Collection FROM collection Yahoo! WebServices Social Dir, Upcoming, MyblogLog, Y!Local, Search(BOSS) External DataSources XML, Atom, RSS, JSON, CSV, HTML
  • 51. YQL Statement Basics Syntax -> Select -> WHERE clause Table data can be filtered in the WHERE clause either Remotely by the table data source Locally by the YQL engine (dot notation)
  • 52. YQL Statement Basics Syntax -> WHERE clause -> Remote Filter WHERE <remote_key>=‘value’ Tables require Keys in where clause Specified in the describe <query> <key name=”guid” required=”true” .../> </query> Correspond to query, path or matrix parameters for the Endpoint
  • 53. YQL Statement Basics Syntax -> WHERE clause -> Local Filter WHERE <local_filter> OP ‘value’ Filter an element or an attribute <movies> Dot notation: <movie>Star Wars</movie> movies.movie LIKE ‘%Star%’ <movie>StarTrek</movie> </movies> <, >, =, LIKE, matches, not matches, not like AND, OR binary operator combinations
  • 54. YQL Statement Basics Syntax -> Select -> Projection SELECT <what> Uses the dot notation to project parts of matching item(s) <results> <movie> <id>101</id> Projection: (relative to root) <name>Star Wars</name> select movie.id, movie.name </movie> from ... <movie>...</movie> </results>
  • 55. YQL Statement Basics Syntax -> Select -> Sub-Select IN (SELECT ...) Join across data sources field IN (select guid from ...) Like SELECT but can return only N leaves Get the profile for all my connections: select * from social.profile where guid in (select guid from social.connections where owner_guid = me)
  • 56. YQL Statement Basics Syntax -> Select -> Sub-Select IN (SELECT ...) (field, ...fieldN) IN (SELECT f1,...fn from table) Get the Location name of the given Photo: select place.name from flickr.places where (lat, lon) in (select location.latitude, location.longitude from flickr.photos.info where photo_id='3030238604')
  • 57. YQL Statement Basics Syntax -> Select -> Table Size Changing the Table Size Yahoo! Tables are limited to a small number by default (10) select * from local.search where zip=‘94089’ and query=‘pizza’ Increase set size as parameters to Collection select * from local.search(100) where zip=‘94089’ and query=‘pizza’
  • 58. YQL Statement Basics Syntax -> Post Query Manipulation Post Select processing using ‘pipe’ symbol. select ... | sort(field=‘item.pubDate’) select ... | unique(field=‘item.title’) select ... | tail(count=10) Functions operate on return data. Operations unrelated to table or data source.
  • 59. YQL Statement Basics Syntax -> YQL Variables (@var) Like Prepared Statements for YQL Substitutes Query parameter http://<>?q=....&city=Bangalore&state=Karnataka select * from table where city=@city and state=@state Can be used in sub-selects select * from table where city in (@city, @city2, @city3)
  • 60. YQL Statement Basics Syntax -> YQL Variables (@var) Multi Valued variables http://<>?q=....&city=Bangalore&city=Mumbai select * from table where city in (@city)
  • 61. Sounds Good. But what about my WebService?
  • 62. Can I add my data tables?
  • 63. Open Data Tables YQL
  • 64. Open Data Tables YQL
  • 65. Open Data Tables YQL
  • 66. Open Data Tables YQL
  • 67. Open Data Tables Bindings YQL
  • 68. Open Data Tables YQL
  • 69. Open Data Tables YQL
  • 70. Open Data Tables Map YQL to Endpoint YQL
  • 71. Open Data Tables YQL
  • 72. Open Data Tables YQL
  • 73. Open Data Tables
  • 74. Open Data Tables
  • 75. Open Data Tables Schema defines mapping between YQL and Endpoint Keys can either be query, path or matrix parameters Keys can be marked as required YQL Compiler validates existence of required keys
  • 76. USE Verb use ‘http://url-to-def.xml’ as tableName; select * from tableName where key=‘value’... Imports the Table defintion Makes it available to following statements as tableName desc tableName - describes the def Acts like a First Class Data Source just like other YQL Tables.
  • 77. data
  • 78. One API : YQL
  • 79. Accessing YQL OAuth Endpoint http://query.yahooapis.com/v1/yql? q=... Public Endpoint http://query.yahooapis.com/v1/ public/yql?q= YQL Console http://developer.yahoo.com/yql/ console
  • 80. Accessing YQL YQL Via Pipes
  • 81. Q&A