Skip to content

Web API power tools: One tool to bind them all

February 14, 2011

In my last post we examined a three step process for learning about a new web API, prototyping its use in a console, and then copying the calls you developed into your own script or program.

That approach works well, but there is one major problem:  It requires you to learn a new API for each RESTful service you want to try out.

Wouldn’t it be nice if there was one mechanism you could learn that allowed you to make calls into just about any web API, or even plain old web pages?  In fact there is, and that’s the subject of this post:  the Yahoo! Query Language (YQL).

I first wrote about YQL for the PayPal X Developer Network in a two part DevZone article series on harvesting and analyzing RSS feed data (click here to read the first part on harvesting the data; the second part will be publishing soon).  You can read more about YQL in detail in those articles, so for this post I just want to cover the high level capability to show you its usefulness in your web API-based development.

So what is YQL?  YQL looks like SQL but enables you to access live data from the Internet.  That definition doesn’t really do it justice, however.

The bigger point about YQL is that it includes many built-in bindings to various web APIs so that you can use almost every major web API in a consistent manner, with similar calls across the many possible APIs available to you.  Yahooligans summarize this capability as:

select * from Internet

Here’s why.  In the first article in my harvest+analysis series I showed how you could use YQL to load DevZone “Blog” RSS feed data:

select * from rss where url in ('')

In the second part of the series you see how you can use that same YQL in an application.  The article shows a Python example using the Python YQL client library, but you can use it in other languages too with the appropriate library.  Barring direct support in a particular language of interest, however, you can always make the equivalent REST call provided for any given YQL statement you put together in the YQL console.

For instance, if you enter the above YQL into the console and test it with diagnostic information turned off and the server response set to ‘XML’ (JSON is the other option), the console gives you this output:

Copying the REST call for a new YQL query out of the console

In this case, the REST query copied out of the highlighted portion of the console is:*%20from%20rss%20where%20url%20in%20('')

Click the REST query above to see the server response live in your browser.  You can use this REST call in your application code, no matter the programming language or environment.  Nifty, huh?

But what if you want to use that same DevZone data, or data from a different RSS feed or server, in an application where you also need access to other web APIs?  No problem, YQL supports many other web API queries too.  It does this via Open Data Tables created with just a little bit of XML.  Click here to learn more about the data tables.

For example, suppose you want to search Twitter for tweets containing “PayPal”.

Read the complete post on the PayPal X Developer Network to learn how to use the Twitter search API in YQL.


From → Uncategorized

  1. Pete Mancini permalink

    On my personal heat map of development, YQL has become Red Hot and has changed the entire direction of my WordPress Plugin development. The fun is back because the power here is intense. Also, creating your own data sources for YQL is a snap. Suddenly, if you have interesting data you can let others leverage it.

  2. YQL is a lot of fun, isn’t it? I have more plans to use it in future hackery and work. I sure hope this service survives whatever troubles may be yet to come at Yahoo.

Comments are closed.

%d bloggers like this: