api API

Based on many years of experience in filtering traffic, we decided to provide our customers with the ability to use the clicklock service using a functional API.

This functionality provides the ability to manage your threads (create, modify, delete, receive), filtering traffic by incoming parameters, as well as view statistics of clicks for a selected time.

Communication with the service through the API is implemented using Json requests and responses, so clicklock implementation is available in almost any programming language and on any platform, since Json is supported almost everywhere. The most popular ones are: php, js, kotlin, python, c++, etc.

Important - access to the API is available on ADVANCE and PRO subscriptions. API service is not available for START.
Access:

The main tool for accessing API methods is the API key. You can find it on the API subsection home page inside the dashboard. In addition, data about the server from which the request is received is used for access. To enable API service for your server - you need to add API access:

  • domain name - domain address from which access to API functions is allowed*
  • Server IP - IP address of the server from which access to API functions is allowed*
  • User IP - IP address of the user running the script from which access to API functions is allowed*
*Applies to all API methods, except Filtrate - this method works anywhere without additional access settings, you only need the correct combination of API key and thread ID in the request.

When creating an API access setting - you can specify only one of these three parameters, or a combination of them. For example, with the specified domain name, API methods will only work from this domain. If you specify only the server IP - API methods will work from the whole server with this IP - regardless of the domain where the script is located. If you specify both the domain name and the server IP, the API methods will only work from the specified domain, which is located on the server with the specified IP.
API answers:

Responses from the clicklock API service come in a multidimensional array encoded in json.

The first level of the array contains data about the connection result:

title values
action name of the API method of the current connection, options for values depending on the request:

filtrate
create
gettread
update
delete
getclicks
connected 1 - connection was successful
error 1 - the request was sent with an error
message Description of the request error. Possible options:

You dont match any requirements for access this tread - You have entered the wrong thread ID. You dont have access to it.

Account subscription inactive - Inactive subscription.

You have reach the traffic limit for today - You have reached your traffic limit for this day.

Wrong account subscription type - Inappropriate subscription type to use this method.

You dont have access premission for use api here - Insufficient authority to use the API on this server.
clicklock array encoded in json with the result of request processing:

success - takes on the value 1 if the request was successfully processed and the issue provided.

Further, depending on the method, there may be another array with data, or information about the thread ID.
filtrate:

   Request code example:

$data = array(
    'key' => 'YOUR_API_KEY',
    'action' => 'filtrate',
    'data' => json_encode(array(
        'tread' => 'TREAD_ID',
        'server' => json_encode($_SERVER),
        'serverside' => 'self',
        'connection' => 'php'
    ))
)
   Response example:

Array
(
    [action] => filtrate
    [connected] => 1
    [clicklock] => Array
        (
            [filter] => no
            [page_type] => offerpage
            [url] => http://habr.com
            [mode] => load
        )

)
create:

   Request code example:

$data = array(
    'key' => 'YOUR_API_KEY',
    'action' => 'create',
    'data' => json_encode(array(
       'server' => json_encode($_SERVER),
       'title' => 'Test tread 20-05-2022',
       'status' => 'active',
       'status_delayed' => '',
       'savepage' => 'testdomain.com',
       'offerpage_1' => 'yandex.ru',
       'offerpage_perc_1' => '',
       'offerpage_2' => '',
       'offerpage_perc_2' => '',
       'offerpage_3' => '',
       'offerpage_perc_3' => '',
       'offerpage_4' => '',
       'offerpage_perc_4' => '',
       'offerpage_5' => '',
       'offerpage_perc_5' => '',
       'mode' => 'load',
       'core' => 'default',
       'ipv6' => true,
       'vpn' => true,
       'geo_country' => 'off',
       'countrylist' => json_encode(array('United States','Germany')),
       'geo_city' => 'off',
       'citieslist' => json_encode(array('Washington','Berlin')),
       'ip_filter' => 'off',
       'ip_list' => json_encode(array('192.168.0.1','234.26.31.23')),
       'isp_filter' => 'off',
       'isp_list' => json_encode(array('Amazon')),
       'devices_filter' => 'off',
       'devices_list' => json_encode(array('desktop','windows','mobile','android')),
       'referer_filter_empty' => true,
       'referer_filter' => 'disallow',
       'referer_list' => json_encode(array('google')),
       'ua_filter_empty' => false,
       'ua_filter' => 'allow',
       'ua_list' => json_encode(array('chrome')),
       'urlparams_filter_empty' => false,
       'urlparams_filter' => 'off',
       'urlparams_list_allow' => json_encode(array()),
       'urlparams_list_disallow' => json_encode(array('utc_action','test')),
       'time_filter' => 'off',
       'time_list' => json_encode(array('00_01','13_14','14_15','15_16'))
    ))
)
   Response example:

Array
(
    [action] => create
    [connected] => 1
    [clicklock] => Array
        (
            [success] => 1
            [tread] => TREAD_ID
        )

)
gettread:

   Request code example:

$data = array(
    'key' => 'YOUR_API_KEY',
    'action' => 'gettread',
    'data' => json_encode(array(
       'server' => json_encode($_SERVER),
       'tread' => 'TREAD_ID'
    ))
)
   Response example:

Array
(
    [action] => gettread
    [connected] => 1
    [clicklock] => Array
        (
            [success] => 1
            [tread] => Array
                (
                    [id] => TREAD_ID
                    [title] => test.domain.com 1
                    [status] => active
                    [status_delayed] => 0
                    [savepage] => yandex.ru
                    [offerpage_1] => habr.com
                    [offerpage_perc_1] => 100
                    [offerpage_2] => 
                    [offerpage_perc_2] => 
                    [offerpage_3] => 
                    [offerpage_perc_3] => 
                    [offerpage_4] => 
                    [offerpage_perc_4] => 
                    [offerpage_5] => 
                    [offerpage_perc_5] => 
                    [mode] => load
                    [core] => default
                    [ipv6] => 1
                    [vpn] => 1
                    [geo_country] => allow
                    [countrylist] => Array
                        (
                            [1] => United States
                            [2] => Russian Federation
                        )

                    [geo_city] => allow
                    [citieslist] => Array
                        (
                            [0] => Kiiv
                            [1] => London
                        )

                    [ip_filter] => off
                    [ip_list] => Array
                        (
                        )

                    [isp_filter] => off
                    [isp_list] => Array
                        (
                        )

                    [devices_filter] => off
                    [devices_list] => Array
                        (
                            [0] => desktop
                            [1] => windows
                            [2] => mac
                            [3] => linux
                            [4] => mobile
                            [5] => ios
                            [6] => windowsphone
                        )

                    [referer_filter_empty] => 1
                    [referer_filter] => off
                    [referer_list] => Array
                        (
                        )

                    [ua_filter_empty] => 0
                    [ua_filter] => disallow
                    [ua_list] => Array
                        (
                            [0] => Chrome
                        )

                    [urlparams_filter_empty] => 1
                    [urlparams_filter] => off
                    [urlparams_list_allow] => Array
                        (
                        )

                    [urlparams_list_disallow] => Array
                        (
                        )

                    [time_filter] => off
                    [time_list] => Array
                        (
                            [0] => 00_01
                            [1] => 01_02
                            [2] => 02_03
                            [3] => 03_04
                        )

                )

        )

)
update:

   Request code example:

$data = array(
    'key' => 'YOUR_API_KEY',
    'action' => 'update',
    'data' => json_encode(array(
       'server' => json_encode($_SERVER),
       'tread' => 'TREAD_ID',
       'title' => 'Test tread 20-05-2022 updated',
       'status' => 'active',
       'status_delayed' => '',
       'savepage' => 'testdomain.com',
       'offerpage_1' => 'yandex.ru',
       'offerpage_perc_1' => '',
       'offerpage_2' => '',
       'offerpage_perc_2' => '',
       'offerpage_3' => '',
       'offerpage_perc_3' => '',
       'offerpage_4' => '',
       'offerpage_perc_4' => '',
       'offerpage_5' => '',
       'offerpage_perc_5' => '',
       'mode' => 'load',
       'core' => 'default',
       'ipv6' => true,
       'vpn' => true,
       'geo_country' => 'off',
       'countrylist' => json_encode(array('United States','Germany','Spain')),
       'geo_city' => 'off',
       'citieslist' => json_encode(array('Washington')),
       'ip_filter' => 'off',
       'ip_list' => json_encode(array('193.162.23.45','234.26.31.23','234.26.31.0/50')),
       'isp_filter' => 'off',
       'isp_list' => json_encode(array()),
       'devices_filter' => 'allow',
       'devices_list' => json_encode(array('desktop','windows','mobile','android','ios')),
       'referer_filter_empty' => true,
       'referer_filter' => 'allow',
       'referer_list' => json_encode(array('google')),
       'ua_filter_empty' => false,
       'ua_filter' => 'allow',
       'ua_list' => json_encode(array('chrome')),
       'urlparams_filter_empty' => false,
       'urlparams_filter' => 'off',
       'urlparams_list_allow' => json_encode(array()),
       'urlparams_list_disallow' => json_encode(array('utc_action','test')),
       'time_filter' => 'disallow',
       'time_list' => json_encode(array('00_01','01_02','02_03','03_04','04_05','05_06'))
    ))
)
   Response example:

Array
(
    [action] => update
    [connected] => 1
    [clicklock] => Array
        (
            [success] => 1
            [tread] => TREAD_ID
        )

)
delete:

   Request code example:

$data = array(
    'key' => 'YOUR_API_KEY',
    'action' => 'delete',
    'data' => json_encode(array(
       'server' => json_encode($_SERVER),
       'tread' => 'TREAD_ID'
    ))
)
   Response example:

Array
(
    [action] => delete
    [connected] => 1
    [clicklock] => Array
        (
            [success] => 1
            [tread] => TREAD_ID
        )

)
getclicks:

   Request code example:

$data = array(
    'key' => 'YOUR_API_KEY',
    'action' => 'getclicks',
    'data' => json_encode(array(
       'server' => json_encode($_SERVER),
       'tread' => 'TREAD_ID',
       'date' => '20-04-2022',
       'page' => '1',
       'page_size' => '20'
    ))
)
   Response example:

Array
(
    [action] => getclicks
    [connected] => 1
    [clicklock] => Array
        (
            [success] => 1
            [date] => 20-04-2022			
            [all_clicks] => 2
            [filtered] => 2
            [offer] => 0
            [tread_id] => TREAD_ID
            [current_page] => 1
            [page_size] => 20
            [pages_counts] => 1
            [clicks] => Array
                (
                    [0] => Array
                        (
                            [filtered] => 1
                            [filter_concrete] => User-Agent
                            [page_type] => safe page
                            [page_url] => yandex.ru
                            [SERVER_ADDR] => 45.234.12.56
                            [SERVER_NAME] => test.domain.com
                            [REMOTE_ADDR] => 44.55.66.77
                            [HTTP_REFERER] => -
                            [USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
                            [QUERY_STRING] => -
                            [CITY] => Minsk
                            [COUNTRY] => Belarus
                            [COUNTRY_CODE] => BY
                            [ISP] => Republican Unitary Telecommunication Enterprise Beltelecom
                            [time] => 11:44:04
                            [day] => 20-04-2022							
                            [device_type] => desktop
                        )

                    [1] => Array
                        (
                            [filtered] => 1
                            [filter_concrete] => User-Agent
                            [page_type] => safe page
                            [page_url] => yandex.ru
                            [SERVER_ADDR] => 45.234.12.56
                            [SERVER_NAME] => test.domain.com
                            [REMOTE_ADDR] => 41.52.63.74
                            [HTTP_REFERER] => -
                            [USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36
                            [QUERY_STRING] => -
                            [CITY] => Minsk
                            [COUNTRY] => Belarus
                            [COUNTRY_CODE] => BY
                            [ISP] => Republican Unitary Telecommunication Enterprise Beltelecom
                            [time] => 11:32:01
                            [day] => 20-04-2022							
                            [device_type] => desktop
                        )

                )

        )

)
$_SERVER variable:

In every API method you can notice the presence of the php variable $_SERVER encoded in json. This is for your convenience, as most users use php to communicate with the clicklock service. But if you use another programming language, you will need to build this array manually.

You can read how it looks like here: https://www.php.net/manual/en/reserved.variables.server.php and to use clicklock in the system, you need only a few of its standard elements.

Below is a list of the elements required for normal processing of the API service:

REMOTE_ADDR Users IP address
SERVER_ADDR Server IP address
SERVER_NAME Domain name
HTTP_USER_AGENT User-Agent of user
HTTP_REFERER Referrer


To use it in API requests, just build an array with the given keys and corresponding values, for example, if you are making an application on Kotlin for Android, just put "Android" in HTTP_USER_AGENT, and so on.