Eat your greens!

Actually, I am a rocket scientist
Home » geekage » Opening up data with YQL

Opening up data with YQL

Posted in geekage, yql

Recently I’ve been following Chris Heilmann’s enthusiastic posts about Yahoo! Query Language (YQL). Chris has also written a good introduction to YQL for developers. It’s a SQL-like language for getting data out of open web services. Sort of a single syntax for interacting with a variety of services, such as the APIs for flickr, upcoming or twitter, without needing to know a lot of the detail of those individual services. One of its features is open data tables, which allows you to describe your own web services using a simple XML syntax, not unlike OpenSearch.

Last year we made the National Maritime Museum collections available as OpenSearch RSS feeds. More recently we’ve developed a new manuscripts search which also publishes search results as RSS. After reading Chris’ blog I had a go at writing some YQL table descriptions for those feeds. They’re very simple to write and you can find my examples at

Here are a couple of example queries using those tables. For example, search the NMM art collections for the phrase “tower bridge”:

use 'http://eatyourgreens.org.uk/yql/nmm-search.xml' as nmm.collections.search;
select * from nmm.collections.search where category = 'art' and searchterm = '"tower bridge"'

Or perhaps search the archive catalogue for the phrase “aircraft carrier”:

use 'http://eatyourgreens.org.uk/yql/nmm-archive-search.xml' as nmm.archive.search;
select * from nmm.archive.search where searchterm = '"aircraft carrier"'

The results from YQL queries can be returned as XML or JSON. For an example of using these feeds, have a look at Chris’ Javascript for dynamically retrieving photos from flickr with YQL. I haven’t got any examples using the NMM data at the moment but it’s an interesting way to look at the whole idea of web-based APIs. I particularly like the idea of wrapping these services in a single syntax to simplify writing code to work with them.

Update: Here’s an example using the NMM collection, which I put together for Chris Heilmann’s talk at the museum.