Quick URL Shortening

API Documentation

General informations

Twi.mn allows you to use a single API to do basically everything you can do on the site : shorten URL, and write then post long tweets. We provide 2 formats for the API : JSON and XML. You can call the one you want with these adresses : You must POST every arguments for both URL-shortening and long-tweet posting.

URL-shortening API

Shorten URL

Use : http://twi.mn/api.json / http://twi.mn/api.xml
The API automatically detects if you're sending a Twi.mn URL and if not, send you the shorten URL back.

Params :

  • url (string) : the URL you want to shorten - required -

Returns :

Download a simple PHP example

Expand URL

Use : http://twi.mn/api.json / http://twi.mn/api.xml
The API automatically detects if you're sending a Twi.mn URL and if yes, send you the long URL back.

Params :

  • url (string) : the URL you want to expand - required -

Returns :

Download a simple PHP example

Long-Post API

Use : http://twi.mn/api.json / http://twi.mn/api.xml

Params :

  • twimn (string) : the long message with HTML tags - required -
  • twitter_account (string) : the username of the author (or application name if do_post is FALSE) - required -
  • twitter_password (string) : the twitter password of the author - required if do_post is TRUE -
  • do_post (boolean) : TRUE if you want to post directly the tweet. If not, you get the tweet formated and can post from your own application. - optional -
  • in_reply_to_status_id (int) : if the tweet is a reply - optional -

Returns :

  • error (int) : 0 if no error or error code (see below)
  • url (string) : the Twi.mn URL (i.e. http://twi.mn/a )
  • tweet (string) : the tweet ready to post (or posted if posted is TRUE)
  • posted (boolean) : tweet posted or not (because of an error, and depending on doPost)

Note :

When not posting, the username can be either the application name or the user name. Sending a false name is prohibited and as a consequence your application can be blacklisted.

Download a simple PHP example

Errors list

Error are returned if something went wrong. Only 1 error is returned.
You get a number, see below for corresponding state, and a detailled message in the 'message' parameter.

  • 1000 : the method you're trying to use does not exist.
  • 1001 : the URL you're trying to expand does not exist in our database.
  • 1002 : the URL you sent is not a short URL, but another media type (i.e. picture, or long-tweet)
  • 1003 : we can not record your URL because it is not a valid URL, or because the server is blacklisted or another URL-shortening service
  • 1004 : one required argument at less is missing