Разработчики

API Documentation

Bitlq provides an API that you can use to shorten URLs within your application. It allows you to automate manual tasks with ease. You can also use the API to fetch data about every short URL in your account.

Your API Key

Once you sign up with bitlq, the system will generate your API key.

  1. Login to your account.
  2. Click the “settings” option on the left sidebar.
  3. You will find your API key on the right side of the dashboard. 

Using the API

Sending a shorten URL request

Use the following URL to send a request to shorten a URL:

http://bitlq.com/api?api=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS

  • You can use https:// instead of http:// according to your needs.
  • Replace the APIKEY with your own API key.
  • Replace THELONGURLTOBESHORTENED with the URL you would like to shorten.
  • You can request a custom alias. Replace the CUSTOMALIAS with the one that you would like to use. Remember to check the request response to make sure the alias that you asked for is not in use.
  • If you are using a custom domain (Business Pro users), replace the bitlq domain name with your own domain.

 

Parsing a shorten URL response

The bitlq API server response is encoded using the JSON format.
The response will contain two elements:

  • The first element named “error” indicates if there was an error with your call (1) or not (0).
  • The second element will be named “short” if no error has occurred and its value will include the short URL. In case of an error, it will be named “msg” and will include the description of the error.

For example:

// No errors
{
  "Error":0,
  "short":"http:\/\/bitlq.com\/r6Zfs"
}

// An error has occurred
{
  "error":1,
  "msg":"A valid API key is required to use this service."
}

 

 

Using plain text format

You can choose to request that the response will be sent to you using plain text format by adding &format=text at the end of your GET request.
When using plain text format, the short URL will be returned instead of the JSON encoded response.
We highly recommend not using this option unless you have no other choice.  In an event of an error the output will be NULL and you will get no indication about the error reason.

 

 

Using the API in PHP

Below you will find a sample code on how to use the API with PHP.

  // Using JSON Response
  $api_url="http://bitlq.com/api?api=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS";
  $res= @json_decode(file_get_contents($api_url),TRUE);
  if($res["error"])
  {
    echo $res["msg"];
  }
  else
  {
    echo $res["short"];
  }

  // Using Plain Text Response
  $api_url="http://blitlq.com/api?api=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS&format=text";
  $res= @file_get_contents($api_url);
  if($res)
  {
    echo $res;
  }