Opn.Im API Reference.

Overview.

This documentation describes the public RESTful API of Opn.Im. The Opn.Im API provides methods for creating short links, retrieving analytics data, and managing short links. The RESTful API uses JSON as the underlying data serialization mechanism. The documentation always refers to the latest version of the API. Using the API is free of charge.

Request
Type POST
Address http://opn.im/api/link_to_shorten
Request payload JSON

To create a short link you need to POST JSON with a single field:

Request object fields
url The long URL

Response contains the short URL itself, URL to the analytics dashboard and the short url code (you may use it to generate QR code):

Response object fields
shortUrl The short link
statisticUrl Private link to the analytics dashboard
code Short link code
statisticCode Analytics link code
Code example (JS)
            //include JQuery first
            var rq = new Object();
            rq.url = "google.com"

            $.ajax
            ({
                type: "POST",
                url: 'http://opn.im/api/link_to_shorten',
                dataType: 'json',
                contentType: 'application/json',
                data: JSON.stringify(rq),
                success: function (response) {
                    console.log("Response : ", response);
                }
            });

Generating QR code for your short link.

You may generate QR code for your short link using code parameter (see Creating a short link):

Request
Type GET
Address http://opn.im/api/qr_for_short_url_code/{code}

Example:

http://opn.im/api/qr_for_short_url_code/Cn4gq

Retrieving analytics for your short link.

To retrieve analytics data for the specific short link use statisticCode parameter (see Creating a short link):

Request
Type GET
Address http://opn.im/api/analytics_data/{statisticCode}
Response contains a number of clicks:
Response object fields
analyticsByCountry Total number of clicks for each country
analyticsByBrowser Total number of clicks for each browser
analyticsByOs Total number of clicks for each OS
Code example (JS)
            //include JQuery first
            var statsCode = "K7S9stKPdwaQ7J0r";
            $.ajax
            ({
                type: "GET",
                url: 'http://opn.im/api/analytics_data/' + statsCode,
                success: function (response) {
                    console.log("Response : ", response);
                }
            });

Disabling and enabling the short link.

You may disable or enable your short link using statisticCode parameter (see Creating a short link):

Request
Type POST
Address http://opn.im/api/link_status
Request payload JSON
Request object fields
linkStatsCode The same as statisticCode
active TRUE if the link is enabled
Code example (JS)
           //include JQuery first
            var rq = new Object();
            rq.linkStatsCode = "K7S9stKPdwaQ7J0r";
			rq.active = true;

            $.ajax
            ({
                type: "POST",
                url: 'http://opn.im/api/link_status',
                dataType: 'json',
                contentType: 'application/json',
                data: JSON.stringify(rq),
                success: function () {
                    console.log("Done");
                }
            });

You can also GET status of the short link:

Request
Type GET
Address http://opn.im/api/link_status/{statisticCode}
Response object fields
active TRUE if the link is enabled
Code example (JS)
            //include JQuery first
            var statsCode = "K7S9stKPdwaQ7J0r";
            $.ajax
            ({
                type: "GET",
                url: 'http://opn.im/api/link_status/' + statsCode,
                success: function (response) {
                    console.log("Response : ", response);
                }
            });