Sampled Mappings
curl --request GET \
--url https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings', 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}/sample/mappings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body[
{
"mapping_id": "62db1e99-7e0e-46c3-802b-1b13a0ebdb7b",
"records": [
{
"input": {
"idType": "idType1",
"idValue": "idValue1"
},
"output": {
"unique_id_95b79302_0f80_4cfd_9e43_ea26aa13b9a7": {
"type": "idType1"
}
}
},
{
"input": {
"idType": "idType2",
"idValue": "idValue2"
},
"output": {
"unique_id_95b79302_0f80_4cfd_9e43_ea26aa13b9a7": {
"type": "idType2"
}
}
}
]
},
{
"mapping_id": "f2d14fb8-2c9b-4ade-851e-388bfcd942f1",
"records": [
{
"input": {
"idType": "idType1",
"idValue": "idValue1"
},
"output": {
"unique_id_322d2d83_d8ec_4808_80be_66d08e446de5": {
"value": "idValue1"
}
}
},
{
"input": {
"idType": "idType2",
"idValue": "idValue2"
},
"output": {
"unique_id_322d2d83_d8ec_4808_80be_66d08e446de5": {
"value": "idValue2"
}
}
}
]
}
]{
"type": null,
"title": "Failed to Parse Query",
"status": 400,
"detail": "Invalid query format.",
"instance": "/nql/validate",
"log_id": "c06fea02-0950-45c6-aaff-07ab07c0d04c",
"debug": null
}Dataset Samples
Sampled Mappings
Returns sampled dataset after attribute mapping for a given mapping_id
This endpoint should be used when mapping exist.
A response is a list of JSON objects, where every object will have an input field, that represents the original key/value pairs from the dataset, and the output filed that will contain mapped fields where the key will be attribute name, and value will be JSON object of key/value pairs.
GET
/
datasets
/
{dataset_id}
/
sample
/
mappings
Sampled Mappings
curl --request GET \
--url https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings', 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}/sample/mappings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/datasets/{dataset_id}/sample/mappings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body[
{
"mapping_id": "62db1e99-7e0e-46c3-802b-1b13a0ebdb7b",
"records": [
{
"input": {
"idType": "idType1",
"idValue": "idValue1"
},
"output": {
"unique_id_95b79302_0f80_4cfd_9e43_ea26aa13b9a7": {
"type": "idType1"
}
}
},
{
"input": {
"idType": "idType2",
"idValue": "idValue2"
},
"output": {
"unique_id_95b79302_0f80_4cfd_9e43_ea26aa13b9a7": {
"type": "idType2"
}
}
}
]
},
{
"mapping_id": "f2d14fb8-2c9b-4ade-851e-388bfcd942f1",
"records": [
{
"input": {
"idType": "idType1",
"idValue": "idValue1"
},
"output": {
"unique_id_322d2d83_d8ec_4808_80be_66d08e446de5": {
"value": "idValue1"
}
}
},
{
"input": {
"idType": "idType2",
"idValue": "idValue2"
},
"output": {
"unique_id_322d2d83_d8ec_4808_80be_66d08e446de5": {
"value": "idValue2"
}
}
}
]
}
]{
"type": null,
"title": "Failed to Parse Query",
"status": 400,
"detail": "Invalid query format.",
"instance": "/nql/validate",
"log_id": "c06fea02-0950-45c6-aaff-07ab07c0d04c",
"debug": null
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Unique identifier for a dataset.
Query Parameters
The number of rows to sample from the dataset.
Required range:
x <= 1000Response
OK
Example:
[ { "mapping_id": "62db1e99-7e0e-46c3-802b-1b13a0ebdb7b", "records": [ { "input": { "idType": "idType1", "idValue": "idValue1" }, "output": { "unique_id_95b79302_0f80_4cfd_9e43_ea26aa13b9a7": { "type": "idType1" } } }, { "input": { "idType": "idType2", "idValue": "idValue2" }, "output": { "unique_id_95b79302_0f80_4cfd_9e43_ea26aa13b9a7": { "type": "idType2" } } } ] }, { "mapping_id": "f2d14fb8-2c9b-4ade-851e-388bfcd942f1", "records": [ { "input": { "idType": "idType1", "idValue": "idValue1" }, "output": { "unique_id_322d2d83_d8ec_4808_80be_66d08e446de5": { "value": "idValue1" } } }, { "input": { "idType": "idType2", "idValue": "idValue2" }, "output": { "unique_id_322d2d83_d8ec_4808_80be_66d08e446de5": { "value": "idValue2" } } } ] } ]
Was this page helpful?
⌘I

