Introducing the dynamIt URL-shortening API

While using the Tweetie 2 Twitter client on my iPhone a couple of weeks ago, I realized the app developer saw fit to include the option of using any URL shortening service I might desire if the shortening service provided an appropriate API.

API stands for Application Programming Interface. An API allows software to interact with other software. Twitter clients use the Twitter API to implement features of Twitter and access tweets, Twitter uses the Bit.ly API to shorten links using the Bit.ly service, and we have made creative use of various APIs on sites like Columbus College of Art and Design (which uses the Google Calendar API to power its deep set of event and news listings).

Since dynamIt already has a URL shortener built into our site, all we needed was a suitable API. I was able to use the existing scripting to generate and store the shortened URL, and only needed to adjust how the shortened URL was returned for suitable API use.

TinyURL has set a precedent for the simplest response possible—just the new shortened URL. Try calling the following action in your browser where [URL] is the URL you would like to shorten:

http://dynamit.us/url/api.dT?url=[URL]

The response will be the resulting shortened dynamit.us URL in plain text. You can optionally include the title of the page whose URL you are shortening as well:

http://dynamit.us/url/api.dT?title=[TITLE]&url=[URL]

While this simple plain text response can be interpreted by most applications, some developers may prefer a Bit.ly / JSON style response that looks something like this:

{ "shortUrl": "http://dynamit.us/222" }

If so, just add the URL variable “json=true” to the API call (with or without the optional [TITLE] variable):

http://dynamit.us/url/api.dT?json=true&url=[URL]

The Tweetie 2 application I use on my iPhone will accept either format. In Tweetie 2, go to Settings > Services > URL Shortening > Custom and enter:

http://dynamit.us/url/api.dT?url=%@

Or if you want to use the Bit.ly / JSON format just for fun:

http://dynamit.us/url/api.dT?json=true&url=%@

Tweetie URL Settings Tweetie URL API

Tweetie recognizes “%@” as where it should include the URL in the API call. Now whenever I am tweeting from my phone and want to include a URL, Tweetie will automatically use the dynamit.us URL shortener to shorten the link for me!

Test Tweet

Are there other places where you might like to use our URL shortener?