If you want to use our API, you may do so by simply following these instructions. To prevent abuse, we require our developers to register an account and make calls using their assigned key. If you have not yet registered, simply click here. In the other hand if you already have an account, simply login and retrieve your developer key.

 

Request to Shorten a long URL
 

Request are done by sending the the long url to http://url6.net/api/. The URL will then be processed by our server and the a short url will be generated. Below is an example of a sample request. Note that request are only accept if and only you also send your API key which is assigned when you register to our site.
 

GET http://url6.net/api/?url=http://www.google.com&api=APIKEY


Below is a sample response. Note that response are returned in json format. This means that you will need the decode that use the native decoding of the language you use in your application. If there are no errors encountered during the process, the "error" element will be set to 0, otherwise to 1. You can use this to validate the content before using it.

 

Sample Response
 

{
"error":"0",
"short":http://url6.net/mnQRi"
}

 

Sample Usage in PHP
 

$content=@file_get_contents("http://url6.net/api/?url=http://www.google.com&api=APIKEY");
 

$url=json_decode($content,TRUE);//Decodes json into an array
 
if(!$url["error"]){  // If there is no error
echo $url["short"]; //Outputs the short url
}else{ 
echo $url["msg"]; //Outputs the error message
}

 

Handling Errors
 

If there is a problem, the error element will be set to "0" and an error message will be set. There are several error messages. For example, if the API key is not set or is invalid, an error message will tell you that. 

These are some cases you can expect an error:

 

  1. Invalid URL or is simple not set
  2. API Key is invalid or is not set
  3. The administrator has disabled the API system.

 

Sample Error Response
 

{
"error":"1",
"msg":"Service have been disabled."
}