Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Hack Day EU 2011 YQL

6,922 views

Published on

"YQL and other hack APIs" presentation for May 2011 Yahoo! Developer Network Hack Day EU in Bucharest, Romania.

Published in: Technology

Hack Day EU 2011 YQL

  1. 1.
  2. 2. YQL and the API hack stack<br />Jonathan LeBlanc<br />Principal Software Engineer / Technology Evangelist<br />Twitter: @jcleblanc<br />
  3. 3. What We’re Going to Cover<br />YQL Overview<br />Making Queries and the Console Sandbox<br />Open Data Tables (a.k.a. Adding New Features into YQL)<br />Execute (Server-Side JavaScript)<br />Final Lessons<br />
  4. 4. What We’re Going to Cover<br />YQL Overview<br />Making Queries and the Console Sandbox<br />Open Data Tables (a.k.a. Adding New Features into YQL)<br />Execute (Server-Side JavaScript)<br />Final Lessons<br />
  5. 5. Overview: Don’t reinvent the wheel!<br />
  6. 6. Overview: The Components of YQL<br />YQL Service<br />Web API<br />YQL Table<br />USER<br />
  7. 7. Overview: YQLFETCHesdata<br />
  8. 8. Overview: YQL Sets and deletes data<br />
  9. 9. Overview: IS YQL A DATABASE?<br />
  10. 10. Overview:YQL is not a database<br />
  11. 11. What We’re Going to Cover<br />YQL Overview<br />Making Queries and the Console Sandbox<br />Open Data Tables (a.k.a. Adding New Features into YQL)<br />Execute (Server-Side JavaScript)<br />Final Lessons<br />
  12. 12. Making Requests: Fetching data<br />SELECT myColumn, myTitle<br />FROM myTable(0, 50) <br />WHERE myColumn = 'value' <br />AND myTitle = 'title‘<br />LIMIT 3 OFFSET 10<br />
  13. 13. MakingRequests: Inserting data<br />INSERT INTO bitly.shorten (login, apiKey, longUrl)<br />VALUES ('ME', 'API_KEY', 'http://yahoo.com') <br />
  14. 14. MakingRequests: updating data<br />UPDATE social.profile.status<br />SET status="Using YQL UPDATE” <br />WHERE guid="NJFIDHVPVVISDX7UKED2WHU"<br />
  15. 15. MakingRequests: deleting data<br />DELETE FROM twittertable<br />WHERE tweetid="12345" <br />AND username="twitter_username" <br />AND password="twitter_password"<br />
  16. 16. MakingRequests: Sub Selects<br />SELECT * FROM geo.places WHERE textIN (SELECT location FROM social.profile WHERE guid = me)<br />
  17. 17. MakingRequests: The yql console<br />http://developer.yahoo.com/yql/console<br />
  18. 18. MakingRequests: Flickr URLs<br /><photofarm="3"<br />id="5708163920"<br />isfamily="0"<br />isfriend="0"<br />ispublic="1"<br />owner="31832337@N04"<br />secret="0075137487"<br />server="2496"<br />title="San Francisco"/><br />
  19. 19. MakingRequests: Flickr URLs<br />Photo URL<br />http://farm{$farm}.static.flickr.com/{$server}/{$id}_{$secret}.jpg<br />Photo Page URL<br />http://www.flickr.com/photos/{$owner}/{$id}<br />Photo Owner Profile URL<br />http://www.flickr.com/photos/{$owner}<br />
  20. 20. Making Requests: url structure<br />http://query.yahooapis.com/v1/yql?[params]<br />http://query.yahooapis.com/v1/public/yql?[params]<br />Params<br /><ul><li>q= [ YQL QUERY ]
  21. 21. format = [ XML / JSON]
  22. 22. diagnostics = [ true / false ]
  23. 23. debug = [ true / false ]
  24. 24. env= [ .env file URL ]
  25. 25. callback = [ function name ]</li></li></ul><li>Making Requests: Private Data<br />http://query.yahooapis.com/v1/yql<br />Uses OAuth 1.0 for authorization<br />OAuth is complicated – use one of our SDKs athttps://github.com/yahoo<br />
  26. 26. Making Requests: Let’s See It<br />
  27. 27. What We’re Going to Cover<br />YQL Overview<br />Making Queries and the Console Sandbox<br />Open Data Tables (a.k.a. Adding New Features into YQL)<br />Execute (Server-Side JavaScript)<br />Final Lessons<br />
  28. 28. Open Data Tables: Top Level<br /><?xml version="1.0" encoding="UTF-8"?><br /><table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <br /> <meta></meta> <br /> <bindings></bindings><br /></table><br />
  29. 29. Open Data Tables: Meta Node<br /><?xml version="1.0" encoding="UTF-8"?><br /><table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <br /><meta></meta> <br /> <bindings></bindings><br /></table><br />
  30. 30. Open Data Tables: Meta Node<br /><?xml version="1.0" encoding="UTF-8"?><br /><table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <br /><meta><br /><author>Jonathan LeBlanc</author> <br /> <description>My Table</description> <br /> <documentationURL>www.site.com<br /> </documentationURL> <br /> <sampleQuery>SELECT * FROM {table}<br /> </sampleQuery><br /> </meta> <br /> <bindings></bindings><br /></table><br />
  31. 31. Open Data Tables: Bindings Node<br /><?xml version="1.0" encoding="UTF-8"?><br /><table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <br /> <meta></meta> <br /><bindings></bindings><br /></table><br />
  32. 32. Open Data Tables: Bindings Node<br /><?xml version="1.0" encoding="UTF-8"?><br /><table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <br /> <meta></meta> <br /><bindings><br /><select itemPath="top.child" produces="XML"> <br /> <urls> <br /> <urlenv="all">http://www.site.com/{user}</url> <br /> </urls> <br /> <inputs> <br /> <key id="user" type="xs:string" paramType="path" <br /> required="true" /><br /> </inputs> <br /> </select><br /> </bindings><br /></table><br />
  33. 33. Open Data Tables: Using Your Table<br />Several Choices:<br />Upload the XML file to our community Github account.<br />Upload the XML file to your own site and use the YQL ‘USE’ clause.<br />
  34. 34. Open Data Tables: Community Tables<br />http://github.com/yql/yql-tables<br />
  35. 35. Open Data Tables: Using The USE Clause<br />The USE clause<br />USE 'http://www.mysite.com/my_table.xml' <br />ASmytable; <br />SELECT * FROMmytable<br />WHERE user='john_doe'<br />
  36. 36. What We’re Going to Cover<br />YQL Overview<br />Making Queries and the Console Sandbox<br />Open Data Tables (a.k.a. Adding New Features into YQL)<br />Execute (Server-Side JavaScript)<br />Final Lessons<br />
  37. 37. Execute: Execute Node<br /><?xml version="1.0" encoding="UTF-8"?><br /><table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <br /> <meta></meta> <br /> <bindings><br /><select itemPath="top.child" produces="XML"> <br /> <urls></urls> <br /> <inputs></inputs> <br /> </select><br /> </bindings><br /></table><br />
  38. 38. Execute: Execute Node<br /><?xml version="1.0" encoding="UTF-8"?><br /><table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <br /> <meta></meta> <br /> <bindings><br /><select itemPath="top.child" produces="XML"> <br /> <urls></urls> <br /> <inputs></inputs><br /><execute></execute><br /> </select><br /> </bindings><br /></table><br />
  39. 39. Execute: Server-Side JavaScript<br /><execute><br /> <![CDATA[<br /> //get user specified inputs from YQL query<br />vararrQueries = inputs['query'];<br /> //create new XML nodes<br />varelQueries = <queries/>;<br /> //output new node as YQL response <br />response.object = elQueries;<br /> ]]><br /></execute> <br />
  40. 40. What We’re Going to Cover<br />YQL Overview<br />Making Queries and the Console Sandbox<br />Open Data Tables (a.k.a. Adding New Features into YQL)<br />Execute (Server-Side JavaScript)<br />Final Lessons<br />
  41. 41. Final Lessons<br />YQL is a skeleton key for all Yahoo! APIs<br />Open data tables allow you to create new data feeds out of one or many different raw sources<br />Execute allows you to manipulate data before it is returned.<br />Use SDKs when accessing private data that requires OAuth<br />
  42. 42. Final Lessons: Links<br />All Yahoo! APIs and Services<br />http://developer.yahoo.com/everything.html<br />YQL Documentation<br />http://developer.yahoo.com/yql<br />YQL Console<br />http://developer.yahoo.com/yql/console<br />YQL Github Account (Contribute Tables)<br />http://github.com/yql/yql-tables<br />
  43. 43. Any questions?<br />http://www.slideshare.com/jcleblanc/<br />Jonathan LeBlanc<br />Twitter: @jcleblanc<br />E-Mail: jleblanc@yahoo-inc.com<br />

×