YQL and GEO

    Prajwal BS
    Developer,
 Hacker, Evangelist
Agenda

•  YQL Overview

•  Making Queries and the Console
   Sandbox

•  Demo

•  Geo Hacking

•  YQL and GEO
Hacking together
systems in 24 hours is
      lot of fun
Data manipulation
Hacks =           +
          Data visualization
The web has lot of data around
ProgrammableWeb.Com – 3517 APIs
Yahoo! has also
opened up its data
http://developer.yahoo.com/everything.html
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
To make data access
  easy on the web,
Yahoo! created YQL
YQL turns web
services and data on
    the web into
     databases.
YQL lets you access
almost all API’s in a
   standardized
      manner.
API List on console
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 IIT-M




SELECT * FROM youtube.search where
 query=’IIT Madras'
Selecting Photos of Hackday



SELECT * FROM flickr.photos.search where
 text="hackday”

SELECT * FROM flickr.photos.search where
 text="hackday” LIMIT 5
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
https://github.com/yahoo
Retrieving my profile




SELECT * FROM social.contacts WHERE
              guid=me
Mix and Match several
web services using IN
      command
Guess what this does?




select * from google.translate where q in
  (select text from twitter.search where
         q='hacku') and target='hi';
You want more??
How about these formats




Atom                     Json
Csv                      Microformats
Feed                     Rss
Html                     xml
Company Headlines anyone??



    select * from html where
url="http://finance.yahoo.com/q?
     s=YHOO" and xpath=‘//
div[@id="yfi_headlines"]/div[2]/ul/
                li/a’
Company Headlines anyone??
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/
  [params]

    Params
    •  q =             [ YQL QUERY ]
    •  format =        [ XML / JSON ]
    •  diagnostics =   [ true / false ]
    •  debug =         [ true / false ]
    •  callback =      [ function name ]
Let’s See It
GEO HACKING


•  GOOD NEWS! - Not hard to do.

•  YQL as always has a solution to
  most geo problems.
REQUIREMENTS

•  Finding current location.

•  Turning a location into a place.

•  Finding geographical hierarchy.

•  Geo-tagging information.

•  Displaying geo information.
Current Location 


           IP Sniffing

      W3C geolocation API

User Social presence (foursquare,
        twitter, flickr etc.)
REQUIREMENTS

•  Finding current location.

•  Turning a location into a place.

•  Finding geographical hierarchy.

•  Geo-tagging information.

•  Displaying geo information.
GEOCODING AND REVERSE-GEOCODING




 •  converting street addresses or place
     names into geographic coordinates
              (and vice versa).


 h"p://developer.yahoo.com/yql/console/#h=desc%20geo.placefinder

YQL to the rescue
select * from geo.placefinder where text="IIT
                 Madras India"




    select * from geo.placefinder where
 text="13.063970,80.243110" and gflags="R"
REQUIREMENTS

•  Finding current location.

•  Turning a location into a place.

•  Finding geographical hierarchy.

•  Geo-tagging information.

•  Displaying geo information.
YQL GEO.PLACES.*

•  geo.places.ancestors
•  geo.places.belongtos
•  geo.places.children
•  geo.places.common
•  geo.places.descendants
•  geo.places.neighbors
•  geo.places.parent
•  geo.places.siblings
REQUIREMENTS

•  Finding current location.

•  Turning a location into a place.

•  Finding geographical hierarchy.

•  Geo-tagging information.

•  Displaying geo information.
PLACEMAKER


•  Takes text/web URL and
   extracts the geographical
   information from it.

•  SELECT * FROM
   geo.placemaker WHERE
   documentContent = "Hey,
   I am in bangalore now.
   Will visit mumbai and
   delhi before going back to
   sunnyvale" AND
   documentType="text/
   plain"
EXAMPLES


•  SELECT * FROM geo.placemaker WHERE
   documentURL = "http://en.wikipedia.org/wiki/
   Country" AND documentType="text/html”

•  SELECT * FROM geo.placemaker WHERE
   documentURL = "http://
   timesofindia.feedsportal.com/c/33039/f/
   533917/index.rss" AND documentType="text/
   rss"

     h"p://developer.yahoo.com/geo/placemaker/

REQUIREMENTS

•  Finding current location.

•  Turning a location into a place.

•  Finding geographical hierarchy.

•  Geo-tagging information.

•  Displaying geo information.
Use Maps to visualize geo data.
Use YQL in your hacks
  using Javascript.
USEFUL LINKS


•  http://isithackday.com/hacks/geo/

•  http://isithackday.com/geoplanet-explorer/
• 
•  http://isithackday.com/hacks/geo/yql-geo-library/

•  http://www.hostip.info/
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
LETS LOCATE YOUR HACK!

                               THANKS!!
  If you throw a guy on Foursquare and a guy on Twitter off a cliff, which one
                            would hit the ground first?
  The guy on Twitter. The guy on Foursquare would have to stop halfway down
                                   to check in!



PRAJWAL BS
Twitter - @prajwalbs
Slideshare - http://www.slideshare.net/prajwalbs
Facebook - http://www.facebook.com/prajwalbs

Yql with geo