Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
Hack with YUI
Hack with YUI
Cargando en…3
×

Eche un vistazo a continuación

1 de 39 Anuncio

Más Contenido Relacionado

Anuncio

Similares a Hack Day EU 2011 YQL (20)

Más de Jonathan LeBlanc (20)

Anuncio

Más reciente (20)

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: YQL FETCHes data<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. Making Requests: Inserting data<br />INSERT INTO bitly.shorten (login, apiKey, longUrl)<br />VALUES ('ME', 'API_KEY', 'http://yahoo.com') <br />
  14. 14. Making Requests: updating data<br />UPDATE social.profile.status<br />SET status="Using YQL UPDATE” <br />WHERE guid="NJFIDHVPVVISDX7UKED2WHU"<br />
  15. 15. Making Requests: deleting data<br />DELETE FROM twittertable<br />WHERE tweetid="12345" <br />AND username="twitter_username" <br />AND password="twitter_password"<br />
  16. 16. Making Requests: Sub Selects<br />SELECT * FROM geo.places WHERE text IN (SELECT location FROM social.profile WHERE guid = me)<br />
  17. 17. Making Requests: The yql console<br />http://developer.yahoo.com/yql/console<br />
  18. 18. Making Requests: Flickr URLs<br /><photo farm="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. Making Requests: 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. 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 at https://github.com/yahoo<br />
  25. 25. Making Requests: Let’s See It<br />
  26. 26. 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 />
  27. 27. 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 />
  28. 28. 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 />
  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><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 />
  30. 30. 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 />
  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><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 />
  32. 32. 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 />
  33. 33. Open Data Tables: Community Tables<br />http://github.com/yql/yql-tables<br />
  34. 34. Open Data Tables: Using The USE Clause<br />The USE clause<br />USE 'http://www.mysite.com/my_table.xml' <br />AS mytable; <br />SELECT * FROM mytable<br />WHERE user='john_doe'<br />
  35. 35. 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 />
  36. 36. 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 />
  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 /><execute></execute><br /> </select> <br /> </bindings><br /></table><br />
  38. 38. 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 />
  39. 39. 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 />
  40. 40. 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 />
  41. 41. 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 />
  42. 42. Any questions?<br />http://www.slideshare.net/jcleblanc/hack-day-eu-2011-yql<br />Jonathan LeBlanc<br />Twitter: @jcleblanc<br />E-Mail: jleblanc@yahoo-inc.com<br />

×