Developerlar üçün API Referansı v3

Başlanır

Sistem tərəfindən emal edilən sorğular üçün API açarı tələb olunur. İstifadəçi qeydiyyatdan keçdikdən sonra bu istifadəçi üçün avtomatik olaraq API açarı yaradılır. API açarı hər sorğu ilə göndərilməlidir (aşağıdakı tam nümunəyə baxın). API açarı göndərilməyibsə və ya vaxtı keçibsə, xəta olacaq. Sui-istifadənin qarşısını almaq üçün API açarınızı məxfi saxladığınızdan əmin olun.

İdentifikasiyası

API sistemi ilə autentifikasiya etmək üçün hər sorğu ilə API açarınızı avtorizasiya nişanı kimi göndərməlisiniz. Aşağıda nümunə kodu görə bilərsiniz.

curl --location --request POST 'https://kec.az/api/url/add' \ 
--header 'Authorization: Bearer YOURAPIKEY
--header 'Content-Type: application/json' \ 
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/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);
Məzənnə Limiti

API-miz sabitliyini maksimum dərəcədə artırmaq üçün sorğularda artımdan qorunmaq üçün sürət məhdudlaşdırıcısına malikdir. Bizim tarif limitimiz hazırda 1 dəqiqədə 30 sorğu ilə məhdudlaşır.

Cavabın yanında bir neçə başlıq göndəriləcək və sorğu haqqında müxtəlif məlumatları müəyyən etmək üçün bunlar yoxlanıla bilər.

X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: TIMESTAMP
Cavab İşlənməsi

Bütün API cavabları standart olaraq JSON formatında qaytarılır. Bunu istifadə edilə bilən məlumatlara çevirmək üçün dilə uyğun olaraq müvafiq funksiyadan istifadə etmək lazımdır. PHP-də json_decode() funksiyası verilənləri obyektə (defolt) və ya massivə (ikinci parametri doğru olaraq təyin edin) çevirmək üçün istifadə edilə bilər. Səhv açarını yoxlamaq çox vacibdir, çünki bu, səhv olub-olmaması barədə məlumat verir. Başlıq kodunu da yoxlaya bilərsiniz.

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

Hesab

Hesab yarat
GET https://kec.az/api/account

Hesab haqqında məlumat əldə etmək üçün bu endpointə sorğu göndərə bilərsiniz və o, hesabdakı məlumatları qaytaracaq.

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

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/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 cavabı
{
    "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"
    }
}
Hesabı yeniləyin
PUT https://kec.az/api/account/update

Hesabdakı məlumatları yeniləmək üçün bu endpointə sorğu göndərə bilərsiniz və o, hesabdakı məlumatları yeniləyəcək.

curl --location --request PUT 'https://kec.az/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://kec.az/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 cavabı
{
    "error": 0,
    "message": "Account has been successfully updated."
}

Linklər


QR kodları

Bütün QR kodları sadalayın
GET https://kec.az/api/qr?limit=2&page=1

QR kodlarınızı API vasitəsilə əldə etmək üçün bu endpointdən istifadə edə bilərsiniz. Siz həmçinin məlumatları filtrləyə bilərsiniz (Əlavə məlumat üçün cədvələ baxın).

ParametrTəsvir
limit (optional) Per page data result
page (optional) Current page request
curl --location --request GET 'https://kec.az/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://kec.az/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 cavabı
{
    "error": "0",
    "data": {
        "result": 2,
        "perpage": 2,
        "currentpage": 1,
        "nextpage": 1,
        "maxpage": 1,
        "qrs": [
            {
                "id": 2,
                "link": "https:\/\/kec.az\/qr\/a2d5e",
                "scans": 0,
                "title": "Google",
                "date": "2020-11-10 18:01:43"
            },
            {
                "id": 1,
                "link": "https:\/\/kec.az\/qr\/b9edfe",
                "scans": 5,
                "title": "Google Canada",
                "date": "2020-11-10 18:00:25"
            }
        ]
    }
}
Tək QR kodu əldə edin
GET https://kec.az/api/qr/:id

API vasitəsilə tək QR kodu üçün təfərrüatlar əldə etmək üçün bu endpointdən istifadə edə bilərsiniz.

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

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/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 cavabı
{
    "error": 0,
    "details": {
        "id": 1,
        "link": "https:\/\/kec.az\/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
        }
    }
}
QR kodu yaradın
POST https://kec.az/api/qr/add

QR Kodunu qısaltmaq üçün siz POST sorğusu vasitəsilə JSON-da etibarlı məlumat göndərməlisiniz. Data aşağıda göstərildiyi kimi sorğunuzun xam orqanı kimi göndərilməlidir. Aşağıdakı nümunə göndərə biləcəyiniz bütün parametrləri göstərir, lakin sizdən hamısını göndərmək tələb olunmur (Əlavə məlumat üçün cədvələ baxın).

ParametrTəsvir
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) Hex color e.g. #ffffff
foreground (optional) Hex color e.g. #000000
logo (optional) Path to the logo either png or jpg
curl --location --request POST 'https://kec.az/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://kec.az/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 cavabı
{
    "error": 0,
    "id": 3,
    "link": "https:\/\/kec.az\/qr\/a58f79"
}
QR kodunu yeniləyin
PUT https://kec.az/api/qr/:id/update

QR Kodunu yeniləmək üçün siz PUT sorğusu vasitəsilə JSON-da etibarlı data göndərməlisiniz. Data aşağıda göstərildiyi kimi sorğunuzun xam orqanı kimi göndərilməlidir. Aşağıdakı nümunə göndərə biləcəyiniz bütün parametrləri göstərir, lakin sizdən hamısını göndərmək tələb olunmur (Əlavə məlumat üçün cədvələ baxın).

ParametrTəsvir
data (required) Data to be embedded inside the QR code. The data can be string or array depending on the type
background (optional) Hex color e.g. #ffffff
foreground (optional) Hex color e.g. #000000
logo (optional) Path to the logo either png or jpg
curl --location --request PUT 'https://kec.az/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://kec.az/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 cavabı
{
    "error": 0,
    "message": "QR has been updated successfully."
}
QR kodunu silin
DELETE https://kec.az/api/qr/:id/delete

QR kodunu silmək üçün SİL sorğusu göndərməlisiniz.

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

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/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 cavabı
{
    "error": 0,
    "message": "QR Code has been deleted successfully."
}

Planlar

bu endpointə yalnız admin imtiyazları olan istifadəçilər daxil ola bilər.

Bütün planları sadalayın
GET https://kec.az/api/plans

Platformada bütün planların siyahısını əldə edin.

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

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/api/plans",
    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 cavabı
{
    "error": 0,
    "data": [
        {
            "id": 2,
            "name": "Business",
            "free": false,
            "prices": {
                "monthly": 9.99,
                "yearly": 99.99,
                "lifetime": 999.99
            },
            "limits": {
                "links": 100,
                "clicks": 100000,
                "retention": 60,
                "custom": {
                    "enabled": "0"
                },
                "team": {
                    "enabled": "0",
                    "count": "0"
                },
                "splash": {
                    "enabled": "1",
                    "count": "5"
                },
                "overlay": {
                    "enabled": "1",
                    "count": "10"
                },
                "pixels": {
                    "enabled": "1",
                    "count": "10"
                },
                "domain": {
                    "enabled": "1",
                    "count": "1"
                },
                "multiple": {
                    "enabled": "0"
                },
                "alias": {
                    "enabled": "1"
                },
                "device": {
                    "enabled": "0"
                },
                "geo": {
                    "enabled": "0"
                },
                "bundle": {
                    "enabled": "0"
                },
                "parameters": {
                    "enabled": "0"
                },
                "export": {
                    "enabled": "0"
                },
                "api": {
                    "enabled": "0"
                }
            }
        },
        {
            "id": 1,
            "name": "Starter",
            "free": true,
            "prices": null,
            "limits": {
                "links": 10,
                "clicks": 1000,
                "retention": 7,
                "custom": {
                    "enabled": "0"
                },
                "team": {
                    "enabled": "0",
                    "count": "0"
                },
                "splash": {
                    "enabled": "0",
                    "count": "0"
                },
                "overlay": {
                    "enabled": "0",
                    "count": "10"
                },
                "pixels": {
                    "enabled": "0",
                    "count": "10"
                },
                "domain": {
                    "enabled": "0",
                    "count": "0"
                },
                "multiple": {
                    "enabled": "0"
                },
                "alias": {
                    "enabled": "0"
                },
                "device": {
                    "enabled": "0"
                },
                "geo": {
                    "enabled": "0"
                },
                "bundle": {
                    "enabled": "0"
                },
                "parameters": {
                    "enabled": "0"
                },
                "export": {
                    "enabled": "0"
                },
                "api": {
                    "enabled": "0"
                }
            }
        }
    ]
}
Bir istifadəçini bir plana abunə olun
PUT https://kec.az/api/plan/:planid/user/:userid

İstifadəçini plana abunə olmaq üçün plan id və istifadəçi id ilə bu endpointə PUT sorğusu göndərin. Abunəliyin növü və son istifadə tarixi dəqiqləşdirilməlidir. İstifadə müddəti göstərilməyibsə, tarix növünə uyğun olaraq düzəliş ediləcək.

ParametrTəsvir
type monthly | yearly | lifetime
expiration (isteğe bağlı) Planın bitmə tarixi, məs.2024-05-24 19:17:29
curl --location --request PUT 'https://kec.az/api/plan/:planid/user/:userid' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "monthly",
    "expiration": "2024-05-24 19:17:29"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/api/plan/:planid/user/:userid",
    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": "monthly",
    "expiration": "2024-05-24 19:17:29"
}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server cavabı
{
    "error": 0,
    "message": "User has been subscribed to this plan."
}

İstifadəçilər

bu endpointə yalnız admin imtiyazları olan istifadəçilər daxil ola bilər.

Bütün istifadəçiləri siyahıya salın
GET https://kec.az/api/users?filter=free

Platformadakı bütün istifadəçilərin siyahısını əldə edin. Məlumat url-də filtr parametri göndərməklə filtrlənə bilər.

ParametrTəsvir
filter admin | free | pro
curl --location --request GET 'https://kec.az/api/users?filter=free' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/api/users?filter=free",
    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 cavabı
{
    "error": 0,
    "data": [
        {
            "id": 2,
            "email": "sample2@domain.com",
            "username": "sample2user",
            "avatar": "https:\\\/\\\/domain.com\/content\/avatar2.png",
            "status": "free",
            "planid": 1,
            "expires": null,
            "registered": "2020-11-10 18:01:43"
        },
        {
            "id": 1,
            "email": "sample@domain.com",
            "username": "sampleuser",
            "avatar": "https:\\\/\\\/domain.com\/content\/avatar.png",
            "status": "pro",
            "planid": 2,
            "expires": "2022-11-15 15:00:00",
            "registered": "2020-11-10 18:01:43"
        }
    ]
}
İstifadəçi yaradın
POST https://kec.az/api/user/add

İstifadəçi yaratmaq üçün bu endpointdən istifadə edin və aşağıdakı məlumatları JSON kimi göndərin.

ParametrTəsvir
username (required) User's username. Needs to be valid.
email (required) User's email. Needs to be valid.
password (required) User's password. Minimum 5 characters.
planid (optional) Premium plan. This can be found in the admin panel.
expiration (optional) Membership expiration example 2020-12-26 12:00:00
curl --location --request POST 'https://kec.az/api/user/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "username": "user",
    "password": "1234567891011",
    "email": "demo@yourwebsite.com",
    "planid": 1,
    "expiration": "2020-11-20 11:00:00"
}'
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/api/user/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 => '{
    "username": "user",
    "password": "1234567891011",
    "email": "demo@yourwebsite.com",
    "planid": 1,
    "expiration": "2020-11-20 11:00:00"
}',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
Server cavabı
{
    "error": 0,
    "message": "User has been registered.",
    "data": {
        "id": 3,
        "email": "demo@yourwebsite.com",
        "username": "user"
    }
}
İstifadəçini silin
DELETE https://kec.az/api/user/:id/delete

İstifadəçini silmək üçün bu endpointdən istifadə edin.

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

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://kec.az/api/user/: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 cavabı
{
    "error": 0,
    "message": "User has been deleted."
}