API Documentation

What is an API?

API stands for Application Programming Interface. At some point or another, most large companies have built APIs for their customers, or for internal use. (source: https://medium.freecodecamp.org/what-is-an-api-in-english-please-b880a3214a82)

If You don't know what is API do You need it?

If you have your own website and you need to short long links your can make it from your website. You don't need to come to our site and past the links. If you use API you can automate an url shortening process.

Let say you are sending an tracking links or monitoring your delivery. You can use API in your application to short links from your application, and the send them to your customers via email or SMS.

What do I need to use API?

To use API you need:

  1. Register as a user in our system
  2. Generate an API key
  3. Read the rest of this manual to get to know how to use it
  4. Use a PHP/Java or whatever you or your IT use to connect to API
  5. Short long url links or manager an existing ones
  6. Have a coffee and fun

How to call an API?

You can call the api via JSON standard.

PHP JSON API call example?

The api can be requested by JSON.

The url is: http://slink/apirequest/{YourApiKey}

$url = 'http://slink/apirequest/{YourApiKey}';
$ch = curl_init($url);

$data = array( 'action' => 'short', 'url' => 'https://www.google.com' );

$payload = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);

$json_output = json_decode($result);

This exaple shows the first action - short - it shorts Your url.

The JSON has two parameters:

  • action - describe what you want to do, in this example, we want to short a url
  • url - the long url to be shorten

Both parameters are enocded with JSON in $data variable.


If the long url is shortened, you will get an JSON response with two paramenters:

  • status - it;s "OK" if the is no error
  • url - short url like "http://slink/tiny123"

In above example you can access both paramets like

$status = $json_output->status;

$url = $json_output->url;

If you have any question - please contact me.

How to call an API?