Create or Update detailed statistics
curl --request PUT \
--url https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"records": [
{
"column_name": "idType",
"approx_count_distinct": 2,
"count_distinct": null,
"histogram": {
"values": {
"adid": {
"absolute": 2,
"ratio": 0.5
},
"idfa": {
"absolute": 2,
"ratio": 0.5
}
},
"number_of_bins": 2
},
"mean": null,
"standard_deviation": null,
"completeness": null,
"observed_types": null
},
{
"column_name": "idValue",
"approx_count_distinct": 20000,
"count_distinct": null,
"histogram": null,
"mean": null,
"standard_deviation": null,
"completeness": null,
"observed_types": null
}
]
}
'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats"
payload = { "records": [
{
"column_name": "idType",
"approx_count_distinct": 2,
"count_distinct": None,
"histogram": {
"values": {
"adid": {
"absolute": 2,
"ratio": 0.5
},
"idfa": {
"absolute": 2,
"ratio": 0.5
}
},
"number_of_bins": 2
},
"mean": None,
"standard_deviation": None,
"completeness": None,
"observed_types": None
},
{
"column_name": "idValue",
"approx_count_distinct": 20000,
"count_distinct": None,
"histogram": None,
"mean": None,
"standard_deviation": None,
"completeness": None,
"observed_types": None
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
records: [
{
column_name: 'idType',
approx_count_distinct: 2,
count_distinct: null,
histogram: {
values: {adid: {absolute: 2, ratio: 0.5}, idfa: {absolute: 2, ratio: 0.5}},
number_of_bins: 2
},
mean: null,
standard_deviation: null,
completeness: null,
observed_types: null
},
{
column_name: 'idValue',
approx_count_distinct: 20000,
count_distinct: null,
histogram: null,
mean: null,
standard_deviation: null,
completeness: null,
observed_types: null
}
]
})
};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'records' => [
[
'column_name' => 'idType',
'approx_count_distinct' => 2,
'count_distinct' => null,
'histogram' => [
'values' => [
'adid' => [
'absolute' => 2,
'ratio' => 0.5
],
'idfa' => [
'absolute' => 2,
'ratio' => 0.5
]
],
'number_of_bins' => 2
],
'mean' => null,
'standard_deviation' => null,
'completeness' => null,
'observed_types' => null
],
[
'column_name' => 'idValue',
'approx_count_distinct' => 20000,
'count_distinct' => null,
'histogram' => null,
'mean' => null,
'standard_deviation' => null,
'completeness' => null,
'observed_types' => null
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats"
payload := strings.NewReader("{\n \"records\": [\n {\n \"column_name\": \"idType\",\n \"approx_count_distinct\": 2,\n \"count_distinct\": null,\n \"histogram\": {\n \"values\": {\n \"adid\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n },\n \"idfa\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n }\n },\n \"number_of_bins\": 2\n },\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n },\n {\n \"column_name\": \"idValue\",\n \"approx_count_distinct\": 20000,\n \"count_distinct\": null,\n \"histogram\": null,\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"records\": [\n {\n \"column_name\": \"idType\",\n \"approx_count_distinct\": 2,\n \"count_distinct\": null,\n \"histogram\": {\n \"values\": {\n \"adid\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n },\n \"idfa\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n }\n },\n \"number_of_bins\": 2\n },\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n },\n {\n \"column_name\": \"idValue\",\n \"approx_count_distinct\": 20000,\n \"count_distinct\": null,\n \"histogram\": null,\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"records\": [\n {\n \"column_name\": \"idType\",\n \"approx_count_distinct\": 2,\n \"count_distinct\": null,\n \"histogram\": {\n \"values\": {\n \"adid\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n },\n \"idfa\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n }\n },\n \"number_of_bins\": 2\n },\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n },\n {\n \"column_name\": \"idValue\",\n \"approx_count_distinct\": 20000,\n \"count_distinct\": null,\n \"histogram\": null,\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Datasets
Create or Update detailed statistics
Create or Update detailed statistics. Detailed statistics are collected for datasets belonging to the Narrative Data Plane, but uploading these stats is necessary for non-Narrative data planes, since Narrative does not have access to the data to compute these statistics.
PUT
/
datasets
/
{dataset_id}
/
columns-stats
Create or Update detailed statistics
curl --request PUT \
--url https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"records": [
{
"column_name": "idType",
"approx_count_distinct": 2,
"count_distinct": null,
"histogram": {
"values": {
"adid": {
"absolute": 2,
"ratio": 0.5
},
"idfa": {
"absolute": 2,
"ratio": 0.5
}
},
"number_of_bins": 2
},
"mean": null,
"standard_deviation": null,
"completeness": null,
"observed_types": null
},
{
"column_name": "idValue",
"approx_count_distinct": 20000,
"count_distinct": null,
"histogram": null,
"mean": null,
"standard_deviation": null,
"completeness": null,
"observed_types": null
}
]
}
'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats"
payload = { "records": [
{
"column_name": "idType",
"approx_count_distinct": 2,
"count_distinct": None,
"histogram": {
"values": {
"adid": {
"absolute": 2,
"ratio": 0.5
},
"idfa": {
"absolute": 2,
"ratio": 0.5
}
},
"number_of_bins": 2
},
"mean": None,
"standard_deviation": None,
"completeness": None,
"observed_types": None
},
{
"column_name": "idValue",
"approx_count_distinct": 20000,
"count_distinct": None,
"histogram": None,
"mean": None,
"standard_deviation": None,
"completeness": None,
"observed_types": None
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
records: [
{
column_name: 'idType',
approx_count_distinct: 2,
count_distinct: null,
histogram: {
values: {adid: {absolute: 2, ratio: 0.5}, idfa: {absolute: 2, ratio: 0.5}},
number_of_bins: 2
},
mean: null,
standard_deviation: null,
completeness: null,
observed_types: null
},
{
column_name: 'idValue',
approx_count_distinct: 20000,
count_distinct: null,
histogram: null,
mean: null,
standard_deviation: null,
completeness: null,
observed_types: null
}
]
})
};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'records' => [
[
'column_name' => 'idType',
'approx_count_distinct' => 2,
'count_distinct' => null,
'histogram' => [
'values' => [
'adid' => [
'absolute' => 2,
'ratio' => 0.5
],
'idfa' => [
'absolute' => 2,
'ratio' => 0.5
]
],
'number_of_bins' => 2
],
'mean' => null,
'standard_deviation' => null,
'completeness' => null,
'observed_types' => null
],
[
'column_name' => 'idValue',
'approx_count_distinct' => 20000,
'count_distinct' => null,
'histogram' => null,
'mean' => null,
'standard_deviation' => null,
'completeness' => null,
'observed_types' => null
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats"
payload := strings.NewReader("{\n \"records\": [\n {\n \"column_name\": \"idType\",\n \"approx_count_distinct\": 2,\n \"count_distinct\": null,\n \"histogram\": {\n \"values\": {\n \"adid\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n },\n \"idfa\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n }\n },\n \"number_of_bins\": 2\n },\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n },\n {\n \"column_name\": \"idValue\",\n \"approx_count_distinct\": 20000,\n \"count_distinct\": null,\n \"histogram\": null,\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"records\": [\n {\n \"column_name\": \"idType\",\n \"approx_count_distinct\": 2,\n \"count_distinct\": null,\n \"histogram\": {\n \"values\": {\n \"adid\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n },\n \"idfa\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n }\n },\n \"number_of_bins\": 2\n },\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n },\n {\n \"column_name\": \"idValue\",\n \"approx_count_distinct\": 20000,\n \"count_distinct\": null,\n \"histogram\": null,\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/columns-stats")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"records\": [\n {\n \"column_name\": \"idType\",\n \"approx_count_distinct\": 2,\n \"count_distinct\": null,\n \"histogram\": {\n \"values\": {\n \"adid\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n },\n \"idfa\": {\n \"absolute\": 2,\n \"ratio\": 0.5\n }\n },\n \"number_of_bins\": 2\n },\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n },\n {\n \"column_name\": \"idValue\",\n \"approx_count_distinct\": 20000,\n \"count_distinct\": null,\n \"histogram\": null,\n \"mean\": null,\n \"standard_deviation\": null,\n \"completeness\": null,\n \"observed_types\": null\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"error": "Unauthorized",
"error_description": "You are not authorized to use this endpoint."
}Was this page helpful?
⌘I

