NAV
shell python javascript php

Introduction

Welcome to the url.1click.top API! You can use our API to access url.1click.top API endpoints, which can get information about URL in our database and create Shorten URL.

We have language bindings in Shell, Python, JavaScript and PHP! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Get Original URL from Shortcode

import requests

url = 'https://url.1click.top/api/get/?shortcode=fb,abc123'

x = requests.get(url)

print(x.text)
curl -X GET https://url.1click.top/api/get/?shortcode=fb,abc123
var url = "https://url.1click.top/api/get/?shortcode=fb,abc123";

var xhr = new XMLHttpRequest();
xhr.open("GET", url);

xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
      console.log(xhr.status);
      console.log(xhr.responseText);
   }};

xhr.send();
<?php

$url = "https://url.1click.top/api/get/?shortcode=fb,abc123";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

?>

The above command returns JSON structured like this:

{
    "status": "OK",
    "result": [{
        "shortcode": "fb",
        "longurl": "https://www.facebook.com/"
    }, {
        "shortcode": "abc123",
        "comment": "Đường dẫn rút gọn đã hết hạn hoặc không tồn tại. Vui lòng kiểm tra lại."
    }]
}

This endpoints retrieves Original URL from Shortcode.

Request

GET https://url.1click.top/api/get/?shortcode={shortcode_1,shortcode_2,...}

Query Parameters

Parameter Default Description Note
shortcode NULL Shortcode list separated by ',' Required

Example:
https://url.1click.top/api/get/?shortcode=fb,abc123

Create Shortened URL

import requests

url = 'https://url.1click.top/api/short/'
data = [
   {
      "url":"url.1click.top/api_document",
      "custom":"testapi",
      "password":"api123",
      "expiry":"27-01-2021 22:30",
      "key":"a123@"
   },
   {
      "url":"hcmue.edu.vn",
      "custom":"hcmue"
   }
]

x = requests.post(url, json = data)

print(x.text)
curl -XPOST -H "Content-type: application/json" \
-d '[ { "url":"url.1click.top/api_document", \
"custom":"testapi", "password":"api123", \
"expiry":"27-01-2021 22:30", "key":"a123@"}, \
{ "url":"hcmue.edu.vn", "custom":"hcmue" } ]' \
'https://url.1click.top/api/short/'
var url = "https://url.1click.top/api/short";

var xhr = new XMLHttpRequest();
xhr.open("POST", url);

xhr.setRequestHeader("Content-Type", "application/json");

xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
      console.log(xhr.status);
      console.log(xhr.responseText);
   }};

var data = `[
   {
      "url":"url.1click.top/api_document",
      "custom":"testapi",
      "password":"api123",
      "expiry":"27-01-2021 22:30",
      "key":"a123@"
   },
   {
      "url":"hcmue.edu.vn",
      "custom":"hcmue"
   }
]`;

xhr.send(data);
<?php

$url = "https://url.1click.top/api/short/";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = <<<DATA
[
   {
      "url":"url.1click.top/api_document",
      "custom":"testapi",
      "password":"api123",
      "expiry":"27-01-2021 22:30",
      "key":"a123@"
   },
   {
      "url":"hcmue.edu.vn",
      "custom":"hcmue"
   }
]
DATA;

curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

?>

The above command returns JSON structured like this:

{
    "status": "OK",
    "result": [{
        "longUrl": "url.1click.top/api_document",
        "shortcode": "testapi",
        "shortUrl": "https://url.1click.top/testapi",
        "key": "a123@"
    }, {
        "longUrl": "hcmue.edu.vn",
        "comment": "Đường dẫn rút gọn https://url.1click.top/hcmue đã tồn tại. Vui lòng chọn lại."
    }]
}

This endpoints creates shorten URL and retrieves shorten URL.

Request

POST https://url.1click.top/api/short/

Data Parameters

List of object with every element is as below:

Parameter Default Description Note
url NULL The URL you need to shorten Required
custom NULL Short code of URL you need to shorten, if not set short code will create random
password NULL Authentication password to access the URL, if not set anyone can access the URL without authentication
expiry NULL The expiration date of shortened URL with format "dd-mm-yyyy hh:mm", if not set, shortened URL will remain until it is removed
key NULL The key for you to delete shortened URL, if not set, you can not delete shortened URL unless it expires

Example data:
[ { "url":"url.1click.top/api_document", "custom":"api", "password":"api123", "expiry":"27-01-2021 22:30", "key":"a123@" }, { "url":"hcmue.edu.vn", "custom":"hcmue" } ]

Remove Shortened URL

import requests

url = 'https://url.1click.top/api/delete'
data = [
   {
      "shortcode":"testapi",
      "key":"a123@"
   },
   {
      "shortcode":"fb",
      "key":"pass"
   }
]

x = requests.post(url, json = data)

print(x.text)
curl -XPOST -H "Content-type: application/json" \
-d '[ {"shortcode":"testapi","key":"a123@"},\
{"shortcode":"fb","key":"pass"}]' \
'https://url.1click.top/api/delete'
var url = "https://url.1click.top/api/delete";

var xhr = new XMLHttpRequest();
xhr.open("POST", url);

xhr.setRequestHeader("Content-Type", "application/json");

xhr.onreadystatechange = function () {
   if (xhr.readyState === 4) {
      console.log(xhr.status);
      console.log(xhr.responseText);
   }};

var data = `[
   {
      "shortcode":"testapi",
      "key":"a123@"
   },
   {
      "shortcode":"fb",
      "key":"pass"
   }
]`;

xhr.send(data);
<?php

$url = "https://url.1click.top/api/delete";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$data = <<<DATA
[
   {
      "shortcode":"testapi",
      "key":"a123@"
   },
   {
      "shortcode":"fb",
      "key":"pass"
   }
]
DATA;

curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

?>

The above command returns JSON structured like this:

{
    "status": "OK",
    "result": [{
        "shortcode": "testapi",
        "key": "a123@",
        "comment": "Đường dẫn https://url.1click.top/testapi được xóa thành công!"
    }, {
        "shortcode": "fb",
        "key": "pass",
        "comment": "Xóa không thành công do Key không đúng."
    }]
}

This endpoints remove shorten URL.

Request

POST https://url.1click.top/api/delete

Data Parameters

List of object with every element is as below:

Parameter Default Description Note
shortcode NULL Shortcode of shortened URL you need to remove Required
key NULL Authentication key of shortened URL you need to remove, if not set or not match the shortened URL, you can't remove the shortened URL Required

Example data:
[ { "shortcode":"testapi", "key":"a123@" }, { "shortcode":"fb", "key":"pass" } ]