Skip to content URL Shortener Bookmarklet via YQL

goo.gl_yqlLast month we saw a new Google URL shortening service that will be used for Feedburner and the Google Toolbar. It wasn’t long before the URL shortening code in the toolbar was dissected, and subsequent APIs developed. I managed to put together my own by using YQL.

YQL is a truly amazing web API.  With its server-side JavaScript and the ability to quickly scour the web for information, there is very little it cannot do.  I decided it was the perfect platform for putting together a simple API for

Because the Google Toolbar was already written in JavaScript, implementing it in YQL was quite easy with the server-side JavaScript. It wasn’t long, before I put together my own open data table for

I submitted my open table to the git repository for open data tables, and shortly after my open data table was included. It’s really pretty simple. The YQL you would use to get the short URL for my blog would be:


The great thing about YQL is that you can obtain the data as XML or JSON, and specify a JSON callback function. So that means it’s very easy to use in JavaScript and develop cross-domain JavaScript. I put together a simple bookmarklet that uses my public YQL table and provides a URL for the current page. To try it out, just drag and drop the link below to your browser’s shortcut bar:

[raw] page


Here’s the JavaScript code from the bookmarklet:

var YQL_url='';
var YQL_statement='SELECT * FROM WHERE url=\''+document.location.href+'\'';
var YQL_script_url=YQL_url+encodeURIComponent(YQL_statement)+'&callback=yql_cb';
function yql_cb(response){
	prompt('Here is your short URL (be sure to copy to your clipboard): ', short_url);
var yql_script=document.createElement('script');


Pretty simple. Basically it works by putting together the YQL statement w/ the URL of the current page, builds the proper YQL API URL for it, and finally inserts a JavaScript script with the call to the callback function that displays the URL of the current page in a prompt. You’ll have to manually copy it to your clipboard. Enjoy!

4 thoughts on “ URL Shortener Bookmarklet via YQL”

Leave a Reply

Your email address will not be published. Required fields are marked *