twtr.io is an algorithmic URL shortener for Twitter URLs.
Given a full URL to a tweet such as https://twitter.com/aaronpk/status/364781641031360514, this can be shortened to http://twtr.io/bBowYg3hMu. When the short URL is requested, it is algorithmically expanded to a twitter.com URL. Since the shortening is done algorithmically, no database is needed, and the requirements for running this code are very small.
Try it Now!
To un-shorten a link, the NewBase60 number is converted back to its base 10 equivalent. The base 10 ID is appended to "https://twitter.com/_/status/". This takes advantage of a feature of twitter.com where they will redirect a tweet URL to the correct username.
Q: Why do I need this?
A: You probably don't
Q: Where is this used?
A: You can see an example of where this is useful on the IRC logs for the #indiewebcamp IRC channel.
Copyright 2013 by Aaron Parecki
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.