YQL talk at OHD Jakarta

Uploaded on

Shreeni from Y! Sing does a deep dive on YQL

Shreeni from Y! Sing does a deep dive on YQL

More in: Technology , Design
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Standardizing web querying - Using YQL for accessing and exposing APIs
  • 2. Agenda
    Introduction to YQL
    How to get started
    What’s supported through YQL
    Theme of the day – mim.yahoo.com
    Lots of examples using mim API
    Mashup using YQL
    Introduction to more YQL goodies
    Server side javascript execution
    YQL hosted storage
    Concluding remarks
    ..lets keep it interactive
  • 3. YQL – Yahoo Query Language
    Enables you to access Internet data with SQL-like commands
    YQL hides the complexity of Web service APIs by presenting data as simple tables, rows, and columns.
    YQL includes pre-defined tables for popular Yahoo! Web services such as Flickr, Search, Geo andMim.
    YQL can access services on the Internet that output data in the following formats: HTML, XML, JSON, RSS, Atom, and microformat.
    Create fast mashups reducing latency, code
  • 4. How to get started
    Explore the APIs - http://developer.yahoo.com/everything.html
    Get a developer key - https://developer.apps.yahoo.com/wsregapp/
    Read the documentation - http://developer.yahoo.com/yql/guide/
    Visit the YQL Console - http://developer.yahoo.com/yql/console/
    The YQL Console enables you to run YQL statements interactively from your browser.
    Hack away..
  • 5. Y! APIs supported by YQL
    Show tables
    Y! geo
    Y! local search
    Y! maps
    Y! mim
    Y! music
    Y! MyBlogLog
    Y! search
    Y! social
    Y! upcoming
  • 6. External APIs supported by YQL
    Through datatables.org
    Show tables
    Amazon ECS
    Google (News, Search, Translate)
    Microsoft (Bing)
  • 7. Theme of the day – mim.yahoo.com
    Mim has an YQL based API for everything – reading, searching, updating, deleting and so on.
    Profile information ofmimusers
    Followers/following information
    Query for users
    Listing mim posts of a user
    Popular posts
    Search for posts
    Inserting (posting to mim) through YQL
    • Reposting, commenting deleting
  • Getting information about self (logged in)
    select * from meme.info where owner_guid=me
    <query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1” yahoo:lang="en-US” yahoo:uri="http://query.yahooapis.com/v1/yql?q=select+*+from+meme.info+where+owner_guid%3Dme">
  • 8. In JSON
    select * from meme.info where owner_guid=me
    {"query": {
    "count": "1", "created": "2009-11-19T10:33:11Z",
    "lang": "en-US", "updated": "2009-11-19T10:33:11Z",
    "uri": "http://query.yahooapis.com/v1/yql?q=select+*+from+meme.info+where+owner_guid%3Dme",
    "results": {
    "meme": {
    "name": "shreeni", "title": "Shreeni'sMim",
    "description": null,
    "url": "http://mim.yahoo.com/shreeni/",
    "avatar_url": "http://d.yimg.com/gg/shreeni/avatars/7a0d55f7d0aab9e326a7906a110f8027d46bd49b.jpeg",
    "language": "en", "followers": "18"
  • 9. How to run YQL queries
    • Convert to URL: http://query.yahooapis.com/v1/public/yql?q=&format=
    • 10. Use the YQL Console - http://developer.yahoo.com/yql/console/
    • 11. Use a PHP SDK provided by Y! - http://developer.yahoo.com/social/sdk/#php
  • Selecting specific fields
    select title, url, avatar_url, language from meme.info where name='shreeni'
  • 12. Selecting specific fields (also Followers API)
    select name from meme.followers where owner_guid = “NKADUBBZPUQQG6GF6AHTDTABSQ”
  • 13. Sub-select and Limits
    select name from meme.followers where owner_guid in (select guid from meme.info where name='shreeni’) limit 2
  • 14. Functions
    select name from meme.followers where owner_guid in (select guid from meme.info where name='shreeni') | sort(field="name", descending="true”)
  • 15. Functions
  • 16. Following API inmim
    select name from meme.following where owner_guid in (select guid from meme.info where name='bangwinissimo')
  • 17. Searching for people
    select guid, name, title, language from meme.people where query="Fajar”
    select guid, name, title, language from meme.people where query="Fajar" and language=”id"
  • 18. Finding specific Posts of amimuser
    select * from meme.posts where owner_guid in (select guid from meme.info where name='bangwinissimo')
    select * from meme.posts where owner_guid in (select guid from meme.info where name='bangwinissimo') and type='text'
  • 19. Popular Posts
    select * from meme.popular
    select * from meme.popular where locale="id"
  • 20. Search inmim
    SELECT * FROM meme.search WHERE query="jakarta”
  • 21. Inserting/Deletingmimposts
    INSERT INTO meme.user.posts (type, content) VALUES ("text", "This is a text post from YQL!”)
    DELETE FROM meme.user.posts where pubid = "Nswwwmv"
  • 22. Reposting, Commenting
    INSERT INTO meme.user.posts (guid, pubid, comment) VALUES ("S5R44PGJRBLKNEE5GYSRQPTXLQ", "rGCOBCK", "this is the repost comment”)
    INSERT INTO meme.user.comments (guid, pubid, comment) VALUES ("S5R44PGJRBLKNEE5GYSRQPTXLQ", "rGCOBCK", "meme rocks")
  • 23. YQL Cheat Sheet
  • 24. Exposing own API through YQL
    <?xml version="1.0" encoding="UTF-8"?>
    <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
    <sampleQuery>select * from {table} where query=’q'</sampleQuery>
    <select itemPath="results" produces="JSON" >
    <url env="all">http://query-url</url>
    <key id=”q" type="xs:string" paramType="query" required="true" />
  • 25. Now access it through YQL
    USE "http://definition-file.xml" AS mytable;
    SELECT * FROM mytable WHERE query="whatever”
  • 26. Mashup - introduction
    • Finding the Sunrise/Sunset time for Jakarta
    • 27. Earthtoolsapi for sunrise-sunset information
    • 28. XML based api
    • 29. Needs latitude-longitude of the location
    • 30. Yahoo Geo API to convert location to latitute-longitude
    • 31. Would need 2 different API calls and effort from your side
    • 32. Assuming Yahoo API was in JSON would have to deal with 2 formats
  • Solution – Exposing 3rd party API in YQL
    <?xml version="1.0" encoding="UTF-8"?>
    <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
    <sampleQuery>select * from {table} where lat='lat' and lon='lon' and day='day' and month='month' </sampleQuery>
    <select itemPath="sun" produces="XML" >
    <key id="lat" type="xs:string" paramType="path" required="true" /><!– 3 others -->
    </inputs> </select></bindings> </table>
  • 33. Querying for the data
    # Get the Lat Long information for Jakarta
    select * from geo.places where text="Jakarta" limit 1;
    # Now get the sunrise/sunset from earthtools using a
    # YQL query
    USE "http://rahukalamcalculator.appspot.com/yql/earthtools-definition.xml" AS earthtools;
    SELECT morning, evening FROM earthtoolsWHERE lat="1.365580" and lon="103.827713" and day="21" and month="11”
  • 34. Combine the queries
    # One awesome call!
    select * from mytable where (lat,lon) in (select centroid.latitude, centroid.longitude from geo.places where text="jakarta") and day="21" and month="11”
  • 35. Mashup – solution highlights
    • Exposed a third party API through YQL
    • 36. Expressed business logic in Query – readable, maintainable
    • 37. Used server side for the actual join
    • 38. Less latency
    • 39. Use the format you like
  • More goodies – YQL server side execution
    • Executing JavaScript allows you to use conditional logic and to format data in a granular manner.
    • 40. Better data shaping and parsing
    • 41. Better support for calling external Web service
    • 42. Better support for adding, modifying, and deleting data using external Web services
    • 43. Lots of examples and detailed documentation at http://developer.yahoo.com/yql/guide/yql-execute-examples.html
  • Server Side execution - example
    <select itemPath="" produces="XML">

    // Your javascript goes here. We will run it on our servers
    response.object = <item>
  • 44. More goodies – YQL Hosted Storage
    • Size Limit: You can have up to 1000 records, with each record being up to 100KB.
    • 45. Retention Limit: Records not read, updated, or executed at least once every thirty days may be removed.
    • 46. Record Format: Records must be in a text-based format. Examples include JavaScript code, XML files, Open Data Tables, or YQL environment files.
    • 47. Authentication for New Records: All connections to yql.storage.admin must be authorized using two-legged OAuth. Alternatively, you can create new records using the YQL console. However, connections to yql.storage do not require authentication.
  • Storing into YQL
    # Just the value
    insert into yql.storage.admin (value) values ("example text content")
    # Contents of a URL
    insert into yql.storage.admin (name,url) values ("newrecord","http://hostingdomain.com/mytable.xml")
    # response looks like
  • 48. Querying from hosted storage
    # Uses select-id
    select * from yql.storage where name="store://08fd2c74”
    # Uses update-id
    delete from yql.storage where name="store://3cc85a99”
    update yql.storage set value="new value" where name="store://3cc85a99”
    # Use contents as env file (uses execute-id)
    use "store://35ad2c72" as mytable;
    select * from mytable;
    # Use contents as JS for server side execute (uses execute-id)
    response.object = <success>{success}</success>;
  • 49. Concluding remarks
    • YQL is an extensible gateway to use APIs across and beyond Yahoo!
    • 50. Allows standardization of APIs across the web
    • 51. Familiar and concise language for expressing business and data logic
    • 52. Powerful tool to build mashups
    • 53. You can build upon existing APIs and expose third party APIs
    • 54. Sound server side support, including javascript execution and storage to enable easy development
  • Questions?
  • 55. Thank You!
    • http://developer.yahoo.com/yql
    • 56. shreeni@yahoo-inc.com
    • 57. http://tech.shreeni.info