REST API
Introduction
The REST API gives developers and authors a way generating flx.im links remotely.
The REST API can be called from
http://flx.im/api?
Rate Limit
Without an API Key, the default rate limit is 5 inserts in a 10 second interval
API Keys can be arranged by prior arrangement
Parameters
url URL to be shortened
example: http://flx.im/api?url=google.com/ig
[key] Bulk user API Key Optional
example: http://flx.im/api?url=google.com/ig&key=flx:0A3FCCA0FF
[format] Return format Optional
- default: json also accepted: xml
example: http://flx.im/api?url=google.com/ig&format=xml
Outputs
Variables
error code: Error code returned by the API.
0 No error 1 Service Disabled 2 No URL Entered 3 Invalid URL 4 Error Finding Page (page doesn't exist) 5 Rate Limit Hit 6 Invalid API Key 10 Unknown Error (send request again)
error: A text description of the error.
url: The URL entered.
fqdn: Domain of the URL entered.
hash: The hash of the shortened link.
flx: The URL of the shortened link.
title: Title of the page at the URL entered.
JSON
({
"errorcode":0,
"error":"",
"url":"http://google.com/ig",
"fqdn":"google.com",
"hash":"kqedj",
"flx":"http://flx.im/kqedj",
"title":"iGoogle"
})
XML
<flx> <status> <errorcode>0</errorcode> <error></error> </status> <url>http://google.com/ig</url> <fqdn>google.com</fqdn> <hash>kqedl</hash> <flx>http://flx.im/kqedl</flx> <title>iGoogle</title> </flx>
Examples
Python
Function
import urllib2, re
def shrink(old, prefix="http://flx.im/api/?url="):
output = urllib2.urlopen(prefix+old).read()
return eval(re.sub("\s", "", output))
Usage
print shrink("http://www.google.com/ig")[flx]JavaScript / jQuery
Function
function shrink(old)
{
$.getJSON("http://flx.im/api/",{url:old},function(data)
{
if (data.errorcode!=0)
{
$('#output').html(data.error);
}
else
{
$('#output').html(data.flx);
}
});
}
Usage
Where, div with id "output" is used to output data and jQuery > 1.2
shrink("http://google.com/ig");
More info: http://docs.jquery.com/Ajax/jQuery.getJSON
Comments
Commenting has been disabled by the author