Query Template
POST
/v2/template/query/{template_id}
const url = 'http://localhost:3000/v2/template/query/example';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"id":"api.query.template.query","ver":"v2","ts":"2024-04-10T16:10:50+05:30","params":{"msgid":"4a7f14c3-d61e-4d4f-be78-181834eeff6d"},"request":{"startdate":"2020-12-31","enddate":"2024-12-31","aggregationLevel":"month","dataset":"test","limit":5}}'};
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/template/query/example \ --header 'Content-Type: application/json' \ --data '{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-04-10T16:10:50+05:30", "params": { "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d" }, "request": { "startdate": "2020-12-31", "enddate": "2024-12-31", "aggregationLevel": "month", "dataset": "test", "limit": 5 } }'Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ” template_id
required
string
Unique identifier for the template
Request Body
Section titled “Request Body ” Media type application/json
object
Example
{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-04-10T16:10:50+05:30", "params": { "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d" }, "request": { "startdate": "2020-12-31", "enddate": "2024-12-31", "aggregationLevel": "month", "dataset": "test", "limit": 5 }}Responses
Section titled “ Responses ”OK
Media type application/json
object
Examples
Success: JSON template with request body
{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-05-14T11:52:24+05:30", "params": { "status": "SUCCESS", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "b65e0130-5ba4-49f1-bc6a-8a7d66d1a02d" }, "responseCode": "OK", "result": [ { "timestamp": "2023-09-01T00:00:00.000Z", "result": { "school_id": 0 } } ]}Success: SQL template query with request body
{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-05-14T11:33:06+05:30", "params": { "status": "SUCCESS", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "48c194ee-6e73-4ee7-83e6-8b154e441911" }, "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
301 ETag
string
Example
W/"12d-9hKB38iHEwYPT2MgF8puXcq05Ew" Date
string
Example
Tue, 14 May 2024 06:22:24 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5Bad Request
Media type application/json
object
Examples
Failure: invalid date range (native template)
{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-05-02T12:59:14+05:30", "params": { "status": "FAILED", "resmsgid": "4379e16b-2fa3-46a8-8ded-bc53f56283e9" }, "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": "" }}Failure: invalid date range
{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-05-13T13:28:18+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "20391fb8-2be8-48b5-a16f-fca150580e97" }, "responseCode": "BAD_REQUEST", "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
336 ETag
string
Example
W/"150-T/XeSIt7PR7GcGEbET1e8n9zX7k" Date
string
Example
Thu, 02 May 2024 07:29:14 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5Not Found
Media type application/json
object
Examples
Failure: Datasource not found in druid
{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-05-13T13:21:46+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "b35a7050-b94c-4944-9630-233c9542272e" }, "responseCode": "NOT_FOUND", "error": { "code": "DATA_OUT_SOURCE_NOT_FOUND", "message": "Dataset test with table hour is not available for querying", "trace": "" }}Failure: Datasource not found in live table
{ "id": "api.query.template.query", "ver": "v2", "ts": "2024-05-13T13:23:47+05:30", "params": { "status": "FAILED", "msgid": "4a7f14c3-d61e-4d4f-be78-181834eeff6d", "resmsgid": "3a303dfd-1d95-4788-b1a7-d88809d4dcf3" }, "responseCode": "NOT_FOUND", "error": { "code": "DATA_OUT_SOURCE_NOT_FOUND", "message": "Datasource test11 not available for querying", "trace": "" }}Headers
Section titled “Headers ” X-Powered-By
string
Example
Express Content-Length
integer
Example
357 ETag
string
Example
W/"165-Q7Qi9SUmHUwU75fy/RFrXL9Pp3U" Date
string
Example
Mon, 13 May 2024 07:51:46 GMT Connection
string
Example
keep-alive Keep-Alive
string
Example
timeout=5