This document provides an overview of YQL (Yahoo Query Language) and how to use its components. It covers making queries in the YQL console sandbox, creating open data tables to add new features to YQL, using server-side JavaScript with the execute node, and final lessons on accessing Yahoo APIs with YQL.
Decarbonising Buildings: Making a net-zero built environment a reality
Build APIs and mashup data with YQL and the API hack stack
1.
2. YQL and the API hack stack Jonathan LeBlanc Principal Software Engineer / Technology Evangelist Twitter: @jcleblanc
3. What We’re Going to Cover YQL Overview Making Queries and the Console Sandbox Open Data Tables (a.k.a. Adding New Features into YQL) Execute (Server-Side JavaScript) Final Lessons
4. What We’re Going to Cover YQL Overview Making Queries and the Console Sandbox Open Data Tables (a.k.a. Adding New Features into YQL) Execute (Server-Side JavaScript) Final Lessons
11. What We’re Going to Cover YQL Overview Making Queries and the Console Sandbox Open Data Tables (a.k.a. Adding New Features into YQL) Execute (Server-Side JavaScript) Final Lessons
12. Making Requests: Fetching data SELECT myColumn, myTitle FROM myTable(0, 50) WHERE myColumn = 'value' AND myTitle = 'title‘ LIMIT 3 OFFSET 10
13. Making Requests: Inserting data INSERT INTO bitly.shorten (login, apiKey, longUrl) VALUES ('ME', 'API_KEY', 'http://yahoo.com')
14. Making Requests: updating data UPDATE social.profile.status SET status="Using YQL UPDATE” WHERE guid="NJFIDHVPVVISDX7UKED2WHU"
15. Making Requests: deleting data DELETE FROM twittertable WHERE tweetid="12345" AND username="twitter_username" AND password="twitter_password"
16. Making Requests: Sub Selects SELECT * FROM geo.places WHERE text IN (SELECT location FROM social.profile WHERE guid = me)
26. What We’re Going to Cover YQL Overview Making Queries and the Console Sandbox Open Data Tables (a.k.a. Adding New Features into YQL) Execute (Server-Side JavaScript) Final Lessons
27. Open Data Tables: Top Level <?xml version="1.0" encoding="UTF-8"?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <meta></meta> <bindings></bindings> </table>
28. Open Data Tables: Meta Node <?xml version="1.0" encoding="UTF-8"?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <meta></meta> <bindings></bindings> </table>
29. Open Data Tables: Meta Node <?xml version="1.0" encoding="UTF-8"?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <meta> <author>Jonathan LeBlanc</author> <description>My Table</description> <documentationURL>www.site.com </documentationURL> <sampleQuery>SELECT * FROM {table} </sampleQuery> </meta> <bindings></bindings> </table>
30. Open Data Tables: Bindings Node <?xml version="1.0" encoding="UTF-8"?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <meta></meta> <bindings></bindings> </table>
32. Open Data Tables: Using Your Table Several Choices: Upload the XML file to our community Github account. Upload the XML file to your own site and use the YQL ‘USE’ clause.
34. Open Data Tables: Using The USE Clause The USE clause USE 'http://www.mysite.com/my_table.xml' AS mytable; SELECT * FROM mytable WHERE user='john_doe'
35. What We’re Going to Cover YQL Overview Making Queries and the Console Sandbox Open Data Tables (a.k.a. Adding New Features into YQL) Execute (Server-Side JavaScript) Final Lessons
38. Execute: Server-Side JavaScript <execute> <![CDATA[ //get user specified inputs from YQL query vararrQueries = inputs['query']; //create new XML nodes varelQueries = <queries/>; //output new node as YQL response response.object = elQueries; ]]> </execute>
39. What We’re Going to Cover YQL Overview Making Queries and the Console Sandbox Open Data Tables (a.k.a. Adding New Features into YQL) Execute (Server-Side JavaScript) Final Lessons
40. Final Lessons YQL is a skeleton key for all Yahoo! APIs Open data tables allow you to create new data feeds out of one or many different raw sources Execute allows you to manipulate data before it is returned. Use SDKs when accessing private data that requires OAuth
41. Final Lessons: Links All Yahoo! APIs and Services http://developer.yahoo.com/everything.html YQL Documentation http://developer.yahoo.com/yql YQL Console http://developer.yahoo.com/yql/console YQL Github Account (Contribute Tables) http://github.com/yql/yql-tables