Распрацоўшчыкі

Даведнік API для распрацоўшчыкаў

Для апрацоўкі запытаў сістэмай неабходны ключ API. Пасля рэгістрацыі карыстальніка для яго аўтаматычна ствараецца ключ API.

Пачатак працы

Для апрацоўкі запытаў сістэмай неабходны ключ API. Пасля рэгістрацыі карыстальніка для яго аўтаматычна ствараецца ключ API. Ключ API неабходна адпраўляць з кожным запытам (гл. поўны прыклад ніжэй). Калі ключ API не будзе адпраўлены або тэрмін яго дзеяння скончыцца, узнікне памылка. Захоўвайце свой ключ API ў сакрэце, каб прадухіліць яго злоўжыванне.

Аўтэнтыфікацыя

Для аўтэнтыфікацыі ў сістэме API неабходна адпраўляць ключ API ў якасці токена аўтарызацыі з кожным запытам. Прыклад кода глядзіце ніжэй.

curl --location --request POST 'https://clck.su/api/account' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \ 

Абмежаванне частаты запытаў

Наш API мае абмежавальнік частаты запытаў, які абараняе ад рэзкага павелічэння іх колькасці і дапамагае забяспечыць стабільную працу сістэмы. У цяперашні час дазволена не больш за 30 запытаў за 1 хвіліну. Звярніце ўвагу, што абмежаванне можа змяняцца ў залежнасці ад абранага тарыфнага плана.

Разам з адказам будуць адпраўлены некалькі загалоўкаў. Іх можна прааналізаваць, каб атрымаць розную інфармацыю пра запыт.

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

Апрацоўка адказаў

Усе адказы API па змаўчанні вяртаюцца ў фармаце JSON. Каб пераўтварыць іх у даныя, прыдатныя для выкарыстання, неабходна ўжыць адпаведную функцыю ў залежнасці ад мовы праграмавання. У PHP для пераўтварэння даных у аб’ект (па змаўчанні) або масіў (для гэтага задайце другі параметр як true) можна выкарыстоўваць функцыю json_decode(). Вельмі важна правяраць ключ error, бо ён паказвае, ці ўзнікла памылка. Таксама можна праверыць код загалоўка.

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

Account

Get Account

GET https://clck.su/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://clck.su/api/account' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "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://clck.su/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://clck.su/api/account/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "newemail@google.com",
    "password": "NewPassword1"
}'

Адказ сервера

{
    "error": 0,
    "message": "Account has been successfully updated."
}

QR-коды

List QR codes

GET https://clck.su/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).

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/qr?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "qrs": [
            {
                "id": 2,
                "link": "https:\/\/clck.su\/qr\/a2d5e",
                "scans": 0,
                "name": "Google",
                "date": "2020-11-10 18:01:43"
            },
            {
                "id": 1,
                "link": "https:\/\/clck.su\/qr\/b9edfe",
                "scans": 5,
                "name": "Google Canada",
                "date": "2020-11-10 18:00:25"
            }
        ]
    }
}

Get a single QR Code

GET https://clck.su/api/qr/:id

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

curl --location --request GET 'https://clck.su/api/qr/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "details": {
        "id": 1,
        "link": "https:\/\/clck.su\/qr\/b9edfe",
        "scans": 5,
        "name": "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://clck.su/api/qr/add

To create 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).

Параметр Апісанне
type (required) text | vcard | link | email | phone | sms | wifi
data (required) Data to be embedded inside the QR code. The data can be string or array depending on the type
background (optional) RGB color e.g. rgb(255,255,255)
foreground (optional) RGB color e.g. rgb(0,0,0)
logo (optional) Path to the logo either png or jpg
name (optional) QR Code name
curl --location --request POST 'https://clck.su/api/qr/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "rgb(255,255,255)",
    "foreground": "rgb(0,0,0)",
    "logo": "https:\/\/site.com\/logo.png",
    "name": "QR Code API"
}'

Адказ сервера

{
    "error": 0,
    "id": 3,
    "link": "https:\/\/clck.su\/qr\/a58f79"
}

Update QR Code

PUT https://clck.su/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).

Параметр Апісанне
data (required) Data to be embedded inside the QR code. The data can be string or array depending on the type
background (optional) RGB color e.g. rgb(255,255,255)
foreground (optional) RGB color e.g. rgb(0,0,0)
logo (optional) Path to the logo either png or jpg
curl --location --request PUT 'https://clck.su/api/qr/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "link",
    "data": "https:\/\/google.com",
    "background": "rgb(255,255,255)",
    "foreground": "rgb(0,0,0)",
    "logo": "https:\/\/site.com\/logo.png"
}'

Адказ сервера

{
    "error": 0,
    "message": "QR has been updated successfully."
}

Delete a QR Code

DELETE https://clck.su/api/qr/:id/delete

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

curl --location --request DELETE 'https://clck.su/api/qr/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "message": "QR Code has been deleted successfully."
}

Брэндаваныя дамены

List Branded Domains

GET https://clck.su/api/domains?limit=2&page=1

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

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/domains?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "domains": [
            {
                "id": 1,
                "domain": "https:\/\/domain1.com",
                "redirectroot": "https:\/\/rootdomain.com",
                "redirect404": "https:\/\/rootdomain.com\/404"
            },
            {
                "id": 2,
                "domain": "https:\/\/domain2.com",
                "redirectroot": "https:\/\/rootdomain2.com",
                "redirect404": "https:\/\/rootdomain2.com\/404"
            }
        ]
    }
}

Create a Branded Domain

POST https://clck.su/api/domain/add

A domain can be added using this endpoint. Please make sure the domain is correctly pointed to our server.

Параметр Апісанне
domain (required) Branded domain including http or https
redirectroot (optional) Root redirect when someone visits your domain
redirect404 (optional) Custom 404 redirect
curl --location --request POST 'https://clck.su/api/domain/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "domain": "https:\/\/domain1.com",
    "redirectroot": "https:\/\/rootdomain.com",
    "redirect404": "https:\/\/rootdomain.com\/404"
}'

Адказ сервера

{
    "error": 0,
    "id": 1
}

Абнавіць дамен

PUT https://clck.su/api/domain/:id/update

To update a branded domain, 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).

Параметр Апісанне
redirectroot (optional) Root redirect when someone visits your domain
redirect404 (optional) Custom 404 redirect
curl --location --request PUT 'https://clck.su/api/domain/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "redirectroot": "https:\/\/rootdomain-new.com",
    "redirect404": "https:\/\/rootdomain-new.com\/404"
}'

Адказ сервера

{
    "error": 0,
    "message": "Domain has been updated successfully."
}

Delete Domain

DELETE https://clck.su/api/domain/:id/delete

To delete a domain, you need to send a DELETE request.

curl --location --request DELETE 'https://clck.su/api/domain/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "message": "Domain has been deleted successfully."
}

Кампаніі

List Campaigns

GET https://clck.su/api/campaigns?limit=2&page=1

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

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/campaigns?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "campaigns": [
            {
                "id": 1,
                "name": "Sample Campaign",
                "public": false,
                "rotator": false,
                "list": "https:\/\/domain.com\/u\/admin\/list-1"
            },
            {
                "id": 2,
                "domain": "Facebook Campaign",
                "public": true,
                "rotator": "https:\/\/domain.com\/r\/test",
                "list": "https:\/\/domain.com\/u\/admin\/test-2"
            }
        ]
    }
}

Стварыць кампанію

POST https://clck.su/api/campaign/add

A campaign can be added using this endpoint.

Параметр Апісанне
name (optional) Campaign name
slug (optional) Rotator Slug
public (optional) Access
curl --location --request POST 'https://clck.su/api/campaign/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "New Campaign",
    "slug": "new-campaign",
    "public": true
}'

Адказ сервера

{
    "error": 0,
    "id": 3,
    "domain": "New Campaign",
    "public": true,
    "rotator": "https:\/\/domain.com\/r\/new-campaign",
    "list": "https:\/\/domain.com\/u\/admin\/new-campaign-3"
}
POST https://clck.su/api/campaign/:campaignid/assign/:linkid

A short link can be assigned to a campaign using this endpoint. The endpoint requires the campaign ID and the short link ID.

curl --location --request POST 'https://clck.su/api/campaign/:campaignid/assign/:linkid' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "message": "Link successfully added to the campaign."
}

Абнавіць кампанію

PUT https://clck.su/api/campaign/:id/update

To update a campaign, 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).

Параметр Апісанне
name (required) Campaign name
slug (optional) Rotator Slug
public (optional) Access
curl --location --request PUT 'https://clck.su/api/campaign/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Twitter Campaign",
    "slug": "twitter-campaign",
    "public": true
}'

Адказ сервера

{
    "error": 0,
    "id": 3,
    "domain": "Twitter Campaign",
    "public": true,
    "rotator": "https:\/\/domain.com\/r\/twitter-campaign",
    "list": "https:\/\/domain.com\/u\/admin\/twitter-campaign-3"
}

Delete Campaign

DELETE https://clck.su/api/campaign/:id/delete

To delete a campaign, you need to send a DELETE request.

curl --location --request DELETE 'https://clck.su/api/campaign/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "message": "Campaign has been deleted successfully."
}

Каналы

List Channels

GET https://clck.su/api/channels?limit=2&page=1

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

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/channels?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "channels": [
            {
                "id": 1,
                "name": "Channel 1",
                "description": "Description of channel 1",
                "color": "#000000",
                "starred": true
            },
            {
                "id": 2,
                "name": "Channel 2",
                "description": "Description of channel 2",
                "color": "#FF0000",
                "starred": false
            }
        ]
    }
}

List Channel Items

GET https://clck.su/api/channel/:id?limit=1&page=1

To get items in a select channels via the API, you can use this endpoint. You can also filter data (See table for more info).

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/channel/:id?limit=1&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "items": [
            {
                "type": "links",
                "id": 1,
                "title": "My Sample Link",
                "preview": "https:\/\/google.com",
                "link": "https:\/\/clck.su\/google",
                "date": "2022-05-12"
            },
            {
                "type": "bio",
                "id": 1,
                "title": "My Sample Bio",
                "preview": "https:\/\/clck.su\/mybio",
                "link": "https:\/\/clck.su\/mybio",
                "date": "2022-06-01"
            }
        ]
    }
}

Стварыць канал

POST https://clck.su/api/channel/add

A channel can be added using this endpoint.

Параметр Апісанне
name (required) Channel name
description (optional) Channel description
color (optional) Channel badge color (HEX)
starred (optional) Star the channel or not (true or false)
curl --location --request POST 'https://clck.su/api/channel/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "New Channel",
    "description": "my new channel",
    "color": "#000000",
    "starred": true
}'

Адказ сервера

{
    "error": 0,
    "id": 3,
    "name": "New Channel",
    "description": "my new channel",
    "color": "#000000",
    "starred": true
}

Assign an Item to a Channel

POST https://clck.su/api/channel/:channelid/assign/:type/:itemid

An item can be assigned to any channel by sending a request with the channel id, item type (links, bio or qr) and item id.

Параметр Апісанне
:channelid (required) Channel ID
:type (required) links or bio or qr
:itemid (required) Item ID
curl --location --request POST 'https://clck.su/api/channel/:channelid/assign/:type/:itemid' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "message": "Item successfully added to the channel."
}

Абнавіць канал

PUT https://clck.su/api/channel/:id/update

To update a channel, 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).

Параметр Апісанне
name (optional) Channel name
description (optional) Channel description
color (optional) Channel badge color (HEX)
starred (optional) Star the channel or not (true or false)
curl --location --request PUT 'https://clck.su/api/channel/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Acme Corp",
    "description": "channel for items for Acme Corp",
    "color": "#FFFFFF",
    "starred": false
}'

Адказ сервера

{
    "error": 0,
    "message": "Channel has been updated successfully."
}

Delete Channel

DELETE https://clck.su/api/channel/:id/delete

To delete a channel, you need to send a DELETE request. All items will be unassigned as well.

curl --location --request DELETE 'https://clck.su/api/channel/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "message": "Channel has been deleted successfully."
}

Пікселі

List Pixels

GET https://clck.su/api/pixels?limit=2&page=1

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

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/pixels?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "pixels": [
            {
                "id": 1,
                "type": "gtmpixel",
                "name": "GTM Pixel",
                "tag": "GA-123456789",
                "date": "2020-11-10 18:00:00"
            },
            {
                "id": 2,
                "type": "twitterpixel",
                "name": "Twitter Pixel",
                "tag": "1234567",
                "date": "2020-11-10 18:10:00"
            }
        ]
    }
}

Create a Pixel

POST https://clck.su/api/pixel/add

A pixel can be created using this endpoint. You need to send the pixel type and the tag.

Параметр Апісанне
type (required) gtmpixel | gapixel | fbpixel | adwordspixel | linkedinpixel | twitterpixel | adrollpixel | quorapixel | pinterest | bing | snapchat | reddit | tiktok
name (required) Custom name for your pixel
tag (required) The tag for the pixel
curl --location --request POST 'https://clck.su/api/pixel/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "gtmpixel",
    "name": "My GTM",
    "tag": "GTM-ABCDE"
}'

Адказ сервера

{
    "error": 0,
    "id": 1
}

Абнавіць піксель

PUT https://clck.su/api/pixel/:id/update

To update a pixel, 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).

Параметр Апісанне
name (optional) Custom name for your pixel
tag (required) The tag for the pixel
curl --location --request PUT 'https://clck.su/api/pixel/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "My GTM",
    "tag": "GTM-ABCDE"
}'

Адказ сервера

{
    "error": 0,
    "message": "Pixel has been updated successfully."
}

Delete Pixel

DELETE https://clck.su/api/pixel/:id/delete

To delete a pixel, you need to send a DELETE request.

curl --location --request DELETE 'https://clck.su/api/pixel/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": 0,
    "message": "Pixel has been deleted successfully."
}

Уласная старонка-застаўка

List Custom Splash

GET https://clck.su/api/splash?limit=2&page=1

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

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/splash?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "splash": [
            {
                "id": 1,
                "name": "Product 1 Promo",
                "date": "2020-11-10 18:00:00"
            },
            {
                "id": 2,
                "name": "Product 2 Promo",
                "date": "2020-11-10 18:10:00"
            }
        ]
    }
}

Усплывальныя блокі з заклікам да дзеяння (CTA)

List CTA Overlays

GET https://clck.su/api/overlay?limit=2&page=1

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

Параметр Апісанне
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://clck.su/api/overlay?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \

Адказ сервера

{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "cta": [
            {
                "id": 1,
                "type": "message",
                "name": "Product 1 Promo",
                "date": "2020-11-10 18:00:00"
            },
            {
                "id": 2,
                "type": "contact",
                "name": "Contact Page",
                "date": "2020-11-10 18:10:00"
            }
        ]
    }
}