API Reference for Developers v3

Getting Started

An API key is required for requests to be processed by the system. Once a user registers, an API key is automatically generated for this user. The API key must be sent with each request (see full example below). If the API key is not sent or is expired, there will be an error. Please make sure to keep your API key secret to prevent abuse.

Authentication

To authenticate with the API system, you need to send your API key as an authorization token with each request. You can see sample code below.

curl --location --request POST 'https://urlplus.cn/api/url/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' 
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/url/add",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer YOURAPIKEY",
    "Content-Type: application/json",
    ),
));

$response = curl_exec($curl);
Rate Limit

Our API has a rate limiter to safeguard against spike in requests to maximize its stability. Our rate limiter is currently caped at 30 requests per 1 minute.

Several headers will be sent alongside the response and these can be examined to determine various information about the request.

X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: TIMESTAMP
Response Handling

All API response are returned in JSON format by default. To convert this into usable data, the appropriate function will need to be used according to the language. In PHP, the function json_decode() can be used to convert the data to either an object (default) or an array (set the second parameter to true). It is very important to check the error key as that provides information on whether there was an error or not. You can also check the header code.

{
    "error": 1,
    "message": "An error ocurred"
}

Account

Get Account
GET https://urlplus.cn/api/account

To get information on the account, you can send a request to this endpoint and it will return data on the account.

curl --location --request GET 'https://urlplus.cn/api/account' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/account",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server response
{
    "error": 0,
    "data": {
        "id": 1,
        "email": "sample@domain.com",
        "username": "sampleuser",
        "avatar": "https:\/\/domain.com\/content\/avatar.png",
        "status": "pro",
        "expires": "2022-11-15 15:00:00",
        "registered": "2020-11-10 18:01:43"
    }
}
Update Account
PUT https://urlplus.cn/api/account/update

To update information on the account, you can send a request to this endpoint and it will update data on the account.

curl --location --request PUT 'https://urlplus.cn/api/account/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "newemail@google.com",
    "password": "newpassword"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/account/update",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ),
    CURLOPT_POSTFIELDS => '{
    "email": "newemail@google.com",
    "password": "newpassword"
}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server response
{
    "error": 0,
    "message": "Account has been successfully updated."
}

Links


QR Codes

List all QR codes
GET https://urlplus.cn/api/qr?limit=2&page=1

To get your QR codes via the API, you can use this endpoint. You can also filter data (See table for more info).

ParameterDescription
limit (可选) 每页条数
page (可选) 页码
curl --location --request GET 'https://urlplus.cn/api/qr?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/qr?limit=2&page=1",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server response
{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "qrs": [
            {
                "id": 2,
                "link": "https:\/\/urlplus.cn\/qr\/a2d5e",
                "scans": 0,
                "title": "Google",
                "date": "2020-11-10 18:01:43"
            },
            {
                "id": 1,
                "link": "https:\/\/urlplus.cn\/qr\/b9edfe",
                "scans": 5,
                "title": "Google Canada",
                "date": "2020-11-10 18:00:25"
            }
        ]
    }
}
Get a single QR Code
GET https://urlplus.cn/api/qr/:id

To get details for a single QR code via the API, you can use this endpoint.

curl --location --request GET 'https://urlplus.cn/api/qr/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/qr/:id",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server response
{
    "error": 0,
    "details": {
        "id": 1,
        "link": "https:\/\/urlplus.cn\/qr\/b9edfe",
        "scans": 5,
        "title": "Google Canada",
        "date": "2020-11-10 18:00:25"
    },
    "data": {
        "clicks": 1,
        "uniqueClicks": 1,
        "topCountries": {
            "Unknown": "1"
        },
        "topReferrers": {
            "Direct, email and other": "1"
        },
        "topBrowsers": {
            "Chrome": "1"
        },
        "topOs": {
            "Windows 10": "1"
        },
        "socialCount": {
            "facebook": 0,
            "twitter": 0,
            "instagram": 0
        }
    }
}
Create a QR Code
POST https://urlplus.cn/api/qr/add

To shorten a QR Code, you need to send a valid data in JSON via a POST request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).

ParameterDescription
type (必选)二维码类型: text | vcard | link | email | phone | sms | wifi
data (必选) 包含的数据,可以是字符串或数组
background (可选) 背景色。如 #ffffff
foreground (可选) 前景色。如 #000000
logo (可选) logo地址,支持png和jpg格式
curl --location --request POST 'https://urlplus.cn/api/qr/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "#ffffff",
    "foreground": "#000000",
    "logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/qr/add",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ),
    CURLOPT_POSTFIELDS => '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "#ffffff",
    "foreground": "#000000",
    "logo": "https:\/\/site.com\/logo.png"
}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server response
{
    "error": 0,
    "id": 3,
    "link": "https:\/\/urlplus.cn\/qr\/a58f79"
}
Update a QR Code
PUT https://urlplus.cn/api/qr/:id/update

To update a QR Code, you need to send a valid data in JSON via a PUT request. The data must be sent as the raw body of your request as shown below. The example below shows all the parameters you can send but you are not required to send all (See table for more info).

ParameterDescription
data (必选) 包含的数据,可以是字符串或数组
background (可选) 背景色。如 #ffffff
foreground (可选) 前景色。如 #000000
logo (可选) logo地址,支持png和jpg格式
curl --location --request PUT 'https://urlplus.cn/api/qr/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "#ffffff",
    "foreground": "#000000",
    "logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/qr/:id/update",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ),
    CURLOPT_POSTFIELDS => '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "#ffffff",
    "foreground": "#000000",
    "logo": "https:\/\/site.com\/logo.png"
}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server response
{
    "error": 0,
    "message": "QR has been updated successfully."
}
Delete a QR Code
DELETE https://urlplus.cn/api/qr/:id/delete

To delete a QR code, you need to send a DELETE request.

curl --location --request DELETE 'https://urlplus.cn/api/qr/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://urlplus.cn/api/qr/:id/delete",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 2,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => array(
        "Authorization: Bearer YOURAPIKEY",
        "Content-Type: application/json",
    ),
    
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server response
{
    "error": 0,
    "message": "QR Code has been deleted successfully."
}