Stat API: Difference between revisions
|  (Marked this version for translation) | No edit summary | ||
| Line 2: | Line 2: | ||
| <translate> | <translate> | ||
| <!--T:1--> | <!--T:1--> | ||
| '''[https://kaminari.click/user  | '''[https://kaminari.click/user How to obtain the token]'''   | ||
| <!--T:2--> | <!--T:2--> | ||
| '''[https://kaminari.click/api/doc  | '''[https://kaminari.click/api/doc Detailed description of the requests and responses for each endpoint].''' | ||
| <!--T:3--> | <!--T:3--> | ||
| === ''' | === '''Endpoint list:''' === | ||
| {| class="wikitable" | {| class="wikitable" | ||
| ! Method !! Path !! Description | ! Method !! Path !! Description | ||
| |- | |- | ||
| | OPTIONS || /api/stat/get ||  | | OPTIONS || /api/stat/get || Returns all possible groupings and metrics grouped by categories | ||
| |- | |- | ||
| | POST || /api/stat/filter ||  | | POST || /api/stat/filter || Obtaining data for filter | ||
| |- | |- | ||
| | POST || /api/stat/data ||  | | POST || /api/stat/data || Obtaining data for the table | ||
| |} | |} | ||
| Line 22: | Line 22: | ||
| === '''OPTIONS /api/stat/get''' === | === '''OPTIONS /api/stat/get''' === | ||
| ===== Request ===== | ===== Request ===== | ||
| No parameters | |||
| <!--T:5--> | <!--T:5--> | ||
| Line 43: | Line 43: | ||
| |data.groups | |data.groups | ||
| |{ groupTitle: ['''<item>''', …] } | |{ groupTitle: ['''<item>''', …] } | ||
| | | |See bellow description '''<item>''' | ||
| |- | |- | ||
| |data.metrics | |data.metrics | ||
| |{ metricTitle: ['''<item>''', …] } | |{ metricTitle: ['''<item>''', …] } | ||
| | | |See bellow description '''<item>''' | ||
| |- | |- | ||
| |data.periods | |data.periods | ||
| Line 54: | Line 54: | ||
| |} | |} | ||
| {| class="wikitable mw-collapsible" | {| class="wikitable mw-collapsible" | ||
| |+ | |+Description '''<item>''' | ||
| !Key | !Key | ||
| !Type | !Type | ||
| Line 62: | Line 62: | ||
| |String | |String | ||
| |<groupTitle или metricTitle> | |<groupTitle или metricTitle> | ||
| +  | + underscore | ||
| <!--T:6--> | <!--T:6--> | ||
| + < | + <metric or group's name> (groupTitle_id) | ||
| <!--T:7--> | <!--T:7--> | ||
| Line 71: | Line 71: | ||
| |icon | |icon | ||
| |<code>date</code><nowiki> | </nowiki><code>text</code><nowiki> | </nowiki><code>number</code> | |<code>date</code><nowiki> | </nowiki><code>text</code><nowiki> | </nowiki><code>number</code> | ||
| | | |Icon of the type | ||
| |- | |- | ||
| |sources | |sources | ||
| Line 83: | Line 83: | ||
| |filterSync | |filterSync | ||
| |Boolean * | |Boolean * | ||
| |<code>list</code>  | |<code>list</code> with server-side search | ||
| |} | |} | ||
| Line 96: | Line 96: | ||
| |id | |id | ||
| |String | |String | ||
| | | |Filter name | ||
| |- | |- | ||
| |searchQuery | |searchQuery | ||
| |String | |String | ||
| | | |Search query | ||
| |} | |} | ||
| Line 147: | Line 147: | ||
| |perPage | |perPage | ||
| |Number | |Number | ||
| | | |Default value 50 | ||
| |- | |- | ||
| |page | |page | ||
| |Number | |Number | ||
| | | |Default value 1 | ||
| |- | |- | ||
| |metrics | |metrics | ||
| Line 161: | Line 161: | ||
| |dateFrom | |dateFrom | ||
| |String | |String | ||
| | | |Date in the format Y-m-d | ||
| |- | |- | ||
| |dateTo | |dateTo | ||
| |String | |String | ||
| | | |Date in the format Y-m-d | ||
| |- | |- | ||
| |filters.filters | |filters.filters | ||
| Line 181: | Line 181: | ||
| |groups | |groups | ||
| |[String] | |[String] | ||
| |''' | |'''Allowed values:'''   | ||
| time_hour, time_day, time_week. time_month, time_dateTime, sub_integration, sub_botType, sub_tbReason, sub_pid, sub_clickId, sub_placementId, sub_sspName, sub_domainName, sub_referer, sub_clickLink, sub_1... | time_hour, time_day, time_week. time_month, time_dateTime, sub_integration, sub_botType, sub_tbReason, sub_pid, sub_clickId, sub_placementId, sub_sspName, sub_domainName, sub_referer, sub_clickLink, sub_1...7, geo_language, geo_timezone, geo_country, geo_city, geo_provider, geo_ip, 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 | ||
| Line 196: | Line 196: | ||
| |id | |id | ||
| |String | |String | ||
| |''' | |'''Allowed values:''' | ||
| time_hour, time_day, time_week, time_month, sub_integration, sub_botType, sub_referer, sub_1... | time_hour, time_day, time_week, time_month, sub_integration, sub_botType, sub_referer, sub_1...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, 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 | ||
| |- | |- | ||
| |type | |type | ||
| Line 208: | Line 208: | ||
| |} | |} | ||
| {| class="wikitable mw-collapsible" | {| class="wikitable mw-collapsible" | ||
| |+ | |+Description <compare> | ||
| !Key | !Key | ||
| !Type | !Type | ||
| Line 215: | Line 215: | ||
| |dateFrom | |dateFrom | ||
| |String | |String | ||
| | | |Date in the format Y-m-d | ||
| |- | |- | ||
| |dateTo | |dateTo | ||
| |String | |String | ||
| | | |Date in the format Y-m-d | ||
| |- | |- | ||
| |mode | |mode | ||
| Line 251: | Line 251: | ||
| |data.rows | |data.rows | ||
| |['''<row>'''] | |['''<row>'''] | ||
| | | |Description of table rows | ||
| |- | |- | ||
| |data.totalRows | |data.totalRows | ||
| |Number | |Number | ||
| | | |Total number of items in the table | ||
| |- | |- | ||
| |data.total | |data.total | ||
| |'''<row>''' | |'''<row>''' | ||
| | | |Sum for each column considering invisible rows | ||
| |- | |- | ||
| |data.page | |data.page | ||
| |Number | |Number | ||
| | | |Current page | ||
| |- | |- | ||
| |data.perPage | |data.perPage | ||
| |Number | |Number | ||
| | | |Number of items per page | ||
| |- | |- | ||
| |data.columns | |data.columns | ||
| |['''<column>'''] | |['''<column>'''] | ||
| | | |Description of columns | ||
| |} | |} | ||
| {| class="wikitable mw-collapsible" | {| class="wikitable mw-collapsible" | ||
| |+ | |+ | ||
| Description <row> | |||
| !Key | !Key | ||
| !Type | !Type | ||
| Line 298: | Line 298: | ||
| {| class="wikitable mw-collapsible" | {| class="wikitable mw-collapsible" | ||
| |+ | |+ | ||
| Description <column> | |||
| !Key | !Key | ||
| !Type | !Type | ||
| Line 305: | Line 305: | ||
| |field | |field | ||
| |String | |String | ||
| |ID  | |ID of the metric or group | ||
| |- | |- | ||
| |type | |type | ||
| Line 313: | Line 313: | ||
| |sortable | |sortable | ||
| |Boolean | |Boolean | ||
| | | |Sortable or not | ||
| |- | |- | ||
| |unit | |unit | ||
| |<nowiki>String | null</nowiki> | |<nowiki>String | null</nowiki> | ||
| | | |Unit of measurement | ||
| For example, % for percentage columns | |||
| |} | |} | ||
| === ''' | === '''Request examples''' === <!--T:11--> | ||
| <!--T:12--> | <!--T:12--> | ||
Revision as of 09:43, 18 December 2023
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 | 
OPTIONS /api/stat/get
Request
No parameters
Response
| 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' ] | |
| 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 | см. Описание filterType | 
| filterSync | Boolean * | listwith server-side search | 
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" } | 
POST /api/stat/data
| Key | Type | Description | 
|---|---|---|
| id | String | |
| name | String | |
| perPage | Number | Default value 50 | 
| page | Number | Default value 1 | 
| metrics | [String] | |
| 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 | От -12 до +12 | 
| groups | [String] | Allowed values: time_hour, time_day, time_week. time_month, time_dateTime, sub_integration, sub_botType, sub_tbReason, sub_pid, sub_clickId, sub_placementId, sub_sspName, sub_domainName, sub_referer, sub_clickLink, sub_1...7, geo_language, geo_timezone, geo_country, geo_city, geo_provider, geo_ip, 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> | |
| Key | Type | Description | 
|---|---|---|
| id | String | Allowed values: time_hour, time_day, time_week, time_month, sub_integration, sub_botType, sub_referer, sub_1...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, 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 | 
| type | String | |
| range | {from: Number, to: Number} | 
| 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 | 
| 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 | 
| Key | Type | Description | 
|---|---|---|
| value | String | |
| diff | String | null | |
| percent | Number | null | |
| compare_value | String | null | 
| 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)