Google Url Shortener Api for .net

February 6, 2011

I read a short and concise post by David Walsh, demonstrating a simple php class for using the new Google Url shortener Api.

I played around with the code a bit in C#, and voila! A .net version (with some additions).

var googleShorter = new GoogleUrlApi("PUT_YOUR_LONG_KEY_HERE");  
var urlToPlayWith = "";  
var shortUrl = googleShorter.Shorten(urlToPlayWith);  
var longUrl = googleShorter.Expand(shortUrl);  
var longUrlDetails = googleShorter.ExpandFull(shortUrl);  
var analytics = googleShorter.GetAnalytics(shortUrl);  

Besides just creating short urls and expanding them, you can also get Analytics information about the shortened urls.

The analytics includes summaries of clicks, with drilldown details per month, week day etc.

Grab the source at :

It’s open sourced under the Apache 2.0 license, so knock yourself out!



comments powered by Disqus