SlideShare uma empresa Scribd logo
1 de 37
Yahoo Query Language:
select * from internet
an Introduction
Mirek Grymuza – mirek@yahoo-inc.com
Josh Gordineer – joshgord@yahoo-inc.com
What are we going to cover?
• What, why and brief history of YQL
• Overview of YQL features, YQL Console
• Get into more detail with: YQL in practice
The problem...
...and the solution
My application
my awesome application
•multiple data sources
•different specs and formats
•multiple connections
•api changes to deal with
•no arbitrary sources without work
Enter YQL
•single API spec
•SQL-like
•select/insert/update/delete
•let YQL optimize queries
•powerful
my awesome application
So what can YQL do?
SELECT * FROM flickr.photos.info WHERE photo_id IN (SELECT id FROM flickr.photos.search(1) WHERE text IN (SELECT content FROM
search.termextract WHERE context IN (SELECT body FROM nyt.article.search WHERE apikey='key' AND query='obama' LIMIT 1)))
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
The statement
Filtering, paging, projection
• Table data can be filtered in the WHERE clause either:
–Remotely by the table data source provider or
–Locally by the YQL engine
• YQL tries to present “rows” of data
–Abstracts away “paging” views of data sources
–Presents a “subset” of paging tables by default
• In YQL fields are analogous to the columns of a table,
multiple fields are delimited by commas
select Title,Address from local.search(0,10) where query="sushi" and
location="san francisco, ca" and Rating.AverageRating="4.5" LIMIT 2
Joining across sources
• Sub-select works the same as normal select except it can
only return a “leaf” element value or attribute
• Parallelizes execution
• Example: How to get an international weather forecast?
Join two services in different companies:
select * from weather.forecast where location in (select id from xml where
url=http://xoap.weather.com/search/search?where=prague and
itemPath="search.loc")
Post-query manipulation
• YQL includes built-in functions such as sort, unique,
truncate, tail, reverse...
• Simple post-SELECT processing can be performed by
appending the “pipe” symbol to the end of the
statement SELECT … | sort(field=item.date) SELECT
… | unique(field=item.title) | …
• Functions only operate on the data being returned by the
query, nothing to do with the tables or data sources
themselves
select * from social.profile where guid in (select guid from
social.connections where owner_guid=me) | sort(field="nickname")
How do you benefit?
SELECT * FROM INTERNET
(INSERT/UPDATE/DELETE)
Uniform method for accessing and modifying
internet data and services
Simplify and enrich data and service
access via uniform query language and
execute tables
Now let’s review - what is YQL?
• Cloud web service with 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
• All in Real time
• Inject business logic with execute element
YQL Since Launch...
• open data tables, environment files
• execute element - April
• new paging model
• insert/update/delete, jsonp-x - July
• set verb, yql.storage, debug mode, multi env
• y.rest, y.query with timeouts
• custom cache, query alias
• meta element
• extend execute to add libraries, functions
• console cache, shortener and query builder
• lots of various data tables since then and more being added
Launched October 28 2008
2010
an enhancement
or new feature
added every
month since
2009
...where is YQL today?
Most popular tables this month?
~6B table requests in October
on track to 7B in November
Popular since launch?
YQL Console
• http://developer.yahoo.com/yql/console/
• Hosted site which executes YQL queries
• Swiss Army Knife for YQL Developers
• Design and debug quickly
How many tables?
• default tables – 175
• community tables – 772
• total - 947
YQL Console
Console tables
Query builder and Explorer
YQL In Practice
What is YQL?
• “The Yahoo! Query Language is an expressive SQL-like
language that lets you query, filter, and join data across
Web services.”
• So what does that mean?
• Be “lazy” – Let YQL take care of the data
–Allows you to focus on innovation not on API’s
The Problem
• Fetch the Yahoo! News articles for Twitter trending topics
in San Francisco
• And be “lazy” i.e. use YQL
YQL Tables
• Built-in Tables
–Maintained by the YQL Team (or Yahoo!)
–fantasy sports, weather, answers, flickr, geo, music,
search, upcoming, mail …
• Data Tables
–Specialized tables to fetch raw data from the web
–atom, csv, html, json, xml …
search.news table
Open Data Tables
• Brings the power of YQL to any API
• Open Data Table Schema defines mapping between YQL
and Endpoint
–http://query.yahooapis.com/v1/schema/table.xsd
• Supply the open table with the “use” statement
• Supply multiple open tables with an “env” query parameter
–ENV file contains multiple USE statements
–Loads environment prior to executing YQL query
Open Data Table Example
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<bindings>
<select itemPath="matching_trends.trends.trend"
produces="XML">
<urls>
<url>http://api.twitter.com/1/trends/{woeid}.xml</url>
</urls>
<inputs>
<key id="woeid” paramType="path" required="true" />
</inputs>
</select>
</bindings>
</table>
url and key Elements
<url>http://api.twitter.com/1/trends/{woeid}.xml</url>
• Provides the resource location for your API
<key id="woeid" paramType="path" required="true" />
• Defines the parameters for the API and provides a binding
for the YQL where clause
• paramType can be query or path
• required is optional
Running YQL Queries
• Console
–http://developer.yahoo.com/yql/console
–Quickly discover tables and iterate on queries
• Public Endpoint
–http://query.yahooapis.com/v1/public/yql
–No Auth
–Rate limit 1K/hour per IP
• Authenticated Endpoint
–http://query.yahooapis.com/v1/yql
–OAuth
–10x higher rate limits
YQL Webservice Basics cont’d
• Query passed in as the “q” query parameter
–http://query.yahooapis.com/v1/public/yql?q=show%20ta
bles
• Execute as a simple HTTP GET
–curl
http://query.yahooapis.com/v1/public/yql?q=show%20ta
bles
• Also available for PUT, POST and DELETE
–curl -d "q=show%20tables"
http://query.yahooapis.com/v1/public/yql
ODT Example Response
YQL Execute
• Extends Open Data Tables with custom application logic
• JavaScript server-side scripting
–No DOM
–E4X compatible
• YQL provides additional useful global objects
–request, response, y.rest, y.include, y.query…
Execute Example
<execute><![CDATA[
var resp = request.get().response;
if(resp) {
var trends = resp.trends.trend;
for(var i=trends.length()-1; i>=0; i--) {
var trend = trends[i];
if(trend.charAt(0) == "#") {
delete resp.trends.trend[i];
}
}
}
response.object = resp;
]]></execute>
• Removes all trend topics that start with hashtag (#) using
e4x
• Request and response objects in action
Execute Example Response
Community Tables
• Someone may have done the work for you already
–http://datatables.org
• Tables are hosted on GitHub
–https://github.com/yql/yql-tables
• Use the env query parameter to include all community
tables in a request
–env=store://datatables.org/alltableswithkeys
YQL Tables on GitHub
Contributing
Process for adding/updating tables on Git
1. Fork the YQL Tables project
2. Clone your Fork
3. Make your changes
4. Push Changes / Commit
5. Make Pull Request
6. YQL Table Admin will moderate and merge changes
and generate new push to datatables.org
• Steps 1-5 are standard Git procedures, step 6 is unique
• Git Tutorials
–http://help.github.com/forking
–http://thinkvitamin.com/code/starting-with-git-cheat-
sheet
Twitter Trending News Query
select abstract, url from search.news where query in (
select trend from twitter.trends.location where
woeid=2487956
)
Retrieves news results for the latest twitter trending topics in
San Francisco
• Combines numerous API calls into a single YQL query
• Filters search.news response from 5 fields into just 2
Query Result
YQL sessions @YUIConf
• Monday – Introduction to YQL (this session)
• Tuesday – Building Open Data Tables with YQL Execute
(Classroom 4: 1.45pm)
• Wednesday – YQL + YUI: Building End-To-End
Applications (Classroom 5: 10.15am)
http://developer.yahoo.com/yql/console/
http://developer.yahoo.com/yql/
Questions
mirek@yahoo-inc.com
joshgord@yahoo-inc.com -twitter: @joshgord or @yql
yql-questions@yahoo-inc.com

Mais conteúdo relacionado

Mais procurados

Elastic search apache_solr
Elastic search apache_solrElastic search apache_solr
Elastic search apache_solr
macrochen
 

Mais procurados (20)

ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)ADL/U-SQL Introduction (SQLBits 2016)
ADL/U-SQL Introduction (SQLBits 2016)
 
U-SQL Learning Resources (SQLBits 2016)
U-SQL Learning Resources (SQLBits 2016)U-SQL Learning Resources (SQLBits 2016)
U-SQL Learning Resources (SQLBits 2016)
 
Revision
RevisionRevision
Revision
 
Speed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsSpeed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and Handlebars
 
Solr: 4 big features
Solr: 4 big featuresSolr: 4 big features
Solr: 4 big features
 
Elastic search apache_solr
Elastic search apache_solrElastic search apache_solr
Elastic search apache_solr
 
OCCIware
OCCIwareOCCIware
OCCIware
 
Intro to Apache Solr for Drupal
Intro to Apache Solr for DrupalIntro to Apache Solr for Drupal
Intro to Apache Solr for Drupal
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure Data
 
Introduction to Apache Solr
Introduction to Apache SolrIntroduction to Apache Solr
Introduction to Apache Solr
 
Lesson4
Lesson4Lesson4
Lesson4
 
Dazzing Data Depiction with D3.JS
Dazzing Data Depiction with D3.JSDazzing Data Depiction with D3.JS
Dazzing Data Depiction with D3.JS
 
Graph Databases for SQL Server Professionals
Graph Databases for SQL Server ProfessionalsGraph Databases for SQL Server Professionals
Graph Databases for SQL Server Professionals
 
How Solr Search Works
How Solr Search WorksHow Solr Search Works
How Solr Search Works
 
New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1
 
Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013
 
it's just search
it's just searchit's just search
it's just search
 
Webinar: What's New in Solr 7
Webinar: What's New in Solr 7 Webinar: What's New in Solr 7
Webinar: What's New in Solr 7
 
Tips & Tricks SQL in the City Seattle 2014
Tips & Tricks SQL in the City Seattle 2014Tips & Tricks SQL in the City Seattle 2014
Tips & Tricks SQL in the City Seattle 2014
 
Solr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon ConsultingSolr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon Consulting
 

Destaque (8)

Txjs
TxjsTxjs
Txjs
 
Photography
PhotographyPhotography
Photography
 
Photography
PhotographyPhotography
Photography
 
My bestiessss
My bestiessssMy bestiessss
My bestiessss
 
Contributing to YUI
Contributing to YUIContributing to YUI
Contributing to YUI
 
YUI 3: Below the Surface
YUI 3: Below the SurfaceYUI 3: Below the Surface
YUI 3: Below the Surface
 
oEmbed と Text::Hatena
oEmbed と Text::HatenaoEmbed と Text::Hatena
oEmbed と Text::Hatena
 
7 Habits of Exceptional Performance
7 Habits of Exceptional Performance7 Habits of Exceptional Performance
7 Habits of Exceptional Performance
 

Semelhante a Yui conf nov8-2010-introtoyql

YQL Publicis Hackday
YQL Publicis HackdayYQL Publicis Hackday
YQL Publicis Hackday
Paul Donnelly
 
YQL and Geo
YQL and GeoYQL and Geo
YQL and Geo
mambo91
 
WPP Hackday presentation - YQL
WPP Hackday presentation - YQLWPP Hackday presentation - YQL
WPP Hackday presentation - YQL
sriramiyer2007
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
Erik Hatcher
 
YQL:: Select * from Internet
YQL:: Select * from InternetYQL:: Select * from Internet
YQL:: Select * from Internet
drgath
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
Erik Hatcher
 
Yql V8
Yql V8Yql V8
Yql V8
JH Lee
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
Erik Hatcher
 

Semelhante a Yui conf nov8-2010-introtoyql (20)

SEA Open Hack - YQL
SEA Open Hack - YQLSEA Open Hack - YQL
SEA Open Hack - YQL
 
YQL Publicis Hackday
YQL Publicis HackdayYQL Publicis Hackday
YQL Publicis Hackday
 
YQL and Geo
YQL and GeoYQL and Geo
YQL and Geo
 
YQL: Select * from Internet
YQL: Select * from InternetYQL: Select * from Internet
YQL: Select * from Internet
 
WPP Hackday presentation - YQL
WPP Hackday presentation - YQLWPP Hackday presentation - YQL
WPP Hackday presentation - YQL
 
Yql with geo
Yql with geoYql with geo
Yql with geo
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Query the web with YQL
Query the web with YQLQuery the web with YQL
Query the web with YQL
 
YQL:: Select * from Internet
YQL:: Select * from InternetYQL:: Select * from Internet
YQL:: Select * from Internet
 
Querying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptxQuerying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptx
 
Open Hack Taiwan 2012
Open Hack Taiwan 2012Open Hack Taiwan 2012
Open Hack Taiwan 2012
 
Building intranet applications with ASP.NET AJAX and jQuery
Building intranet applications with ASP.NET AJAX and jQueryBuilding intranet applications with ASP.NET AJAX and jQuery
Building intranet applications with ASP.NET AJAX and jQuery
 
Build your web apps with yql and yui
Build your web apps with yql and yuiBuild your web apps with yql and yui
Build your web apps with yql and yui
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
Efficient working with Databases in LabVIEW - Sam Sharp (MediaMongrels Ltd) -...
 
YQL & Yahoo! Apis
YQL & Yahoo! ApisYQL & Yahoo! Apis
YQL & Yahoo! Apis
 
Rajnish singh(presentation on oracle )
Rajnish singh(presentation on  oracle )Rajnish singh(presentation on  oracle )
Rajnish singh(presentation on oracle )
 
Yql V8
Yql V8Yql V8
Yql V8
 
Data Governance - Atlas 7.12.2015
Data Governance - Atlas 7.12.2015Data Governance - Atlas 7.12.2015
Data Governance - Atlas 7.12.2015
 
Rapid Prototyping with Solr
Rapid Prototyping with SolrRapid Prototyping with Solr
Rapid Prototyping with Solr
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Yui conf nov8-2010-introtoyql

  • 1. Yahoo Query Language: select * from internet an Introduction Mirek Grymuza – mirek@yahoo-inc.com Josh Gordineer – joshgord@yahoo-inc.com
  • 2. What are we going to cover? • What, why and brief history of YQL • Overview of YQL features, YQL Console • Get into more detail with: YQL in practice
  • 4. My application my awesome application •multiple data sources •different specs and formats •multiple connections •api changes to deal with •no arbitrary sources without work
  • 5. Enter YQL •single API spec •SQL-like •select/insert/update/delete •let YQL optimize queries •powerful my awesome application
  • 6. So what can YQL do? SELECT * FROM flickr.photos.info WHERE photo_id IN (SELECT id FROM flickr.photos.search(1) WHERE text IN (SELECT content FROM search.termextract WHERE context IN (SELECT body FROM nyt.article.search WHERE apikey='key' AND query='obama' LIMIT 1))) 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 The statement
  • 7. Filtering, paging, projection • Table data can be filtered in the WHERE clause either: –Remotely by the table data source provider or –Locally by the YQL engine • YQL tries to present “rows” of data –Abstracts away “paging” views of data sources –Presents a “subset” of paging tables by default • In YQL fields are analogous to the columns of a table, multiple fields are delimited by commas select Title,Address from local.search(0,10) where query="sushi" and location="san francisco, ca" and Rating.AverageRating="4.5" LIMIT 2
  • 8. Joining across sources • Sub-select works the same as normal select except it can only return a “leaf” element value or attribute • Parallelizes execution • Example: How to get an international weather forecast? Join two services in different companies: select * from weather.forecast where location in (select id from xml where url=http://xoap.weather.com/search/search?where=prague and itemPath="search.loc")
  • 9. Post-query manipulation • YQL includes built-in functions such as sort, unique, truncate, tail, reverse... • Simple post-SELECT processing can be performed by appending the “pipe” symbol to the end of the statement SELECT … | sort(field=item.date) SELECT … | unique(field=item.title) | … • Functions only operate on the data being returned by the query, nothing to do with the tables or data sources themselves select * from social.profile where guid in (select guid from social.connections where owner_guid=me) | sort(field="nickname")
  • 10. How do you benefit? SELECT * FROM INTERNET (INSERT/UPDATE/DELETE) Uniform method for accessing and modifying internet data and services Simplify and enrich data and service access via uniform query language and execute tables
  • 11. Now let’s review - what is YQL? • Cloud web service with 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 • All in Real time • Inject business logic with execute element
  • 12. YQL Since Launch... • open data tables, environment files • execute element - April • new paging model • insert/update/delete, jsonp-x - July • set verb, yql.storage, debug mode, multi env • y.rest, y.query with timeouts • custom cache, query alias • meta element • extend execute to add libraries, functions • console cache, shortener and query builder • lots of various data tables since then and more being added Launched October 28 2008 2010 an enhancement or new feature added every month since 2009
  • 13. ...where is YQL today? Most popular tables this month? ~6B table requests in October on track to 7B in November Popular since launch?
  • 14. YQL Console • http://developer.yahoo.com/yql/console/ • Hosted site which executes YQL queries • Swiss Army Knife for YQL Developers • Design and debug quickly How many tables? • default tables – 175 • community tables – 772 • total - 947
  • 17. Query builder and Explorer
  • 19. What is YQL? • “The Yahoo! Query Language is an expressive SQL-like language that lets you query, filter, and join data across Web services.” • So what does that mean? • Be “lazy” – Let YQL take care of the data –Allows you to focus on innovation not on API’s
  • 20. The Problem • Fetch the Yahoo! News articles for Twitter trending topics in San Francisco • And be “lazy” i.e. use YQL
  • 21. YQL Tables • Built-in Tables –Maintained by the YQL Team (or Yahoo!) –fantasy sports, weather, answers, flickr, geo, music, search, upcoming, mail … • Data Tables –Specialized tables to fetch raw data from the web –atom, csv, html, json, xml …
  • 23. Open Data Tables • Brings the power of YQL to any API • Open Data Table Schema defines mapping between YQL and Endpoint –http://query.yahooapis.com/v1/schema/table.xsd • Supply the open table with the “use” statement • Supply multiple open tables with an “env” query parameter –ENV file contains multiple USE statements –Loads environment prior to executing YQL query
  • 24. Open Data Table Example <?xml version="1.0" encoding="UTF-8"?> <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd"> <bindings> <select itemPath="matching_trends.trends.trend" produces="XML"> <urls> <url>http://api.twitter.com/1/trends/{woeid}.xml</url> </urls> <inputs> <key id="woeid” paramType="path" required="true" /> </inputs> </select> </bindings> </table>
  • 25. url and key Elements <url>http://api.twitter.com/1/trends/{woeid}.xml</url> • Provides the resource location for your API <key id="woeid" paramType="path" required="true" /> • Defines the parameters for the API and provides a binding for the YQL where clause • paramType can be query or path • required is optional
  • 26. Running YQL Queries • Console –http://developer.yahoo.com/yql/console –Quickly discover tables and iterate on queries • Public Endpoint –http://query.yahooapis.com/v1/public/yql –No Auth –Rate limit 1K/hour per IP • Authenticated Endpoint –http://query.yahooapis.com/v1/yql –OAuth –10x higher rate limits
  • 27. YQL Webservice Basics cont’d • Query passed in as the “q” query parameter –http://query.yahooapis.com/v1/public/yql?q=show%20ta bles • Execute as a simple HTTP GET –curl http://query.yahooapis.com/v1/public/yql?q=show%20ta bles • Also available for PUT, POST and DELETE –curl -d "q=show%20tables" http://query.yahooapis.com/v1/public/yql
  • 29. YQL Execute • Extends Open Data Tables with custom application logic • JavaScript server-side scripting –No DOM –E4X compatible • YQL provides additional useful global objects –request, response, y.rest, y.include, y.query…
  • 30. Execute Example <execute><![CDATA[ var resp = request.get().response; if(resp) { var trends = resp.trends.trend; for(var i=trends.length()-1; i>=0; i--) { var trend = trends[i]; if(trend.charAt(0) == "#") { delete resp.trends.trend[i]; } } } response.object = resp; ]]></execute> • Removes all trend topics that start with hashtag (#) using e4x • Request and response objects in action
  • 32. Community Tables • Someone may have done the work for you already –http://datatables.org • Tables are hosted on GitHub –https://github.com/yql/yql-tables • Use the env query parameter to include all community tables in a request –env=store://datatables.org/alltableswithkeys
  • 33. YQL Tables on GitHub
  • 34. Contributing Process for adding/updating tables on Git 1. Fork the YQL Tables project 2. Clone your Fork 3. Make your changes 4. Push Changes / Commit 5. Make Pull Request 6. YQL Table Admin will moderate and merge changes and generate new push to datatables.org • Steps 1-5 are standard Git procedures, step 6 is unique • Git Tutorials –http://help.github.com/forking –http://thinkvitamin.com/code/starting-with-git-cheat- sheet
  • 35. Twitter Trending News Query select abstract, url from search.news where query in ( select trend from twitter.trends.location where woeid=2487956 ) Retrieves news results for the latest twitter trending topics in San Francisco • Combines numerous API calls into a single YQL query • Filters search.news response from 5 fields into just 2
  • 37. YQL sessions @YUIConf • Monday – Introduction to YQL (this session) • Tuesday – Building Open Data Tables with YQL Execute (Classroom 4: 1.45pm) • Wednesday – YQL + YUI: Building End-To-End Applications (Classroom 5: 10.15am) http://developer.yahoo.com/yql/console/ http://developer.yahoo.com/yql/ Questions mirek@yahoo-inc.com joshgord@yahoo-inc.com -twitter: @joshgord or @yql yql-questions@yahoo-inc.com

Notas do Editor

  1. Transition, search.news is a built-in table
  2. But what about twitter local trending topics, no built-in table, looks like we’ll have to write an ODT
  3. So, based on this, created a twitter trending open data