Query Data
POST
/v2/data/query/{dataset_id}
const url = 'http://localhost:3000/v2/data/query/example';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"id":"api.data.out","ver":"v2","ts":"1711966306164","params":{"msgid":"e180ecac-8f41-4f21-9a21-0b3a1a368917"},"context":{"aggregationLevel":"day"},"query":"Select * from \"check\" WHERE __time >= timestamp \'2020-12-31\' AND __time < TIMESTAMP \'2024-01-21\' Limit 1"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:3000/v2/data/query/example \ --header 'Content-Type: application/json' \ --data '{ "id": "api.data.out", "ver": "v2", "ts": "1711966306164", "params": { "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917" }, "context": { "aggregationLevel": "day" }, "query": "Select * from \"check\" WHERE __time >= timestamp '\''2020-12-31'\'' AND __time < TIMESTAMP '\''2024-01-21'\'' Limit 1" }'Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ” dataset_id
required
string
Unique identifier for the dataset
Request Body
Section titled “Request Body ” Media type application/json
object
Example
{ "id": "api.data.out", "ver": "v2", "ts": "1711966306164", "params": { "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917" }, "context": { "aggregationLevel": "day" }, "query": "Select * from \"check\" WHERE __time >= timestamp '2020-12-31' AND __time < TIMESTAMP '2024-01-21' Limit 1"}Responses
Section titled “ Responses ”OK
Media type application/json
object
Examples
Success: native query (interval as array type)
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:47:45+05:30", "params": { "status": "SUCCESS", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "134efe35-c096-4cab-ad14-db6a8952f264" }, "responseCode": "OK", "result": [ { "timestamp": "2023-09-11T00:00:00.000Z", "result": { "a1": 1694390400000, "a0": 1694390400000 } } ]}Success: native query (queryType: scan)
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:51:14+05:30", "params": { "status": "SUCCESS", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "4fc6e3c1-4715-47b7-9137-7713fb2fbe72" }, "responseCode": "OK", "result": [ { "timestamp": "2023-09-11T00:00:00.000Z", "result": { "a1": 1694390400000, "a0": 1694390400000 } } ]}Success: native query (normal intervals & queryType : timeseries)
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:51:49+05:30", "params": { "status": "SUCCESS", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "75d7ae48-a3db-4367-b50f-34eb99ac3480" }, "responseCode": "OK", "result": [ { "timestamp": "2023-09-11T00:00:00.000Z", "result": { "school_id": 0 } } ]}Success: sql query
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:42:12+05:30", "params": { "status": "SUCCESS", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "2c981011-76da-3000-97f3-eafac939e59f" }, "responseCode": "OK", "result": [ { "__time": "2023-09-11T00:00:00.000Z", "school_category": "secondary", "gender": "others", "state_id": "15", "district_id": "2002", "block_id": "70", "cluster_id": "485", "obsrv.meta.source.connector": null, "obsrv.meta.source.id": null, "grade_sum": 18, "school_id_sum": 180378, "students_marked_sum": 12492, "students_present_sum": 2466, "total_count": 18, "total_students_sum": 12492 } ]}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
313 ETag
string
Example
W/"139-De+IthAwrGNR+J11CwlNf5RSMmw" Date
string
Example
Thu, 30 May 2024 18:17:45 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5Bad Request
Media type application/json
object
Example
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:46:29+05:30", "params": { "status": "FAILED", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "b6434700-dd92-4f64-9250-a22939e753b9" }, "responseCode": "BAD_REQUEST", "result": {}, "error": { "code": "DATA_OUT_INVALID_DATE_RANGE", "message": "Invalid date range! make sure your range cannot be more than 30 days", "trace": "" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
371 ETag
string
Example
W/"173-OP8NcbSqLKFO92PIyUmMk0lNsXs" Date
string
Example
Thu, 30 May 2024 18:16:29 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5Not Found
Media type application/json
object
Examples
Failure: Datasource not found in live table
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:43:12+05:30", "params": { "status": "FAILED", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "f922f120-2aea-49af-9a76-7312fe2eb266" }, "responseCode": "NOT_FOUND", "result": {}, "error": { "code": "DATA_OUT_SOURCE_NOT_FOUND", "message": "Datasource telemetry-eventssss not available for querying", "trace": "" }}Failure: Datasource not found in druid
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:50:27+05:30", "params": { "status": "FAILED", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "75bd4313-d504-4fd3-92ab-ee2a685beb83" }, "responseCode": "NOT_FOUND", "result": {}, "error": { "code": "DATA_OUT_SOURCE_NOT_FOUND", "message": "Dataset test with table day is not available for querying", "trace": "" }}SQL Failure: dataset not found in druid
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:52:26+05:30", "params": { "status": "FAILED", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "19849769-c290-4599-a79e-862dcbce1124" }, "responseCode": "NOT_FOUND", "result": {}, "error": { "code": "DATA_OUT_SOURCE_NOT_FOUND", "message": "Dataset test with table day is not available for querying", "trace": "" }}SQL Failure: Datasource not found in live table
{ "id": "api.data.out", "ver": "v2", "ts": "2024-05-30T23:53:02+05:30", "params": { "status": "FAILED", "msgid": "e180ecac-8f41-4f21-9a21-0b3a1a368917", "resmsgid": "530a12f9-04f3-4986-8f52-b3184b9194bd" }, "responseCode": "NOT_FOUND", "result": {}, "error": { "code": "DATA_OUT_SOURCE_NOT_FOUND", "message": "Datasource undefined not available for querying", "trace": "" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
356 ETag
string
Example
W/"164-DSmPP0WJI5ISEqIw3U3B1NFXxVE" Date
string
Example
Thu, 30 May 2024 18:13:12 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5