Important

  1. Request should use GET method.
  2. If you have premium IP address with us, request must be made from same IP address or use the access token to avoid "redirect window".
  3. Endpoint is: https://cu8.in/api/?
  4. Response type: json
  5. See pricing for request limit. Respect it.


API Parameters

  1. action: [required] :: This determines what you want to do with the API.
    1. action=short :: To shorten long URL(s). Use "domain=https://my-domain.com/" parameter for your custom domain URL. Use "key=Nice" parameter to get expected key if available.
    2. action=info :: To get information of an existing shorten entry. key parameter required. The request must made from the same IP address of creation or use token.
    3. action=update :: To update an existing shorten entry. key parameter required. The request must made from the same IP address of creation or use token.
    4. action=delete :: To delete an existing shorten entry. key parameter required. The request must made from the same IP address of creation or use token.
  2. urls: [optional] :: Must provide for shorten URL(s). Multiple URL can be made separated by "|" (pipe).
  3. key: [optional] :: Must provide where identification needed.
  4. token: [optional] :: Use it when not calling from correct server IP address.


Response parameters

  • status [int]: The type of response. Usually 200 is good to go. Please checkout REST status code for more http status code.
  • error [array]: A list of error messages.
  • data [object]: Main response and data will be available here.
    • key [string]: The key of shorten URL.
    • shortUrl [object]: List of shorten URLs.
      • secure [string]: https:// enabled (SSL) shorten URL.
      • insecure [string]: http:// enabled (non-SSL) shorten URL.
      • privateDomainInsecure [string]: Fully qualified shorten URL of your own domain.
    • targetUrls [array]: List of target URLs.
    • scannedForMalware [array]: List of integer value. It is unix timestamp when the URL has been last checked for malware
    • validTill [int]: Unix timestamp when the shorten link will expire.
    • clientIp [string]: The ip address of the device while created the shorten link.
    • token [string]: The token you used while created the shorten link.


Example of a successful response

Example: https://cu8.in/api/?action=short&urls=|https://google.com|https://facebook.com|&domain=https://drivebird.com/&token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

{
    "status": 200,
    "error": [],
    "data": {
        "key": "Love",
        "shortUrl": {
            "secure": "https://cu8.in/Love",
            "insecure": "http://cu8.in/Love",
            "privateDomainInsecure": "http://drivebird.com/Love"
        },
        "targetUrls": [
            "https://google.com",
            "https://facebook.com"
        ],
        "scannedForMalware": [
            0,
            0
        ],
        "redirects": [
            0,
            0
        ],
        "validTill": 1678269978,
        "clientIp": "127.0.0.1",
        "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
}
                        


Example of a failed response

Example: https://cu8.in/api/?action=short&urlX=|https://google.com|https://facebook.com|&domain=https://drivebird.com/

{
    "status": 400,
    "error": [
        "Required key not found: urls"
    ],
    "data": {}
}
                        


Shortening URL with automated key

Example: https://cu8.in/api/?action=short&urls=|https://cu8.in/|

  • Replace the urls with yours. Use "|" to separate multiple URLs.


Shortening rotating URL with automated key

Example: https://cu8.in/api/?action=short&urls=|https://cu8.in/|https://google.com|. Replace the urls with yours. Use "|" to separate multiple URLs.


Updating a shortened link

Example: https://cu8.in/api/?action=update&urls=|https://cu8.in/|&key=Love OR https://cu8.in/api/?action=update&urls=|https://cu8.in/|https://google.com|&key=Love. Replace the urls with yours. Use "|" to separate multiple URLs. You may also provide "domain" parameter to get your personalized shorten link. The request must made from the same IP address of creation or use token. Replace the urls and key with yours.


Shortening URL to vanity/custom URL

Example: https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love. OR https://cu8.in/api/?action=short&urls=|https://cu8.in/|https://google.com|&key=Love. Replace the urls and key with yours.


Know total clicks of a shortened link

Example: https://cu8.in/api/?action=info&key=Love. The request must made from the same IP address of creation or use token. Replace the key with yours. Check the redirects from the result.


Know the validity of a shortened URL

Example: https://cu8.in/api/?action=info&key=Love. The request must made from the same IP address of creation or use token. Replace the key with yours. Check the validTill from the result. This is unix timestamp which means its a total number of seconds since 1970. A shorten URL will last for 1100 days from creation time. After that every redirection will reset it's validity for next 1100 days. Meaning, creating / editing / redirecting will reset its validity for 1100 days.


Delete a shorten link

Example: https://cu8.in/api/?action=delete&key=Love. The request must made from the same IP address of creation or use token. Replace the key with yours.


Get the IP address of the requesting device

Example: https://cu8.in/api/?action=getIp. Check the clientIp from the result.


Sample code for: CURL

curl "https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love"


Sample code for: PHP

$result = file_get_contents('https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love');


Sample code for: PHP-CURL

$handle = curl_init();
$url = "https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love";
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($handle);
curl_close($handle);
echo $output;


Sample code for: Python2

import urllib2
contents = urllib2.urlopen("https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love").read()


Sample code for: Python3

import urllib.request
contents = urllib.request.urlopen("https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love").read()


Sample code for: Node js

const https = require('https');
https.get('https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love', (resp) => {
  let data = '';
  resp.on('data', (chunk) => {
    data += chunk;
  });
  resp.on('end', () => {
    console.log(JSON.parse(data).explanation);
  });
}).on("error", (err) => {
  console.log("Error: " + err.message);
});


Sample code for: jQuery

$.get("https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love", function(data, status){
    alert("Data: " + JSON.stringify(data) + "\nStatus: " + status);
});


Sample code for: React

fetch('https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love')
.then(res => {
    console.log(res.data);
})


Sample code for: Angular 8

httpClient.get('https://cu8.in/api/?action=short&urls=|https://cu8.in/|&key=Love');