Scott's Weblog The weblog of an IT pro specializing in virtualization, networking, open source, and cloud computing

Shortening URLs via from the CLI

I was experimenting tonight with some ways to add more automation to my workflow. One process that is (relatively) time-consuming is the process of generating short URLs via This site had a brief tutorial on how to use curl to do it, but the shortened link didn’t show up in my link history. Upon browsing the API documentation, though, I was able to fairly quickly piece together a command line that will shorten a URL via and put the shortened URL in the user’s link history.

Note that in order to use this command, you’ll need your API key. Your API key is easily accessed from your account settings page.

Here’s the command I tested (works on Mac OS X 10.6.4):

curl '< login>&apiKey=< API key>&longURL=<Long URL to be shortened>&format=txt'

Note you’ll need to supply appropriate values for < login>, < API key>, and <Long URL to be shortened>.

In order to make this truly usable, there are some additional things that have to happen. The long URL has to be properly encoded, as it can’t have any spaces or special characters, for example. But otherwise, this command is a workable solution to shortening a URL from the command line. All I need now is a small AppleScript around this and then I’ll have a URL shortening script I can bind to a hotkey. That should help speed the process up!

Be social and share this post!