The API version 2
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
v2api.php Logo API

Version 2

The API is licensed under the Creative Commons

Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit

Hey guys, I hope to make this project feaable and I would love your help. If you find a bug, please please submit a bug report. It helps out a lot to let me know what's going on. If you have any suggestions or ideas to make it better, feel free to submit a pull request and I'll look into merging it into the master branch.

The API authentication is (for the moment) only for high traffic usage so that I can keep track and make adjustments to the system and network to make everyone happy.

What is it?

  • is a link shortener
  • The API is a tool to let programmers integrate functionality into their programs
  • It's free to use and will remain that way forever
  • Easy to use
  • Custom link expiry
  • Link resolving - make a short link long again
  • Link stat lookup - Returns the stats that are stored on that link, or as a whole for broader stats

How do I use it?

That's actually pretty easy! I've designed this API to handle a bunch of different inputs to help programmers.

  • Support for GET requests at the endpoint
  • Support for POST requests at the endpoint
  • Authenticated and non-authenticated requests of both types
  • SSL/TLS is an available option

The commands are simple to use and grasp (as shown below)

Primary commands (Required):

  • shorten - Used to shorten links
  • resolve - Used to lengthen short links
  • stats - Used to retrive various stored statistics gathered about links

Secondary commands:

  • url - The link in question (Required)
    • shorten - This will be your long url that you want to shorten
    • resolve - This will be one of (shortID,, long url)
      • shortID and are treated the same
      • long url will act like you're shortening a long url
  • stats - This will display statistics that are gathered during normal link usage, used with modifiers can show specific usage details, or just general click stats/number of users
  • expire - Used only with shorten. Sets expiration time to +secs from NOW();
  • mods - JSON array containing what you want to grab from the stats engine
  • key - Your API key (if you have one, used for high volume/traffic services)

Example usage:

PHP using file_get_contents(); - Unauthenticated GET

    $longUrl = "Your website's long url";
    // The API query
    $api = "$longUrl";
    // Array containing result of the shorten
    $result = json_decode(file_get_contents($api), true);
    // Result will be:
    Array('shorten':Array('id'=>"123", 'link'=>"longUrl", 
'datecreated'=>"Today's Date", 'expireat'=>"UNIX timestamp in future 
when link expires - 24h by default"))

PHP using cURL - Unauthenticated POST

    $longUrl = Your website's long url;
    $url = "";
    $fields = array('type'=>'shorten', 'url'=>$longUrl);
    foreach($fields as $key=>$value) { $fields_string .= 
$key.'='.$value.'&'; }
    rtrim($fields_string, '&');
    //open connection
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

    //execute post
    $result = json_decode(curl_exec($ch), true);
    //close connection
    // Result will be:
    Array('shorten':Array('id'=>"123", 'link'=>"longUrl", 
'datecreated'=>"Today's Date", 'expireat'=>"UNIX timestamp in future 
when link expires - 24h by default"))

JavaScript Unauthenticated GET

function sendAPIRequest(url, callback){ 
    var method = "GET";
	var req = new XMLHttpRequest();, "" + url, true);
	req.onload = function(){

function shortenURL(url){ // Creates a short url and copies it to 
		var url = encodeURIComponent(url);
		sendAPIRequest("?shorten&url=" + url, function(req){
			var res = req.responseText.trim();
            return res;

var longUrl = your long url;
var short = shortenURL(longUrl);

// var short will be a JSON string looking similar to:
{"shorten":{"id":"123","link":"http:\/\/your long 

// testURL() checks if the link markup is valid and returns true/false