API

For ftw.gd, we have implemented a very simple API. The basis for development of this API was inspired by the Twitter for iPhone App, which enables you to configure a custom URL shortening API within the settings.

Shortening

Input

Send a HTTP request to http://ftw.gd/api/shorten, setting the HTTP GET variable 'URL' equal to the long URL to shorten. For example:

http://ftw.gd/api/shorten?url=mylongurl.com

Process

The URL provided will be subject to all of the same checks as it would should it be provided on the http://ftw.gd/ homepage. A connection to the site will be attempted, and a HTTP response code between 200 and 302 will be required to shorten. So if a site 404s, don't expect a short URL to be returned! The URL will also be ran against the current database to involve duplicate short URLs and redirection loops back to http://ftw.gd/. If the URL has already be shortened, the shortening will still return a successful response with a short URL, but it will be the existing short URL.

Output

At present, the default response format is in JSON, and hence in key/value pairs. The JSON object contains a status flag which is either success or error; a shortUrl variable - the bread and butter of the request - which represents the returned short URL from the system; and longUrl which represents the original requested URL to be shortened, for usage in your systems.

A successful API request will return a JSON request similar to the following.

{ "status":"success", "shortUrl":"http://ftw.gd/1t", "longUrl":"http://bbc.co.uk" }

Conversely, a failed API request will return a JSON request similar to the following.

{ "status":"error", "shortUrl":null, "longUrl":"http://invalidwebsite.com" }

Lengthening

In addition to shortening URLs, we also provide an API for developers to expand or 'lengthen' previously shortened URLs using http://ftw.gd/.

Input

To use lengthening, send a HTTP request to http://ftw.gd/api/lengthen and pass in the GET variable URL equal to the short http://ftw.gd/ you wish to expand. For example:

http://ftw.gd/api/lengthen?url=http://ftw.gd/1t

Note: you are free to either pass in the full URL (as above), or simply the short reference e.g. 1t. Our API will detect which you pass.

Output

Again, output is in the form of a JSON object. A successful request will return the following self-explanatory fields, which are the shortUrl, the expanded longUrl, a result status flag and an added time stamp representing the creation.

{ "shortUrl":"http://ftw.gd/1t","longUrl":"http://bbc.co.uk","added":"2010-08-28 18:58:40","status":"success" }

Conversely, a failed request will return:

{ "shortUrl":"http://ftw.gd/invalid","longUrl":null,"added":null,"status":"error" }

Limit

There is currently no limit to using the API however traffic volumes are monitored heavily. Any signs of abuse will result in implementation of a API key/token system which will require developer registration.

tl;dr - free/open access but abuse the system and you will have to register.