YQL & Yahoo! APIs - Open Hack India 2011
-
Upload
saurabh-sahni -
Category
Technology
-
view
4.066 -
download
6
description
Transcript of YQL & Yahoo! APIs - Open Hack India 2011
![Page 1: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/1.jpg)
![Page 2: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/2.jpg)
YQL AND YAHOO! APIS
Saurabh Sahni YDN Developer, Hacker, Evangelist Twitter: @saurabhsahni
![Page 3: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/3.jpg)
Hacking together systems in 24 hours is lot of fun
![Page 4: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/4.jpg)
Hacks = Data manipulation
+ Data visualization
![Page 5: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/5.jpg)
The web has lot of data around
![Page 6: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/6.jpg)
ProgrammableWeb.Com – 3517 APIs
![Page 7: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/7.jpg)
Yahoo! has opened up its data
![Page 8: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/8.jpg)
http://developer.yahoo.com/everything.html
![Page 9: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/9.jpg)
THE TROUBLE WITH DATA • You 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
![Page 10: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/10.jpg)
To make data access easy on the web, Yahoo! created YQL
![Page 11: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/11.jpg)
YQL turns web services and data on the web into databases.
![Page 12: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/12.jpg)
select {what} from {where} where {conditions}
![Page 13: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/13.jpg)
You can select, filter, sort and limit
![Page 14: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/14.jpg)
You can even insert, update and delete from it.
![Page 15: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/15.jpg)
FINDING VIDEOS ABOUT BANGALORE
SELECT * FROM youtube.search where query='bangalore'
![Page 16: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/16.jpg)
SELECTING PHOTOS OF HACKDAY
SELECT * FROM flickr.photos.search where text="hackday"
![Page 17: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/17.jpg)
INSERTING DATA
INSERT INTO bitly.shorten (login, apiKey, longUrl)
VALUES ('ME', 'API_KEY', 'http://yahoo.com')
![Page 18: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/18.jpg)
UPDATING DATA
UPDATE social.profile.status
SET status="Using YQL UPDATE”
WHERE guid="NJFIDHVPVVISDX7UKED2WHU"
![Page 19: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/19.jpg)
RETRIEVING MY CONTACTS
SELECT * FROM social.contacts WHERE guid=me
![Page 20: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/20.jpg)
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
![Page 21: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/21.jpg)
The easiest way to start with YQL is to use the console
http://developer.yahoo.com/yql/console
![Page 22: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/22.jpg)
YQL: http://developer.yahoo.com/yql/console
![Page 23: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/23.jpg)
![Page 24: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/24.jpg)
![Page 25: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/25.jpg)
![Page 26: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/26.jpg)
URL STRUCTURE
http://query.yahooapis.com/v1/yql?[params] http://query.yahooapis.com/v1/public/yql?[params]
Params • q = [ YQL QUERY ] • format = [ XML / JSON ] • diagnostics = [ true / false ] • debug = [ true / false ] • callback = [ function name ]
![Page 27: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/27.jpg)
LET’S SEE IT
![Page 28: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/28.jpg)
QUERY EXAMPLES
Find hackday tweets: SELECT * FROM twitter.search where q='hackday’
Search Yahoo! Answers for resolved questions about cars: select * from answers.search where query="cars" and type="resolved”
Translate tweets into Hindi: select * from google.translate where q in (select text from twitter.search where q="hackday") and target='hi';
Extract important terms from top stories on Yahoo! news: select * from search.termextract where context in (select description from rss where url='http://rss.news.yahoo.com/rss/topstories')
![Page 29: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/29.jpg)
QUERY EXAMPLES
Find distance between Bangalore and Mumbai: select * from geo.distance where place1="bangalore" and place2="mumbai”
Get stock quotes for Yahoo!, Apple, Google & Microsoft in one query: select * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT")
Shorten a URL: insert into yahoo.y.ahoo.it (url, keysize) values ('http://www.javarants.com', 5)
Search apartments in criagslist: select * from craigslist.search where location="bangalore" and type="apa" and query="indiranagar”
![Page 30: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/30.jpg)
QUERY EXAMPLES
Scrape news from Yahoo! Finance: select * from html where url="http://finance.yahoo.com/q?s=yhoo" and xpath='//div[@id="yfi_headlines"]/div[2]/ul/li/a’
Select, filter data from google spreadsheets: select * from csv where url="https://spreadsheets.google.com/pub?key=0ArYndzim-lbrdF8wc3A5QWl1ZGRpdkxRZk80SU9zUXc&output=csv" and col5 like 'Bangalore%’ ;
![Page 31: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/31.jpg)
Let’s find openhackindia photos on flickr
![Page 32: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/32.jpg)
![Page 33: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/33.jpg)
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"/>
![Page 34: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/34.jpg)
MAKING REQUESTS: FLICKR URLS
http://farm{$farm}.static.flickr.com/{$server}/{$id}_{$secret}.jpg
Photo URL
http://www.flickr.com/photos/{$owner}/{$id} Photo Page URL
http://www.flickr.com/photos/{$owner} Photo Owner Profile URL
![Page 35: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/35.jpg)
![Page 36: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/36.jpg)
https://github.com/saurabhsahni/Hacks/
![Page 37: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/37.jpg)
Finding Recent Photos from flickr
![Page 38: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/38.jpg)
Some YQL Hacks
![Page 39: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/39.jpg)
ChromYQLip is a chrome extension for page scraping via YQL
Open Hack Bangalore 2010 Winner
![Page 40: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/40.jpg)
http://bit.ly/chromeYQL
![Page 41: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/41.jpg)
VIDEO CLIP
![Page 42: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/42.jpg)
http://www.webmeme.in
![Page 43: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/43.jpg)
WEBMEME.IN
Fetch multiple feeds in different formats like atom, RSS and transform them into consistent RSS format Select * from rss where url in (‘http://feeds.feedburner.com/pluggd’, ‘http://quatrainman.blogspot.com/atom.xml’, ‘…’)
Filter news containing “india” from multiple feeds: select * from rss where url in ('http://feeds.feedburner.com/TechCrunch', 'http://www.readwriteweb.com/rss.xml','http://gigaom.com/feed/') and description like '%india%’
![Page 44: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/44.jpg)
YQL is open – you can get your data tables in our system
![Page 45: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/45.jpg)
All you need to do is write an XML schema and put it on Github.
![Page 46: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/46.jpg)
http://github.com/yql/yql-tables
![Page 47: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/47.jpg)
Here is the craigslist search table https://github.com/yql/yql-tables/tree/master/craigslist/craigslist.search.xml
![Page 48: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/48.jpg)
![Page 49: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/49.jpg)
USE INSTANTLY BY UPLOADING ON YOUR SITE
USE 'http://www.mysite.com/my_table.xml' AS mytable; SELECT * FROM mytable WHERE user='saurabh'
![Page 50: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/50.jpg)
You can even write server side javascript to build a webservice or augment one. h#p://developer.yahoo.com/yql/guide/yql-‐execute-‐chapter.html
![Page 51: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/51.jpg)
There are lot of things you can do with YQL.
![Page 52: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/52.jpg)
Play yourself http://developer.yahoo.com/yql/
![Page 53: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/53.jpg)
RESOURCES
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
![Page 54: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/54.jpg)
ANY QUESTIONS?
Saurabh Sahni
Twitter: @saurabhsahni Github: http://github.com/saurabhsahni Web: http://www.saurabhsahni.com
http://www.slideshare.net/saurabhsahni
![Page 55: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/55.jpg)
![Page 56: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/56.jpg)
![Page 57: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/57.jpg)
![Page 58: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/58.jpg)
![Page 59: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/59.jpg)
![Page 60: YQL & Yahoo! APIs - Open Hack India 2011](https://reader034.fdocuments.net/reader034/viewer/2022051612/54bd62fb4a79595e238b45fd/html5/thumbnails/60.jpg)