NAV Navbar
javascript php ruby python shell
  • Introduction
  • Authentication
  • Short URLs
  • Errors
  • Introduction

    Welcome to the lc.cx developer API! You can use our API to access lc.cx API endpoints, which can perform operation on your short URLs.

    To use our API service, you need to have a valid API key. You can register a new API key from your account. If you don't have yet an account, you can create on for free.

    Authentication

    To authorize, use this code:

    require 'kittn'
    
    api = Kittn::APIClient.authorize!('meowmeowmeow')
    
    import kittn
    
    api = kittn.authorize('meowmeowmeow')
    
    # With shell, you can just pass the correct header with each request
    curl "api_endpoint_here"
      -H "Authorization: meowmeowmeow"
    
    const kittn = require('kittn');
    
    let api = kittn.authorize('meowmeowmeow');
    

    Make sure to replace meowmeowmeow with your API key.

    Before performing actions, you need first to retrieve a JWT in order to perform actions. If success, token has be to set in headers.

    HTTP Request

    GET /api/v1/auth

    Query Parameters

    Parameter Description
    api_key API key of your account

    Short URLs

    Create a short URL

    require 'kittn'
    
    api = Kittn::APIClient.authorize!('meowmeowmeow')
    api.kittens.get
    
    import kittn
    
    api = kittn.authorize('meowmeowmeow')
    api.kittens.get()
    
    curl "http://example.com/api/kittens"
      -H "Authorization: meowmeowmeow"
    
    const kittn = require('kittn');
    
    let api = kittn.authorize('meowmeowmeow');
    let kittens = api.kittens.get();
    

    The above command returns JSON structured like this:

    {  
       "status_code":200,
       "status_message":"OK",
       "data":{  
          "longUrl":"http:\/\/www.myawsomewebsite.com",
          "shortUrl":"https:\/\/lc.cx\/myawesomewebsite"
       }
    }
    

    This endpoint creates a short URL.

    HTTP Request

    POST /api/v1/create

    Headers Parameters

    Parameter Description
    Authorization=Bearer The JWT you retrieve from the authentification

    Post Parameters

    Parameter Description
    longUrl The long url to shrink
    customUrl (optional) name of a custom slug

    Expand a short URL

    require 'kittn'
    
    api = Kittn::APIClient.authorize!('meowmeowmeow')
    api.kittens.get(2)
    
    import kittn
    
    api = kittn.authorize('meowmeowmeow')
    api.kittens.get(2)
    
    curl "http://example.com/api/kittens/2"
      -H "Authorization: meowmeowmeow"
    
    const kittn = require('kittn');
    
    let api = kittn.authorize('meowmeowmeow');
    let max = api.kittens.get(2);
    

    The above command returns JSON structured like this:

    {
      "id": 2,
      "name": "Max",
      "breed": "unknown",
      "fluffiness": 5,
      "cuteness": 10
    }
    

    This endpoint retrieves the long URL from a short URL.

    HTTP Request

    POST /api/v1/expand

    Headers Parameters

    Parameter Description
    Authorization=Bearer The JWT you retrieve from the authentification

    Query Parameters

    Parameter Description
    ShortUrl The short URL to expand

    Deactivate a short URL

    require 'kittn'
    
    api = Kittn::APIClient.authorize!('meowmeowmeow')
    api.kittens.delete(2)
    
    import kittn
    
    api = kittn.authorize('meowmeowmeow')
    api.kittens.delete(2)
    
    curl "http://example.com/api/kittens/2"
      -X DELETE
      -H "Authorization: meowmeowmeow"
    
    const kittn = require('kittn');
    
    let api = kittn.authorize('meowmeowmeow');
    let max = api.kittens.delete(2);
    

    The above command returns JSON structured like this:

    {
      "id": 2,
      "deleted" : ":("
    }
    

    This endpoint retrieves the long URL from a short URL.

    HTTP Request

    POST /api/v1/deactivate

    Headers Parameters

    Parameter Description
    Authorization=Bearer The JWT you retrieve from the authentification

    Query Parameters

    Parameter Description
    ShortUrl The short URL to deactivate

    Errors

    The Kittn API uses the following error codes:

    Error Code Meaning
    400 Bad Request -- Your request is invalid.
    401 Unauthorized -- Your API key is wrong.
    403 Forbidden -- The kitten requested is hidden for administrators only.
    404 Not Found -- The specified kitten could not be found.
    405 Method Not Allowed -- You tried to access a kitten with an invalid method.
    406 Not Acceptable -- You requested a format that isn't json.
    410 Gone -- The kitten requested has been removed from our servers.
    418 I'm a teapot.
    429 Too Many Requests -- You're requesting too many kittens! Slow down!
    500 Internal Server Error -- We had a problem with our server. Try again later.
    503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.