Developers

Welcome to the LK2 API, hopefully you are here as you are looking to utilise the services provided by LK2 in your application or site and if so, you've arrived at the right place!

We provide a simple public REST API to enable developers to quickly and easily generate short URL's as well as retrieve statistics and information on their short URL's.

This section provides you with downloadable API clients as well as our API documentation.

Libraries and Tools

There are a number of libraries and tools available out in the wild to enable you to harness the power of LK2 by interacting with our API.

If you've built or discovered a library that is not listed below please let us know by emailing us at info@lk2.in we'd love to add it to our list below.

API Code Libraries

The following list contains libraries that have been built by members of the community and although we do not directly support these libraries you are more than welcome to visit their project sites, review their licenses and download and use in accordance with their license agreement(s).

If you have developed a library and would like to get it on this list or stumbled across a library in the wild please let us know by emailing us at info@lk2.in.

PHP
JAVA
C
  • (None at present)
Python
  • (None at present)

API Documentation

We expose our services to developers via an Application Programming Interface (API), developers can therfore interact in a programmatic way with the LK2 platform. This document is the official reference for that functionality. The current API version is 1.0.

Our API does not require any authentication as we aim to build a public API, the only restriction that we impose is an API rate limit of 2000 requests per hour, this rate limit is imposed on the public IP address of your server/device. If you find that you need to raise this limit for your site please contact us and we'll happily add your server's IP address to our whitelist, the rate limit is designed to limit SPAM.

/api/v1/shorten

Creates a short URL from a long URL.

Parameters

  • long_url - A long URL of which to be shortened (eg. http://www.google.com/) must be URL encoded!

The url should be [http://en.wikipedia.org/wiki/Percent-encoding](URL encoded) otherwise you may encounter undesired results once your URL has been shortened.

Return values

  • hash - The shortened URL hash (the short link string)
  • short_url - The shortened version of the URL.
  • long_url - The original URL of which has been shortened.

Example request

GET http://lk2.in/api/v1/shorten?long_url=http%3A%2F%2Fwww.google.com%2F

[
    "data": {
        "hash": "eFdck",
        "short_url": "http://lk2.in/eFdck",
        "long_url": "http://www.google.com/"
    },
    "status_code": 201,
    "status_text": "CREATED"
]

/api/v1/stats

Return statistics and link information for a given shortened URL.

Parameters

  • hash - The shortened URL hash (eg. eFdck)

Return values

  • hash - The shortened URL hash (the short link string)
  • short_url - The shortened version of the URL.
  • long_url - The original URL of which has been shortened.
  • visits - The total number of times the URL has been visited/used.

Example request

GET http://lk2.in/api/v1/stats?hash=eFdck

{
    "data": {
        "hash": "eFdck",
        "short_url": "http://lk2.in/eFdck",
        "long_url": "http://www.google.com/",
        "stats": {
            "total_visits": 4,
            "last_visited": "2015-01-26 19:53:36",
            "lastvisit_continent": "EU",
            "lastvisit_country": "United Kingdom",
            "lastvisit_city": "Ipswich"
        }
    },
    "status_code": 200,
    "status_msg": "OK"
}