Developers

API Documentation and Resources


Lin.vin URL Shortener API Guide

The new API of Lin.vin URL Shortener is built on the RESTful architecture and it allows you to easily interact with your website using the following endpoints. There were some changes to the API in order facilitate requests from developers.


Authentication

As before, an API key is required for requests to be processed by the system. Once a user registers, an API key is automatically generated for this user and it can be found in the /user/tools page. The API key must be sent with each request via the key parameter.

GET https://yourwebsite.com/api?key=YOURAPIKEY


Response Handling

All API response are returned in JSON format by default. To convert this into usable data, the appropriate function will need to be used according to the language. In PHP, the function json_decode() can be used to convert the data to either an object (default) or an array (set the second parameter to true). It is very important to check the error key as that provides information on whether there was an error or not.

____________________________________________________________________

$responseDecoded = json_decode($response);
// Output data
var_dump($responseDecoded);

____________________________________________________________________

stdClass Object
(
    [error] =>
0
    [short] => "https://yourwebsite.com/DkZOb"
) 

____________________________________________________________________

$responseDecoded = json_decode($response, true);
// Output data
var_dump($responseDecoded); 

____________________________________________________________________

array (

'error' => 0,
'short' => 'https://yourwebsite.com/DkZOb',
)


Shorten a Link

To send a request, the user must use the following format where the variables key and url are required. In the example below, the URL of the demo is used but you should use your own domain name. To request a custom alias, simply add &custom= at the end.

 

Parameter Description
key (required) Your API key.
url (required) Long URL to shorten.
custom (optional) Custom alias instead of random alias.
type (optional) Redirection type [direct, frame, splash]
password (optional) Password protection
format (optional) Output format. Default is json. [json, text]

____________________________________________________________________

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => 1,

    CURLOPT_URL => "https://yourwebsite.com/api?key=YOURAPIKEY&url=https://TheLongURL.com"
]);
// $response is the result. We can use it later.
$response = curl_exec($curl);
curl_close($curl);


Server response

As before, the response will encoded in JSON format (default). This is done to facilitate cross-language usage. The first element of the response will always tell if an error has occurred (error: 1) or not (error: 0). The second element will change with respect to the first element.

If there is an error, the second element will be named “msg”. which contains the source of error, otherwise it will be named “short” which contains the short URL. (See the example)

____________________________________________________________________

// No errors
{
  "error" : 0,
  "short" : "https:\/\/yourwebsite.com\/DkZOb"
}

____________________________________________________________________

// An error has occurred
{
 
"error" : 1,
 
"msg" : "Please enter a valid URL"
}  


Text Format

You can now request the response to be in plain text by just adding &format=text at the end of your request. This will return just https://yourwebsite.com/short/DkZOb instead of the JSON response. Note that if an error occurs, it will not output anything. 

____________________________________________________________________

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER =>
1,
    CURLOPT_URL =>
"https://yourwebsite.com/api?key=YOURAPIKEY&url=https://TheLongURL.com&format=text"
]);
// $response is the result. We can use it later.
$response = curl_exec($curl);
curl_close($curl);  

____________________________________________________________________

https://yourwebsite.com/DkZOb 


Statistics for a short URL

You can get more detail on a short URL by using the /details endpoint along with the following parameters. You need to send the unique alias of a short URL and the response will be in JSON.

Parameter Description
key (required) Your API key.
alias (required) Short URL alias.

____________________________________________________________________

GET https://yourwebsite.com/api/details    

____________________________________________________________________

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER =>
1,
    CURLOPT_URL => "
https://yourwebsite.com/api/details?key=YOURAPIKEY&alias=UNIQUEALIAS"
]);
// $response is the result. We can use it later.
$response = curl_exec($curl);
curl_close($curl); 


Server response

As before, the response will encoded in JSON format (default). This is done to facilitate cross-language usage. The first element of the response will always tell if an error has occurred (error: 1) or not (error: 0). The second element will change with respect to the first element.

If there is an error, the second element will be named "msg". which contains the source of error, otherwise it will be named "details" which contains details of the short URL and "data" which includes statistics.    

____________________________________________________________________

{
   "error": 0,
   "data": [
      {
         "alias": "gempixel",
         "shorturl": "https:\/\/yourwebsite.com\/gempixel",
         "longurl": "https:\/\/premiumscript.ca",
         "clicks": "4",
         "title": "Premium Script | Quality PHP Scripts & Themes",
         "description": "Premium Script is your reference for quality PHP scripts and themes at an affordable price. We developped Premium URL Shortener and Premium Media Script.",
         "date": "2019-01-27 22:49:36"
      },
      {
         "alias": "DkZOb",
         "shorturl": "https:\/\/yourwebsite.com\/DkZOb",
         "longurl": "https:\/\/gempixel.com",
         "clicks": "2",
         "title": "GemPixel | Creative Digital Agency",
         "description": "We are a creative digital agency providing full-featured services including branding, creation of website and app development. We are also                                                                                                                                                                                                             behind Premium URL shortener.",
         "date": "2019-01-27 22:48:36"
      }
   ]
}     


If you detect an error in API, need help or have an idea on how to improve it, please contact the Support 

 

Wir in den sozialen Netzwerken

Like uns auf FacebookFolge uns auf Twitter