Stat API: Difference between revisions

From Wiki Kaminari Click
No edit summary
Line 20: Line 20:


<!--T:4-->
<!--T:4-->
=== '''OPTIONS /api/stat/get''' ===
== How to get all possible groupings and metrics grouped by categories ==
===== Request =====
To obtain such data use this URL
 
{| class="wikitable"
! Method !! Path
|-
| OPTIONS || /api/stat/get
|}
 
==== Request ====
No parameters
No parameters


<!--T:5-->
<!--T:5-->
===== Response =====
==== Response ====
<div class="mw-collapsible mw-collapsed" style="width:80%; overflow:auto;">
    Response example:
    <div class="mw-collapsible-content">
        <code>fdfdsf</code>
    </div>
</div>
 
{| class="wikitable mw-collapsible"
{| class="wikitable mw-collapsible"
! Key !! Type !! Description
! Key !! Type !! Description
Line 87: Line 102:


<!--T:8-->
<!--T:8-->
=== '''POST /api/stat/filter''' ===
== How to get all possible values for filter ==
===== Request =====
To obtain values  use this URL
 
{| class="wikitable"
! Method !! Path
|-
| POST || /api/stat/filter
|}
 
==== Request ====
{| class="wikitable mw-collapsible"
{| class="wikitable mw-collapsible"
!Key
!Key
Line 104: Line 127:


<!--T:9-->
<!--T:9-->
===== Response =====
==== Response ====
{| class="wikitable mw-collapsible"
{| class="wikitable mw-collapsible"
!Key
!Key
Line 130: Line 153:


<!--T:10-->
<!--T:10-->
=== '''POST /api/stat/data''' ===
== How to get data for the table ==
To obtain such data use this URL
 
{| class="wikitable"
! Method !! Path
|-
| POST || /api/stat/data
|}
 
==== Request ====
{| class="wikitable mw-collapsible"
{| class="wikitable mw-collapsible"
|+Request
|+Request
Line 322: Line 354:
|}
|}


=== '''Request examples''' === <!--T:11-->
== '''Request examples''' == <!--T:11-->


<!--T:12-->
<!--T:12-->
==== CURL ====
=== CURL ===
<pre>
<pre>
curl -X 'OPTIONS' \  '<nowiki>https://kaminari.click/api/stat/get'</nowiki> \  -H 'accept: */*' 'Authorization: Bearer <YOUR API_TOKEN>'
curl -X 'OPTIONS' \  '<nowiki>https://kaminari.click/api/stat/get'</nowiki> \  -H 'accept: */*' 'Authorization: Bearer <YOUR API_TOKEN>'
Line 341: Line 373:


<!--T:15-->
<!--T:15-->
==== NodeJS ====
=== NodeJS ===
  const https = require('https');
  const https = require('https');
   
   
Line 373: Line 405:


<!--T:16-->
<!--T:16-->
==== PHP ====
=== PHP ===
  <?php
  <?php
  $ch = curl_init();
  $ch = curl_init();
Line 388: Line 420:


<!--T:17-->
<!--T:17-->
==== Python ====
=== Python ===
  import requests
  import requests
   
   

Revision as of 12:20, 10 April 2024

Other languages:

How to obtain the token

Detailed description of the requests and responses for each endpoint.

Endpoint list:

Method Path Description
OPTIONS /api/stat/get Returns all possible groupings and metrics grouped by categories
POST /api/stat/filter Obtaining data for filter
POST /api/stat/data Obtaining data for the table

How to get all possible groupings and metrics grouped by categories

To obtain such data use this URL

Method Path
OPTIONS /api/stat/get

Request

No parameters

Response

   Response example:
       fdfdsf
Key Type Description
success Boolean
code
msg
data
data.groups { groupTitle: [<item>, …] } See bellow description <item>
data.metrics { metricTitle: [<item>, …] } See bellow description <item>
data.periods [ 'today', 'yesterday', '7days', 'currentWeek', 'month' ]
Description <item>
Key Type Description
id String <groupTitle или metricTitle>

+ underscore

+ <metric or group's name> (groupTitle_id)

icon date | text | number Icon of the type
sources [Number]
filterType range | list | value | value_like | value_combined See description filterType
filterSync Boolean * list with server-side search

How to get all possible values for filter

To obtain values use this URL

Method Path
POST /api/stat/filter

Request

Key Type Description
id String Filter name
searchQuery String Search query

Response

Key Type Description
success Boolean
code
msg
data
data.items [{ id: Number, label: String }] { id: 1, label: "Param A" }

How to get data for the table

To obtain such data use this URL

Method Path
POST /api/stat/data

Request

Request
Key Type Description
id String
name String
perPage Number Default value 50
page Number Default value 1
metrics [String] Allowed values:

summary_totalVisits, summary_uniqUsers, summary_uniqUsersPc, summary_validVisits, summary_validVisitsPc, summary_techLosses, summary_techLossesPc, bots_total, bots_totalPc, bots_crawler, bots_crawlerPc, bots_spoofing, bots_spoofingPc, bots_automated, bots_automatedPc, bots_iFrame, bots_iFramePc, bots_badReputationIp, bots_badReputationIpPc, bots_blocked, bots_blockedPc, lowQuality_total, lowQuality_totalPc, lowQuality_proxy, lowQuality_proxyPc, lowQuality_spoofing, lowQuality_spoofingPc, lowQuality_automated, lowQuality_automatedPc, lowQuality_trafficCheats, lowQuality_trafficCheatsPc, feature_adBlock, feature_adBlockPc, feature_isMobile, feature_isMobilePc, feature_webView, feature_webViewPc, feature_iFrame, feature_iFramePc, feature_pushNotifications, feature_pushNotificationsPc. Those values are allowed only if option Behavioral analysis is turned on for you integration: beAn_pageVisibility, beAn_pageVisibilityPc, beAn_pageActivity, beAn_pageActivityPc, beAn_pageAcceptance, beAn_pageAcceptancePc

filters
dateFrom String Date in the format Y-m-d
dateTo String Date in the format Y-m-d
filters.filters <filters>
period today | yesterday | currentWeek | 7days| month | null
timezone Number From -12 to +12
groups [String] Allowed values:

time_hour, time_day, time_week, time_month, time_dateTime, sub_integration, sub_botType, sub_referer, sub_1, sub_2, sib_3, sub_4, sub_5, sub_6, sub_7, geo_language, geo_timezone, geo_country, geo_city, geo_provider, device_browser, device_browserEngine, device_os, device_realOs, device_device, device_type, device_connectionType, device_useragent, screen_width, screen_height, screen_orientation, screen_pixelDensity

compare <compare>
Description <filters>
Key Type Description
id String Allowed values:

time_hour, time_day, time_week, time_month, sub_integration, sub_botType, sub_referer, sub_1, sub_2, sib_3, sub_4, sub_5, sub_6, sub_7, geo_language, geo_timezone, geo_country, geo_city, geo_provider, device_browser, device_browserEngine, device_os, device_realOs, device_device, device_type, device_connectionType, device_useragent, screen_width, screen_height, screen_orientation, screen_pixelDensity, summary_totalVisits, summary_uniqUsers, summary_uniqUsersPc, summary_validVisits, summary_validVisitsPc, summary_techLosses, summary_techLossesPc, bots_total, bots_totalPc, bots_crawler, bots_crawlerPc, bots_spoofing, bots_spoofingPc, bots_automated, bots_automatedPc, bots_iFrame, bots_iFramePc, bots_badReputationIp, bots_badReputationIpPc, bots_blocked, bots_blockedPc, lowQuality_total, lowQuality_totalPc, lowQuality_proxy, lowQuality_proxyPc, lowQuality_spoofing, lowQuality_spoofingPc, lowQuality_automated, lowQuality_automatedPc, lowQuality_trafficCheats, lowQuality_trafficCheatsPc, feature_adBlock, feature_adBlockPc, feature_isMobile, feature_isMobilePc, feature_webView, feature_webViewPc, feature_iFrame, feature_iFramePc, feature_pushNotifications, feature_pushNotificationsPc. Those values are allowed only if option Behavioral analysis is turned on for you integration: beAn_pageVisibility, beAn_pageVisibilityPc, beAn_pageActivity, beAn_pageActivityPc, beAn_pageAcceptance, beAn_pageAcceptancePc

type String
range {from: Number, to: Number}
Description <compare>
Key Type Description
dateFrom String Date in the format Y-m-d
dateTo String Date in the format Y-m-d
mode compare_value | diff | percent
sort Boolean
Response
Key Type Description
success Boolean
code
msg
data
data.rows [<row>] Description of table rows
data.totalRows Number Total number of items in the table
data.total <row> Sum for each column considering invisible rows
data.page Number Current page
data.perPage Number Number of items per page
data.columns [<column>] Description of columns
Description <row>
Key Type Description
value String
diff String | null
percent Number | null
compare_value String | null
Description <column>
Key Type Description
field String ID of the metric or group
type string | number | float
sortable Boolean Sortable or not
unit String | null Unit of measurement

For example, % for percentage columns

Request examples

CURL

curl -X 'OPTIONS' \  'https://kaminari.click/api/stat/get' \  -H 'accept: */*' 'Authorization: Bearer <YOUR API_TOKEN>'
curl -X POST 'https://kaminari.click/api/stat/filter' -d '{"id":"device_type","searchQuery":"","dateFrom":"2023-01-05","dateTo":"2023-01-05"}' -H 'content-type: application/json' -H 'Authorization: Bearer <YOUR API_TOKEN>'
curl -X POST 'https://kaminari.click/api/stat/data' -d '{"id":null,"name":null,"groups":["time_day"],"metrics":["summary_totalVisits"],"filters":{"filters":[],"period":null,"timezone":0,"dateTo":"2022-08-15","dateFrom":"2022-08-15"},"compare":null}' -H 'content-type: application/json' -H 'Authorization: Bearer <YOUR API_TOKEN>'

NodeJS

const https = require('https');

const options = {
    host: 'kaminari.click',
    port: 443,
    path: '/api/stat/get',
    method: 'POST',
    headers: { 'Authorization': 'Bearer <YOUR API_TOKEN>' }
};

https
    .get(options, (resp) => {
        let data = '';

        resp.on('data', (chunk) => {
            data += chunk;
        });

        resp.on('end', () => {
            try {
                data = JSON.parse(data);
            } catch {
                console.log(data);
            }
        });
    })
    .on("error", (err) => {
        console.log("Error: " + err.message);
    });

PHP

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://kaminari.click/api/stat/get');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'OPTIONS');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: */*',
]);

$response = curl_exec($ch);

curl_close($ch);

Python

import requests

headers = {
    'accept': '*/*',
}

response = requests.options('https://kaminari.click/api/stat/get', headers=headers)
response = requests.options('http://Authorization: Bearer <YOUR API_TOKEN>', headers=headers)