Get a query by id
curl --request GET \
--url https://api-dev.narrative.io/v2/queries/{query_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-dev.narrative.io/v2/queries/{query_id}"
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/v2/queries/{query_id}', 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/v2/queries/{query_id}",
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/v2/queries/{query_id}"
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/v2/queries/{query_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/queries/{query_id}")
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{
"name": "query1",
"id": "7409b999-2a9a-40cd-89dc-8430d85e0391",
"display_name": "Query One",
"owner": {
"company_id": 456,
"company_name": "ExampleCorp",
"company_slug": "examplecorp"
},
"tags": [
"tag1",
"tag2"
],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"is_owned": true,
"metadata": {
"created_at": "2024-04-12T19:57:05.012908",
"created_by_user_id": 321,
"updated_at": "2024-04-12T20:03:48.031825",
"updated_by_user_id": 321
},
"ast": {
"type": "select",
"nql": "SELECT age FROM narrative.rosetta_stone",
"budget": null,
"columns": [
{
"type": "table",
"nql": "age",
"db": null,
"schema": null,
"table": "age"
}
],
"from": {
"type": "table",
"nql": "narrative.rosetta_stone",
"db": null,
"schema": "narrative",
"table": "rosetta_stone"
},
"group_by": [],
"having": null,
"is_distinct": false,
"limit": null,
"order_by": [],
"qualify": null,
"where": null,
"windows": [],
"with": []
}
}Queries
Get a query by id
Get a query.
GET
/
v2
/
queries
/
{query_id}
Get a query by id
curl --request GET \
--url https://api-dev.narrative.io/v2/queries/{query_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api-dev.narrative.io/v2/queries/{query_id}"
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/v2/queries/{query_id}', 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/v2/queries/{query_id}",
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/v2/queries/{query_id}"
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/v2/queries/{query_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dev.narrative.io/v2/queries/{query_id}")
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{
"name": "query1",
"id": "7409b999-2a9a-40cd-89dc-8430d85e0391",
"display_name": "Query One",
"owner": {
"company_id": 456,
"company_name": "ExampleCorp",
"company_slug": "examplecorp"
},
"tags": [
"tag1",
"tag2"
],
"collaborators": {
"query": {
"type": "inclusion",
"company_ids": [
789
]
},
"view": {
"type": "all"
}
},
"is_owned": true,
"metadata": {
"created_at": "2024-04-12T19:57:05.012908",
"created_by_user_id": 321,
"updated_at": "2024-04-12T20:03:48.031825",
"updated_by_user_id": 321
},
"ast": {
"type": "select",
"nql": "SELECT age FROM narrative.rosetta_stone",
"budget": null,
"columns": [
{
"type": "table",
"nql": "age",
"db": null,
"schema": null,
"table": "age"
}
],
"from": {
"type": "table",
"nql": "narrative.rosetta_stone",
"db": null,
"schema": "narrative",
"table": "rosetta_stone"
},
"group_by": [],
"having": null,
"is_distinct": false,
"limit": null,
"order_by": [],
"qualify": null,
"where": null,
"windows": [],
"with": []
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Query identifier.
Response
200 - application/json
OK
- Option 1
- Option 2
It should be unique. Must be <= 256 characters and consist of only alphanumeric characters and underscores.
Describes who can view or query a resource
Show child attributes
Show child attributes
Information about the owner of the query
Show child attributes
Show child attributes
Metadata about when and by whom a query was created/updated
Show child attributes
Show child attributes
The AST representing the query.
Optional. Display Name must be non-empty and less than 1000 chars.
A human-friendly description of the query.
Optional. Each tag must be less than 256 chars.
Whether the requestor owns the query.
Was this page helpful?
⌘I

