API integration guide

April 12, 2017

Find out how to integrate with owl URL using our API. This tutorial is part of the owl URL - features for your social media and WordPress.

What is more flexible than your apps?

You favorite app, owl URL, which now integrates with any API capable apps!

 

Log in to your account for an API Key

An API key is required for requests to be processed by our server. Once a user registers, an API key is automatically generated. Find YOUR API key under Settings > Developers.

Sending a request for shortening an URL

To send a request, the user must use the following format where the variables API 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.

GET https://owlurl.io/short/api?api=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS

Server response

As before, the response will be 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 below for an example)

// No errors
{
  "error":0,
  "short":"https:\/\/owlurl.io\/short\/tdCXe"
}
// An error has occurred
{
  "error":1,
  "msg":"Please enter a valid email"
}

Using plain 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://owlurl.io/short/tdCXe instead of the JSON response. Note that if an error occurs, it will not output anything.

Using the API in PHP

To use the API in your PHP application, you have to send a GET request through file_get_contents or cURL: Both are reliable methods. You can see a sample code below using file_get_contents.

<?php
  // Using JSON Response
  $api_url="https://owlurl.io/short/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="https://owlurl.io/short/api?api=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS&format=text";
  $res= @file_get_contents($api_url);
  if($res){
    echo $res;
  }
?>

The easiest API integration ever!

Share your URL across your digital infrastructure seamlessly.

Geo-targeted QR Code

Geo-targeted QR Code

Apr 13 2017

Find out how to redirect visitors from the same QR CODE to different landing pages to overcome the language barrier and boost…

API integration guide

API integration guide

Apr 12 2017

Find out how to integrate with owl URL using our API. This tutorial is part of the owl URL - features for…

QR coded short links

QR coded short links

Apr 11 2017

Find out how to create a QR code the easy way. This tutorial is part of the owl URL - features for…

ROI optimization

ROI optimization

Jan 10 2017

Find out how to gather important insights to your ROI. This tutorial is part of the owl URL - features for…

Geo-targeting

Geo-targeting

Jan 09 2017

Find out how to redirect visitors from the same short URL to different landing pages to overcome the language barrier and boost…

Shorten URLs

Shorten URLs

Jan 06 2017

Find out how to shorten any long URL into a 16 character length short URL. This tutorial is part of the owl…

API integration guide

by Csaba Miklós time to read: 5 min
0