YQL + YUI: Building End-to-End Applications

Filed under tutorial

The third team talk was presented by Paul Donnelly and Nagesh Susarla. They go over how to start your query out in the YQL console, access YQL data via the various endpoints, and go through YQL’s various authentication layers.

Code examples here. And slides here.

Here is the link to the original yuiblog post and below an embedded video.

Building YQL Open Data Tables with YQL Execute

Filed under tutorial

The second YQL talk at YUIConf was presented by Nagesh Susarla. Nagesh goes over how to use YQL execute in the open data tables. Here is the link to the original yuiblog post and below an embedded video.

YQL: An Introduction

Filed under tutorial

The YQL team was honored to be asked to participate at YUIConf 2010. Several team members had the chance to present various topics on YQL.

The first talk was presented by Mirek Grymuza and Josh Gordineer. Here is the link to the original yuiblog post and below an embedded video.

We’ll post the remaining YQL videos from YUIConf throughout the week.

Changelog for build 9593

Filed under changelog

New Feature Highlights

New core tables

  • Social update activity streams: social.updates.activitystreams, avatars.get, social.relationships

Other features

  • y.rest(url).path(value) should check URL for trailing slash
  • Support array based arguments for post-yql query functions

Changes

  • no notable changes

Bug fixes, including

  • Unescaped HTML entities produce invalid JSON in JSON-p
  • In execute function does not preserve JSON true/false values but turns them into strings
  • Date in yahoo:created is off by 12 hours
  • y.include() should not use base URL when including store:// URLs
  • Post function with invalid url returns duplicate warning message
  • Sort funciton doesn’t support ascending as an argument
  • XML to JSON does not work for sub-elements

Changelog for build 8743

Filed under changelog

New Feature Highlights

  • Store recent queries using HTML5 container
  • Console y.ahoo.it url shortener integrated into the console when permalinking queries – now it’s easier to grab and share long console query

New core tables

  • Yahoo Mail API
  • Social Relationship API

Other features

  • y.cache.incr() should return the new value
  • geo.placetypes adds language support

Changes

  • Preserve newlines in console output

Bug fixes, including

  • Aliased input keys are not available as variables in <execute>
  • In console set publiclyCallable to false if a user is not logged in and runs a query with an auth required table

Changelog for build 8367

Filed under changelog
New Feature Highlights:
  • Allow an <execute> outside the execute blocks to add libraries, functions
  • y.rest().ping() add a way to beacon data to statistics gathering services

New core tables

  • Fantasy Sports API

Other features

  • Improve ability to throw exceptions from execute tables
  • Update tidy library to support HTML5
  • Add y.tidy(String html) to tidy the html and return a document

<execute> changes

  • Core HTTP changes to enable better connection management and reuse

Bug fixes, including:

  • Fix Diagnostics service-time included y.query time
  • Fix Can’t “desc yql.env”
  • Fix Json array returned by a rest call results in an exception
  • Fix Debug output does not handle special characters
  • Fix paging with mode=’offset’ is ignoring the start default attribute

Changelog for build 6122

Filed under changelog
New Feature Highlights:

  • new <meta> element in YQL response envelope returns information “about” the result list
  • social.updates.search table – access the social updates firehose
  • changes to environment feature and capabilities
    • new “env” statement. You can now load envs using the “env” statement as part of the regular YQL syntax.
    • “env”s may now be nested – you can include one env from another
    • “sets” on one environment do NOT apply to any other, unless the environment is nested

New core tables

  • social.updates.search
  • yql.table.desc, yql.table.list and yql.tables tables (reflect on the available YQL tables)

Other features

  • show tables now reports the security required to use the table
  • desc <table> now works for all tables irrespective of security or connection restrictions (https) on tables

<execute> changes

  • added response.meta to enable <meta> element to be set on the response object
  • added forceCharset(String charset) to request/y.rest(..) as a way of overriding the return contentType charset.

Bug fixes, including:

  • fixed debug=true always reported the method as GET in network dump
  • including a store:// url in execute y.include intermittently caused no results to be returned – fix
  • yahoo:uri is no longer in the response envelope
  • yahoo.identity fixed

Changelog for build 5275

Filed under changelog
New Core tables

  • yql.env, automatically apply environments per app or per user per app

Bug fixes, including:

  • “content” can be used to filter in WHERE clause
  • fixed charset parameter handling in HTML table (was broken in previous build)
  • another custom redirect fix (for SPARQL table)
  • update now supports “in” as where clause

Avoiding rate limits and getting banned in YQL and Pipes: Caching is your friend

Filed under tutorial

Web caches are great pieces of software: they lower the load on servers; and serve content faster to clients. YQL and Pipes love caches for this very reason, and we reward clients making good use of our reverse proxy caches by not subjecting those who get cached content to rate limits. That’s right – if we can give you your content from cache you can call it as often as you like, no need to cache locally just to save on calls.

Unfortunately we’ve seen a lot of requests to us that could easily take advantage of our caches but don’t. Here’s a list of some DOs and DONTs for calling YQL and Pipes, and let’s use the example of fetching the weather for a zipcode:

http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where location=90210

DON’T cachebust
“Cachebusting” means changing your request just a little so that the cache can’t give you a copy of the response it’s seen before, often using a random value or timestamp on the end of the query parameters, for example:

http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where location=90210&rnd=_12312

Beware of client-side JS libraries “helping” you
Often developers aren’t even aware they are doing this, but various web client libraries, particular client-side Javascript ones, seem to think cachebusting by default is a sensible thing to do. Its not. It just makes our servers work harder, the downstream sources of data work harder, and the response come back slower to the client. It also stops your own browser cache from helping your app behave faster.

For example, jQuery provides an automatic JSONP callback library that creates a randomly named global function name for each callback. This causes it to cachebust on every call as the function name changes all the time. By taking the time to add a few extra lines of code you can benefit from our caches:

$.ajax({
   url: 'http://query.yahooapis.com/v1/public/yql?q=show%20tables&format=json',
   dataType: 'jsonp',
   jsonp: 'callback',
   jsonpCallback: 'cbfunc'
});
function cbfunc(data){
   $.each(data.query.results.table, function(i,item){
   $('#tables').append('<p>'+item+'</p>');
});
}

By defining your own global function in your script you can be sure that it won’t change from request to request, and you can leverage our caches.

If you must cachebust, use a “window” of time
Sometimes the content gets cached for longer than you want, and sometimes your clients are IE6 web browsers which don’t respect cache headers correctly [shudder]. The best solution to this is to append a parameter that changes gradually at the same rate as the content you are requesting. For example, back to our example of fetching the weather forecast for a zipcode. The forecast will probably change throughout the day, but not every single second, so you’re probably ok fetching that every hour and therefore can create a cachebusting header that uses a timestamp that only changes once per hour, for example:

http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where location=90210&rnd=_2010031310

This uses a YYYYMMDDHH (year/month/day/hour) format for each request to fetch the weather. All requests arriving over the course of an hour will get a cache hit and you’ll use 1 unit of rate limit (per zipcode).

DO put content into cache
On the flip side of caching busting, sometimes content isn’t cached as long as it should be, or you want it do be. Perhaps the content provider set it wrongly or your usage of the content doesn’t need it updating so frequently. You can take control of this in YQL in a couple of ways.

First, you can choose to explicitly set the cache “maxage” header in an open data table to whatever you want. Lets say you want the table data to be cached for 5 minutes, then in the <execute> statement you’d say response.maxAge=300; (its specified in seconds).

Secondly you can just ask YQL to cache the response to a statement for longer – just append the _maxage query parameter to your call and the result will be stored in cache for that length of time (but not shorter than it would have been originally):

http://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where location=90210&_maxage=3600

This is really useful when you’re using output from a table that’s not caching enough or an XML source without having to do any open table work.

By making a few small changes to the way your client calls YQL and Pipes you can gain almost infinite rate limit in many cases and provide better performance to your users.

Jonathan Trevor

Changelog for build 4264

Filed under changelog
New feature highlights:

  • Customizable caching. Execute can now set maxage header in response (response.maxAge=300), and clients can also request a greater maxage header for increased performance (&_maxage=300).
  • Query aliases. Name your YQL queries using meaningful short names.

Core Table changes

  • New global execute element outside of bindings is prepended to all executes (to enable common js to be run over all bindings)

New Core tables

Execute changes

  • max-age header is now auto-calculated based upon queries and rest calls made in execute

Bug fixes, including:

  • Redirect handling improved
  • Upgraded memcache library
  • Batchable attribute now works correctly with paramType=”query” and “matrix”