Fetch many data-streams
curl --request POST \
--url https://api-dev.narrative.io/data-stream/ids \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ids": [
"cddfface-beda-4f84-ab22-a9933fad3992",
"6460aa19-ddb2-424c-a54e-0f80b82b1698"
]
}
'import requests
url = "https://api-dev.narrative.io/data-stream/ids"
payload = { "ids": ["cddfface-beda-4f84-ab22-a9933fad3992", "6460aa19-ddb2-424c-a54e-0f80b82b1698"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ids: ['cddfface-beda-4f84-ab22-a9933fad3992', '6460aa19-ddb2-424c-a54e-0f80b82b1698']
})
};
fetch('https://api-dev.narrative.io/data-stream/ids', 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/data-stream/ids",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ids' => [
'cddfface-beda-4f84-ab22-a9933fad3992',
'6460aa19-ddb2-424c-a54e-0f80b82b1698'
]
]),
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/data-stream/ids"
payload := strings.NewReader("{\n \"ids\": [\n \"cddfface-beda-4f84-ab22-a9933fad3992\",\n \"6460aa19-ddb2-424c-a54e-0f80b82b1698\"\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-dev.narrative.io/data-stream/ids")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": [\n \"cddfface-beda-4f84-ab22-a9933fad3992\",\n \"6460aa19-ddb2-424c-a54e-0f80b82b1698\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/data-stream/ids")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": [\n \"cddfface-beda-4f84-ab22-a9933fad3992\",\n \"6460aa19-ddb2-424c-a54e-0f80b82b1698\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"records": [
{
"id": "f94e8803-fc03-4c3e-a3fc-c3ffe3993788",
"company_id": 100,
"name": "best data stream name",
"slug": "this-is-a-slug",
"content": {
"description": "Fabulous Data Stream even better than anything out there!",
"icon": "https://some.icon.png",
"sections": [
{
"title": "some title",
"description": "some description",
"image": "some-image"
},
{
"whatever": "whatever json structure FE would like to have here.",
"free_form": "json here"
}
]
},
"tags": [
"tag1",
"tag2"
],
"category": "categoryA",
"offers": [
{
"id": "16310512-a8fb-4ce8-aec3-573693067df9",
"channel": "data_streams_market",
"licensing": {
"period": "P90D",
"license": {
"name": "narrative opendata license"
}
},
"pricing": {
"type": "per_record",
"micro_cents_usd": 70000
},
"shops": null
},
{
"id": "d7542ec5-558f-4e98-9ff6-e049b24798fa",
"channel": "data_shop",
"licensing": {
"period": "P90D",
"license": {
"name": "narrative opendata license"
}
},
"pricing": {
"type": "per_record",
"micro_cents_usd": 50000
},
"shops": null
},
{
"id": "5d52d8d8-b683-4ef4-9220-31347dc2237f",
"channel": "data_shop",
"licensing": {
"period": "P90D",
"license": {
"name": "narrative opendata license"
}
},
"pricing": {
"type": "max_price_per_record",
"micro_cents_usd": 30000
},
"shops": [
"only.on.tld.com"
]
}
],
"data_rules": {
"column_sets": [
{
"dataset_id": 99999,
"fields": [
{
"field": "col1",
"filter": null,
"exported": true
},
{
"field": "col2",
"filter": "include_all_values_including_nulls_filter",
"exported": true
},
{
"field": "col3",
"filter": "include_only_if_not_null_filter",
"exported": true
},
{
"field": "col4",
"filter": {
"type": "include",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col5",
"filter": {
"type": "exclude",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": {
"type": "inclusive",
"value": "-100"
},
"max": {
"type": "inclusive",
"value": "100"
}
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": null,
"max": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": false
},
{
"field": "col7",
"filter": {
"type": "include",
"list": [
"true"
]
},
"exported": true
},
{
"field": "col8",
"filter": {
"recency": "P30D",
"from": null,
"to": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": true
}
]
}
],
"attributes": [
{
"attribute_id": 123,
"fields": [
{
"field": "col1",
"filter": null,
"exported": true
},
{
"field": "col2",
"filter": "include_all_values_including_nulls_filter",
"exported": true
},
{
"field": "col3",
"filter": "include_only_if_not_null_filter",
"exported": true
},
{
"field": "col4",
"filter": {
"type": "include",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col5",
"filter": {
"type": "exclude",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": {
"type": "inclusive",
"value": "-100"
},
"max": {
"type": "inclusive",
"value": "100"
}
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": null,
"max": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": false
},
{
"field": "col7",
"filter": {
"type": "include",
"list": [
"true"
]
},
"exported": true
},
{
"field": "col8",
"filter": {
"recency": "P30D",
"from": null,
"to": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": true
},
{
"field": "col9",
"filter": {
"expressions": [
"col9 > -90",
"col9 < 90"
]
},
"exported": true
}
],
"optional": true
},
{
"attribute_id": 321,
"fields": [
{
"field": "col9",
"filter": {
"expressions": [
"col9 > -90",
"col9 < 90"
]
},
"exported": false
}
],
"optional": false
}
],
"deduplication": {
"period": "P60D",
"column_references": null,
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"col9",
"col9.foo.bar"
]
}
]
},
"frequency_filter": {
"column_references": null,
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"col9.foo.bar"
]
}
],
"min_inclusive": 2,
"max_inclusive": 5
}
},
"auth_rules": {
"company_constraint": {
"type": "inclusion",
"company_ids": [
160,
1701
]
}
},
"created_by": 5000,
"created_at": "2021-06-29T10:58:36.726Z",
"updated_at": "2021-06-29T10:58:36.726Z",
"datasets": null
}
]
}{
"error": "<string>",
"error_description": "<string>"
}Data Streams
Fetch many data-streams
Fetch many data-streams, given their ids.
Allows only upto 50 data-streams to be fetched in a call. If no ids are requested, empty array result is returned.
Note: If n ids are requested this might return any m (0 <= m <= n) number of data-streams depending on
how many actually do exist. It is the clients duty to find this discrepancy.
POST
/
data-stream
/
ids
Fetch many data-streams
curl --request POST \
--url https://api-dev.narrative.io/data-stream/ids \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ids": [
"cddfface-beda-4f84-ab22-a9933fad3992",
"6460aa19-ddb2-424c-a54e-0f80b82b1698"
]
}
'import requests
url = "https://api-dev.narrative.io/data-stream/ids"
payload = { "ids": ["cddfface-beda-4f84-ab22-a9933fad3992", "6460aa19-ddb2-424c-a54e-0f80b82b1698"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
ids: ['cddfface-beda-4f84-ab22-a9933fad3992', '6460aa19-ddb2-424c-a54e-0f80b82b1698']
})
};
fetch('https://api-dev.narrative.io/data-stream/ids', 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/data-stream/ids",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ids' => [
'cddfface-beda-4f84-ab22-a9933fad3992',
'6460aa19-ddb2-424c-a54e-0f80b82b1698'
]
]),
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/data-stream/ids"
payload := strings.NewReader("{\n \"ids\": [\n \"cddfface-beda-4f84-ab22-a9933fad3992\",\n \"6460aa19-ddb2-424c-a54e-0f80b82b1698\"\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-dev.narrative.io/data-stream/ids")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": [\n \"cddfface-beda-4f84-ab22-a9933fad3992\",\n \"6460aa19-ddb2-424c-a54e-0f80b82b1698\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/data-stream/ids")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": [\n \"cddfface-beda-4f84-ab22-a9933fad3992\",\n \"6460aa19-ddb2-424c-a54e-0f80b82b1698\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"records": [
{
"id": "f94e8803-fc03-4c3e-a3fc-c3ffe3993788",
"company_id": 100,
"name": "best data stream name",
"slug": "this-is-a-slug",
"content": {
"description": "Fabulous Data Stream even better than anything out there!",
"icon": "https://some.icon.png",
"sections": [
{
"title": "some title",
"description": "some description",
"image": "some-image"
},
{
"whatever": "whatever json structure FE would like to have here.",
"free_form": "json here"
}
]
},
"tags": [
"tag1",
"tag2"
],
"category": "categoryA",
"offers": [
{
"id": "16310512-a8fb-4ce8-aec3-573693067df9",
"channel": "data_streams_market",
"licensing": {
"period": "P90D",
"license": {
"name": "narrative opendata license"
}
},
"pricing": {
"type": "per_record",
"micro_cents_usd": 70000
},
"shops": null
},
{
"id": "d7542ec5-558f-4e98-9ff6-e049b24798fa",
"channel": "data_shop",
"licensing": {
"period": "P90D",
"license": {
"name": "narrative opendata license"
}
},
"pricing": {
"type": "per_record",
"micro_cents_usd": 50000
},
"shops": null
},
{
"id": "5d52d8d8-b683-4ef4-9220-31347dc2237f",
"channel": "data_shop",
"licensing": {
"period": "P90D",
"license": {
"name": "narrative opendata license"
}
},
"pricing": {
"type": "max_price_per_record",
"micro_cents_usd": 30000
},
"shops": [
"only.on.tld.com"
]
}
],
"data_rules": {
"column_sets": [
{
"dataset_id": 99999,
"fields": [
{
"field": "col1",
"filter": null,
"exported": true
},
{
"field": "col2",
"filter": "include_all_values_including_nulls_filter",
"exported": true
},
{
"field": "col3",
"filter": "include_only_if_not_null_filter",
"exported": true
},
{
"field": "col4",
"filter": {
"type": "include",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col5",
"filter": {
"type": "exclude",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": {
"type": "inclusive",
"value": "-100"
},
"max": {
"type": "inclusive",
"value": "100"
}
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": null,
"max": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": false
},
{
"field": "col7",
"filter": {
"type": "include",
"list": [
"true"
]
},
"exported": true
},
{
"field": "col8",
"filter": {
"recency": "P30D",
"from": null,
"to": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": true
}
]
}
],
"attributes": [
{
"attribute_id": 123,
"fields": [
{
"field": "col1",
"filter": null,
"exported": true
},
{
"field": "col2",
"filter": "include_all_values_including_nulls_filter",
"exported": true
},
{
"field": "col3",
"filter": "include_only_if_not_null_filter",
"exported": true
},
{
"field": "col4",
"filter": {
"type": "include",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col5",
"filter": {
"type": "exclude",
"list": [
"this",
"that",
"that too",
"some more"
]
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": {
"type": "inclusive",
"value": "-100"
},
"max": {
"type": "inclusive",
"value": "100"
}
},
"exported": true
},
{
"field": "col6",
"filter": {
"min": null,
"max": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": false
},
{
"field": "col7",
"filter": {
"type": "include",
"list": [
"true"
]
},
"exported": true
},
{
"field": "col8",
"filter": {
"recency": "P30D",
"from": null,
"to": {
"type": "exclusive",
"value": "timestamp01"
}
},
"exported": true
},
{
"field": "col9",
"filter": {
"expressions": [
"col9 > -90",
"col9 < 90"
]
},
"exported": true
}
],
"optional": true
},
{
"attribute_id": 321,
"fields": [
{
"field": "col9",
"filter": {
"expressions": [
"col9 > -90",
"col9 < 90"
]
},
"exported": false
}
],
"optional": false
}
],
"deduplication": {
"period": "P60D",
"column_references": null,
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"col9",
"col9.foo.bar"
]
}
]
},
"frequency_filter": {
"column_references": null,
"attribute_references": [
{
"attribute_id": 123,
"column_names": [
"col9.foo.bar"
]
}
],
"min_inclusive": 2,
"max_inclusive": 5
}
},
"auth_rules": {
"company_constraint": {
"type": "inclusion",
"company_ids": [
160,
1701
]
}
},
"created_by": 5000,
"created_at": "2021-06-29T10:58:36.726Z",
"updated_at": "2021-06-29T10:58:36.726Z",
"datasets": null
}
]
}{
"error": "<string>",
"error_description": "<string>"
}Was this page helpful?
⌘I

