Upload
nageshs
View
2.993
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Slides from my YQL (Yahoo Query Language) Talk @ OpenHackDay Bangalore held on 14th/15th Feb '09
Citation preview
A Query Language for the Web
YQL
Nagesh Susarla
Agenda
Why YQL?
YQL Statement Basics
Accessing YQL
Q&A
Application ?
Application ?
Application ?
Application ?
Application ?
Application =
Application =data manipulation
Application =data manipulation
data visualization+
datadata
datadata
data
dev
dev
dev
dev
dev
dev
dev
dev
dev
dev
dev
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
?
??
?
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
?
??
?
dev
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
?
??
?
Yahoo! My Yahoo! Mail Welcome, guest Sign In
Introduction and Prerequisites
Examples
Display a Yahoo! Map
Add controls to your Yahoo! Map
Add a logger to a Yahoo! Map
Place a marker on a Yahoo! Map
Draw Polylines on a Yahoo! Map
Place Smart Markers on a Yahoo! Map
Add multiple custom markers on Yahoo! Map
Traffic information overlay
Yahoo! Pipes RSS output information overlay
Yahoo! Pipes JSON output information overlay
Local search results overlay
Overlay GeoRSS XML data
Overlay custom objects at YGeoPoint location
Overlay custom objects at YCoordPoint location
Overlay polyline on Yahoo! Map
Export Yahoo! Map in GeoRSS format
GeoRSS overlay with polyline
Get zoom level given radius from center
Custom position of controls
Change Marker Images Dynamically
Use YMapTypeControl to position map types
Other Features of the Yahoo! Maps AJAX API
Rate Limit
Terms of Service
Support & Community
Download all of the cheatsheets and example code in the Yahoo
Maps API Reference Bundle.
For detailed descriptions of the classes and methods in the API,
check out v3.8 Reference Manual.
Yahoo! Maps Cheatsheets
YMap
YEvent, YGeoRSS, YMarker
Remaining, Supporting Classes
Yahoo! Maps Web Services - AJAX API Getting
Started Guide
Learn the fundamentals of the Yahoo! Maps AJAX API and start creating your own maps. This page contains:
Introduction and Prerequisites
The Yahoo! AJAX Maps API lets developers add maps to their web sites using DHTML and JavaScript®. Maps
are fully embeddable and scriptable using the JavaScript programming language. Yahoo! Maps AS-Flash API's
built-in geocoder means that you can specify a physical address or latitude/longitude coordinates for your map's
location, as you like.
In order to create and test applications using Yahoo! Maps AJAX API, you'll need to use a supported web
browser: Firefox 2, Internet Explorer 6 or 7, Opera 9 or Safari 3. Newer versions of these browsers are also
supported. You can code your JavaScript applications using your favorite text editor or IDE.
An application ID is required to use the Yahoo! Maps AJAX API. You can get an application ID here.
For best results, you should launch your web pages from a web server. However, it's possible to run applications
directly from your hard drive by double-clicking on them. This can be done by lowering the security settings in
the Internet Explorer browser or by setting the UniversalBrowserRead property in Firefox.
Displaying a Yahoo! Map
All the API classes and methods necessary to interact with Yahoo! Maps are available to your application when
you include Yahoo! Maps AJAX API library in your web page.This example uses the demonstration application
ID "YD-eQRpTl0_JX2E95l_xAFs5UwZUlNQhhn7lj1H"; you cannot use this Application ID and must request one
here.
<html>
<head>
<b><script type="text/javascript"
src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=YD-eQRpTl0_JX2E95l_xAFs5UwZUlNQhhn7lj1H">
</script </b
YDN Maps Suite AJAX Maps
Leonardo da Vinci: Hacker
Whaddyathink? & the Yahoo! ApplicationPlatform
Making the new Yahoo! Currency Converteraccessible
Retrieving and displaying data fromWikipedia with YQL
RECENT BLOG ARTICLES
January 24, 2009
January 22, 2009
January 21, 2009
January 18, 2009
READY TO GET STARTED?
Get an App ID
Search
MY PROJECTS APIs & WEB SERVICES RESOURCES SUPPORT
You aren't signed in Sign In Help
Flickr ServicesAPI Documentation Feeds Your API Keys Apply for a new API Key
flickr.places.getPlaceTypes
Fetches a list of available place types for Flickr.
Authentication
This method does not require authentication.
Arguments
api_key (Required)
Your API application key. See here for more details.
Example Response
<place_types> <place_type place_type_id="22">neighbourhood</place_type> <place_type place_type_id="7">locality</place_type> <place_type place_type_id="9">county</place_type> <place_type place_type_id="8">region</place_type> <place_type place_type_id="12">country</place_type> <place_type place_type_id="29">continent</place_type></place_types>
Error Codes
100: Invalid API Key
The API key passed was not valid or has expired.
105: Service currently unavailable
The requested service is temporarily unavailable.
111: Format "xxx" not found
The requested response format was not found.
112: Method "xxx" not found
The requested method was not found.
114: Invalid SOAP envelope
The SOAP envelope send in the request could not be parsed.
115: Invalid XML-RPC Method Call
The XML-RPC request document could not be parsed.
API Explorer
API Explorer : flickr.places.getPlaceTypes
Home The Tour Sign Up Explore Search
Yahoo! My Yahoo! Mail Welcome, guest Sign In
Yahoo! Weather RSS Feed
The Weather RSS feed enables you to get up-to-date weather information for your location. You can save this
feed in My Yahoo! or your favorite feed aggregator, or incorporate the RSS data into your own web site or client
application. The Weather RSS feed is a dynamically-generated feed based on zip code or Location ID.
This page describes the format of the request URL and the RSS response for developers. It contains these
sections:
RSS Request
Summary
Request Parameters
RSS Response
Top-Level Elements
Channel Elements
Image Elements
Item Elements
Condition Codes
Examples
Terms of Use
RSS Request
The Weather RSS feed request follows simple HTTP GET syntax: start with a base URL and then add
parameters and values after a question mark (?). Multiple parameters are separated by an ampersand (&).
The base URL for the Weather RSS feed is
http://weather.yahooapis.com/forecastrss
In this section, Summary shows how to make an RSS request with different parameters; Request Parameters
shows a table summarizing those parameters.
SUMMARY
The Weather RSS feed request follows simple HTTP GET syntax: start with a base URL and then add
parameters and values after a question mark (?). Multiple parameters are separated by an ampersand (&). For
the Weather RSS feed there are two parameters:
p for location.
u for degrees units (Fahrenheit or Celsius).
The location parameter p is required. Use this parameter to indicate the location for the weather forecast as a
zip code or Location ID.
http://weather.yahooapis.com/forecastrss?p=location
For example, to get weather for Yahoo! Headquarters in Sunnyvale, CA, use the zip code for Sunnyvale
(94089):
http://weather.yahooapis.com/forecastrss?p=94089
Or use the Location ID for Sunnyvale (USCA1116):
http://weather.yahooapis.com/forecastrss?p=USCA1116
YDN Weather RSS Feed
Search
MY PROJECTS APIs & WEB SERVICES RESOURCES SUPPORT
YQL
dev
http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…
http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2
var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…
dev
YQL
dev
YQL
dev
YQL
Bindings
dev
YQL
Bindings
dev
YQLYQL stmt
Bindings
dev
YQLselectYQL stmt
Bindings
dev
YQLselect
desc
YQL stmt
Bindings
dev
YQLselect
desc
show
YQL stmt
Bindings
Motivation Thousands of Web Services that provide valuable data
Requires developers to read documentation and form URLs/queries.
Data is isolated
Needs combining, tweaking, shaping even after it gets to the developer.
YQLSQL-Like Language
Synonymous with Data access
Familiar to developers
Expressive enough to get the right data.
Self Describing - show, desc table
Allows you to query, filter and join data across WebServices.
YQL Statement Basics
show: lists the supported tables
desc: describes the structure of a table
select: fetches data
use: use an Open Data Table *new*
Verbs
show tables
desc social.contacts
YQL Statement
SELECT what
FROM collection
WHERE filter condition
IN (sub-select)
LIMIT n OFFSET n
Syntax
YQL Statement Basics
FROM collection
Yahoo! WebServices
Social Dir, Upcoming, MyblogLog, Y!Local, Search(BOSS)
External DataSources
XML, Atom, RSS, JSON, CSV, HTML
Syntax -> Select -> Collection
YQL Statement Basics
Table data can be filtered in the WHERE clause either
Remotely by the table data source
Locally by the YQL engine (dot notation)
Syntax -> Select -> WHERE clause
YQL Statement Basics
WHERE <remote_key>=‘value’Tables require Keys in where clause
Specified in the describe
Correspond to query, path or matrix parameters for the Endpoint
Syntax -> WHERE clause -> Remote Filter
<query>
<key name=”guid” required=”true” .../>
</query>
YQL Statement Basics
WHERE <local_filter> OP ‘value’Filter an element or an attribute
Syntax -> WHERE clause -> Local Filter
<movies>
<movie>Star Wars</movie>
<movie>StarTrek</movie>
</movies>
<, >, =, LIKE, matches, not matches, not like
AND, OR binary operator combinations
Dot notation:
movies.movie LIKE ‘%Star%’
YQL Statement Basics
SELECT <what>
Uses the dot notation to project parts of matching item(s)
Syntax -> Select -> Projection
<results>
<movie>
<id>101</id>
<name>Star Wars</name>
</movie>
<movie>...</movie>
</results>
Projection: (relative to root)
select movie.id, movie.name from ...
YQL Statement Basics
IN (SELECT ...)Join across data sources
field IN (select guid from ...)
Like SELECT but can return only N leaves
Syntax -> Select -> Sub-Select
Get the profile for all my connections:
select * from social.profile where guid in (select guid from social.connections where owner_guid = me)
YQL Statement Basics
IN (SELECT ...)
(field, ...fieldN) IN (SELECT f1,...fn from table)
Syntax -> Select -> Sub-Select
Get the Location name of the given Photo:
select place.name from flickr.places where (lat, lon) in (select location.latitude, location.longitude from flickr.photos.info where photo_id='3030238604')
YQL Statement Basics
Changing the Table Size
Yahoo! Tables are limited to a small number by default (10)
Increase set size as parameters to Collection
Syntax -> Select -> Table Size
select * from local.search where zip=‘94089’ and query=‘pizza’
select * from local.search(100) where zip=‘94089’ and query=‘pizza’
YQL Statement Basics
Post Select processing using ‘pipe’ symbol.
Functions operate on return data.
Operations unrelated to table or data source.
Syntax -> Post Query Manipulation
select ... | sort(field=‘item.pubDate’)select ... | unique(field=‘item.title’)select ... | tail(count=10)
YQL Statement Basics
Like Prepared Statements for YQL
Substitutes Query parameter
Can be used in sub-selects
http://<>?q=....&city=Bangalore&state=Karnataka
select * from table where city=@city and state=@state
select * from table where city in (@city, @city2, @city3)
Syntax -> YQL Variables (@var)
YQL Statement Basics
Multi Valued variables
http://<>?q=....&city=Bangalore&city=Mumbai
select * from table where city in (@city)
Syntax -> YQL Variables (@var)
Sounds Good. But what about my WebService?
Can I add my data tables?
Open Data Tables
YQL
Open Data Tables
YQL
Open Data Tables
YQL
Open Data Tables
YQL
Open Data Tables
YQL
Bindings
Open Data Tables
YQL
Open Data Tables
YQL
Open Data Tables
YQL
Map YQL to Endpoint
Open Data Tables
YQL
Open Data Tables
YQL
Open Data Tables
Open Data Tables
Open Data Tables
Schema defines mapping between YQL and Endpoint
Keys can either be query, path or matrix parameters
Keys can be marked as required
YQL Compiler validates existence of required keys
USE Verb
Imports the Table defintion
Makes it available to following statements as tableName
desc tableName - describes the def
Acts like a First Class Data Source just like other YQL Tables.
use ‘http://url-to-def.xml’ as tableName;select * from tableName where key=‘value’...
data
One API : YQL
Accessing YQL
OAuth Endpoint
http://query.yahooapis.com/v1/yql?q=...
Public Endpoint
http://query.yahooapis.com/v1/public/yql?q=
YQL Console
http://developer.yahoo.com/yql/console
Accessing YQL
YQL Via Pipes