YQL & YAHOO! APIS

                    Jai Santhosh
       Frontend Engineer, Hacker
                          Yahoo!
What We’re Going to Cover

• YQL Overview

• Making Queries and the Console Sandbox

• Demo

• Open Data Tables and Execute (Server-Side
  JavaScript)

• Final Lessons
Data manipulation
Hacks =           +
          Data visualization
The web is a large pile of data!
ProgrammableWeb.com – 4480 Apis
Yahoo! has also
opened up its data
http://developer.yahoo.com/everything.html
Trouble with Data
• Need to find data API
• Get Access – Signup for key
• Find data endpoint
• Read docs to learn what parameters you
  have
• Get data in obscure format
• Use data after converting and filtering
• More APIs you use, more is your
  annoyance
To make data access easy on
         the web,
    Yahoo! created YQL
=
YQL turns web services and
  data on the web into
        databases.
select {what} from {where}
    where {conditions}
You can select, filter, sort
and limit data and you can
  even insert, update and
      delete from it.
YQL: http://developer.yahoo.com/yql/console
Finding Videos about Bangalore


• SELECT * FROM youtube.search where
  query='bangalore'
Selecting Photos of RHOK


• SELECT * FROM flickr.photos.search where
  text="rhok"
Inserting data


INSERT INTO bitly.shorten (login, apiKey, longUrl)

VALUES ('ME', 'API_KEY', 'http://yahoo.com')
updating data


UPDATE social.profile.status


SET status="Using YQL UPDATE”


WHERE guid="NJFIDHVPVVISDX7UKED2WHU"
Accessing Private Data
      • http://query.yahooapis.com/v1/yql

Uses OAuth 1.0 for authorization

OAuth is complicated – use one of our SDKs at
https://github.com/yahoo
Retrieving my profile


• SELECT * FROM social.contacts WHERE
  guid=me
Using the YQL Console
makes it very easy to
        use it.
url structure
• http://query.yahooapis.com/v1/yql?[params]
• http://query.yahooapis.com/v1/public/yql?[para
  ms]
    Params
    q=            [ YQL QUERY ]
    format =      [ XML / JSON ]
    diagnostics = [ true / false ]
    debug =       [ true / false ]
    callback =    [ function name ]
Let’s See It
Query Samples
•   SELECT * FROM twitter.search where q='hackathon’ limit 5

•   select * from answers.search where query="cars" and type="resolved"

•   select * from google.translate where q="this is a test" and target="hi";

•   select * from google.translate where q in (select text from twitter.search
    where q="hackday") and target='hi';

•   select * from search.termextract where context in (select description from
    rss where url='http://rss.news.yahoo.com/rss/topstories')
Query Samples
• select * from yahoo.finance.quotes where symbol in
  ("YHOO","AAPL","GOOG","MSFT")

• insert into yahoo.shortener (url, keysize) values
  ('http://www.javarants.com', 5)

• select * from craigslist.search where location="bangalore" and
  type="apa" and query="indiranagar”

• select * from html where url="http://finance.yahoo.com/q?s=yhoo"
  and xpath='//div[@id="yfi_headlines"]/div[2]/ul/li/a’
Making Requests: Flickr URLs
<photo   farm="3"
         id="5708163920"
         isfamily="0"
         isfriend="0"
         ispublic="1"
         owner="31832337@N04"
         secret="0075137487"
         server="2496"
         title="San Francisco"/>
Making Requests: Flickr URLs
Photo URL
http://farm{$farm}.static.flickr.com/{$server}/{$id
}_{$secret}.jpg


Photo Page URL
http://www.flickr.com/photos/{$owner}/{$id}


Photo Owner Profile URL
http://www.flickr.com/photos/{$owner}
YQL is open – you can get your
  data tables in our system
Craigslist data table
<table>
  <meta>
   <author>Yahoo! Inc.</author>
   <documentationURL>http://craigslist.org/</documentationURL>
    <sampleQuery>
    select * from {table} where location="sfbay" and type="sss" and query=“bike”
    </sampleQuery>
  </meta>
  <bindings>
    …
  </bindings>
</table>
Craigslist data table
<table>
 <meta> … </meta>
  <bindings>
   <select itemPath="" produces="XML">
     <urls>
       <url>http://{location}.craigslist.org/search/{type}?format=rss</url>
     </urls>
     <inputs>
       <key id="location" type="xs:string" paramType="path" required="true"/>
       <key id="type" type="xs:string" paramType="path" required="true"/>
       <key id="query" type="xs:string" paramType="query" required="true"/>
     </inputs>
    </select>
  </bindings>
</table>
Upload XML to our Github
 http://github.com/yql/yql-tables
Or to your own Site

• The USE clause

USE 'http://www.mysite.com/my_table.xml'
AS mytable;

SELECT * FROM mytable
WHERE user='john_doe'
You can even write server side
javascript to build a webservice
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

• There are 1200+ Tables in YQL covering all major APIs
  on the web

• Use SDKs when accessing private data that requires
  OAuth
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
http://isithackday.com/hackday-toolbox/
Questions?
http://www.slideshare.net/jaisa
nth




 Jai Santhosh

 Twitter: @jaisanth
 Github: http://github.com/jaisanth
THANK YOU!

YQL & Yahoo! Apis

  • 1.
    YQL & YAHOO!APIS Jai Santhosh Frontend Engineer, Hacker Yahoo!
  • 2.
    What We’re Goingto Cover • YQL Overview • Making Queries and the Console Sandbox • Demo • Open Data Tables and Execute (Server-Side JavaScript) • Final Lessons
  • 3.
    Data manipulation Hacks = + Data visualization
  • 4.
    The web isa large pile of data!
  • 5.
  • 6.
  • 7.
  • 8.
    Trouble with Data •Need to find data API • Get Access – Signup for key • Find data endpoint • Read docs to learn what parameters you have • Get data in obscure format • Use data after converting and filtering • More APIs you use, more is your annoyance
  • 9.
    To make dataaccess easy on the web, Yahoo! created YQL
  • 10.
    = YQL turns webservices and data on the web into databases.
  • 11.
    select {what} from{where} where {conditions}
  • 12.
    You can select,filter, sort and limit data and you can even insert, update and delete from it.
  • 13.
  • 14.
    Finding Videos aboutBangalore • SELECT * FROM youtube.search where query='bangalore'
  • 15.
    Selecting Photos ofRHOK • SELECT * FROM flickr.photos.search where text="rhok"
  • 16.
    Inserting data INSERT INTObitly.shorten (login, apiKey, longUrl) VALUES ('ME', 'API_KEY', 'http://yahoo.com')
  • 17.
    updating data UPDATE social.profile.status SETstatus="Using YQL UPDATE” WHERE guid="NJFIDHVPVVISDX7UKED2WHU"
  • 18.
    Accessing Private Data • http://query.yahooapis.com/v1/yql Uses OAuth 1.0 for authorization OAuth is complicated – use one of our SDKs at https://github.com/yahoo
  • 19.
    Retrieving my profile •SELECT * FROM social.contacts WHERE guid=me
  • 20.
    Using the YQLConsole makes it very easy to use it.
  • 23.
    url structure • http://query.yahooapis.com/v1/yql?[params] •http://query.yahooapis.com/v1/public/yql?[para ms] Params q= [ YQL QUERY ] format = [ XML / JSON ] diagnostics = [ true / false ] debug = [ true / false ] callback = [ function name ]
  • 24.
  • 25.
    Query Samples • SELECT * FROM twitter.search where q='hackathon’ limit 5 • select * from answers.search where query="cars" and type="resolved" • select * from google.translate where q="this is a test" and target="hi"; • select * from google.translate where q in (select text from twitter.search where q="hackday") and target='hi'; • select * from search.termextract where context in (select description from rss where url='http://rss.news.yahoo.com/rss/topstories')
  • 26.
    Query Samples • select* from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT") • insert into yahoo.shortener (url, keysize) values ('http://www.javarants.com', 5) • select * from craigslist.search where location="bangalore" and type="apa" and query="indiranagar” • select * from html where url="http://finance.yahoo.com/q?s=yhoo" and xpath='//div[@id="yfi_headlines"]/div[2]/ul/li/a’
  • 27.
    Making Requests: FlickrURLs <photo farm="3" id="5708163920" isfamily="0" isfriend="0" ispublic="1" owner="31832337@N04" secret="0075137487" server="2496" title="San Francisco"/>
  • 28.
    Making Requests: FlickrURLs Photo URL http://farm{$farm}.static.flickr.com/{$server}/{$id }_{$secret}.jpg Photo Page URL http://www.flickr.com/photos/{$owner}/{$id} Photo Owner Profile URL http://www.flickr.com/photos/{$owner}
  • 29.
    YQL is open– you can get your data tables in our system
  • 30.
    Craigslist data table <table> <meta> <author>Yahoo! Inc.</author> <documentationURL>http://craigslist.org/</documentationURL> <sampleQuery> select * from {table} where location="sfbay" and type="sss" and query=“bike” </sampleQuery> </meta> <bindings> … </bindings> </table>
  • 31.
    Craigslist data table <table> <meta> … </meta> <bindings> <select itemPath="" produces="XML"> <urls> <url>http://{location}.craigslist.org/search/{type}?format=rss</url> </urls> <inputs> <key id="location" type="xs:string" paramType="path" required="true"/> <key id="type" type="xs:string" paramType="path" required="true"/> <key id="query" type="xs:string" paramType="query" required="true"/> </inputs> </select> </bindings> </table>
  • 32.
    Upload XML toour Github http://github.com/yql/yql-tables
  • 33.
    Or to yourown Site • The USE clause USE 'http://www.mysite.com/my_table.xml' AS mytable; SELECT * FROM mytable WHERE user='john_doe'
  • 34.
    You can evenwrite server side javascript to build a webservice
  • 35.
    Final Lessons • YQLis 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 • There are 1200+ Tables in YQL covering all major APIs on the web • Use SDKs when accessing private data that requires OAuth
  • 36.
    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
  • 37.
  • 38.
    Questions? http://www.slideshare.net/jaisa nth Jai Santhosh Twitter: @jaisanth Github: http://github.com/jaisanth
  • 39.

Editor's Notes

  • #2 Give you an overview of YQLHow can you use it for your hacksWe will see lots of examples How you can extend by creating new APIs out of webpages/data sources and for executing JS on server orQnA
  • #4 A.K,.A a big waste of time
  • #5 A.K,.A a big waste of time
  • #6 Youtube, Twitter, Facebook, Google, Amazon, eBay, Craigslist, Imdb, Last.fm
  • #7 A.K,.A a big waste of time
  • #8 Search, Flickr, Geo, Placemaker, placefinder, Social, News, Finance, Mail, Messenger, Address Book, Maps, Anwsers
  • #9 A.K,.A a big waste of time
  • #10 A.K,.A a big waste of time
  • #11 A.K,.A a big waste of time
  • #13 A.K,.A a big waste of time
  • #14 YQL is a sql like language
  • #21 A.K,.A a big waste of time
  • #30 A.K,.A a big waste of time
  • #35 A.K,.A a big waste of time
  • #40 Community ResourcesHelping you be successful in using Yahoo! Web Services isn&apos;t just about code and documentation. We want to make it easy for developers to get in touch with us and others who are using our services to answer and ask questions, toss around ideas, and give your feedback on what services we could offer next.ForumsYDN General BoardsDesign PatternsHotJobsSearchYOSAPTMusicWidgetsGeoPlanetOpenIDY! GroupsAddress BookAnswersFireEagleDel.icio.usTrafficFlickrMailSearchBOSSMapsJavaScriptSilverlightMerchant SolutionsSearch MarketingExceptional PerformanceYUIJava.NetFlashYDN EUAuthPHPPythonRubyPerlEventsWant your tech event appear in the YDN &apos;Upcoming Events&apos; stream on developer.yahoo.com homepage? List your event on Upcoming and then add it to the Yahoo! Developer Network group on Upcoming. If you are setting up a tech event for developers or designers and would like some Yahoo! involvement, please contact us.ExpertsYahoo! Developer Network is on the lookout for experts to share knowledge and help grow our developer communities. If you are interested in applying to moderate a *group* or forum and become an official expert, please contact us for more information. Remember, we pay in hugs, link-love and schwag only.BlogThe YDN blog is where we talk about our various Yahoo! developer offerings and YDN events around the world. Your comments welcome. If you have a suggestion for the blog or a blog post you&apos;d like to write about your experiences using our APIs or services, let us know. We are particularly interested in posts using Yahoo! APIs, tools, webservices and coverage of tech events. If you need inspiration or want to run some ideas by us, please contact us.YDN TheaterYDN Theater is chock-full of API deep dives, developer interviews, cutting- edge technologies, and recaps of tech events you wish you hadn&apos;t missed. If you have an idea for a story, please contact us.