List Queries
This endpoint returns all the queries
Query
GET /api/1.0/queries
No parameters |
---|
Response
HTTP Status | Response |
---|---|
200 OK | Output example:
{ "list":[ { "createdDate":1492400077000, "lastModDate":1492400077000, "jsonConfig":"{\n \"entityName\" : \"test123\",\n \"queryStr\" : \"db[someTable].find().limit(10000)\",\n \"datasourceId\" : 1427,\n \"discovery\" : {\n \"tableName\" : \"someTable\",\n \"limit\" : 10000\n },\n \"direct\" : false,\n \"triggered\" : false,\n \"overrideVals\" : {\n \"replaceAll\" : true\n }\n}", "strId":"pvH8wk", "op":1, "connectorSyncStatus":1, "id":2017, "entityName":"test123", "datasourceId":1427, "userId":10077, "customerId":1033, "queryStr":"db[someTable].find().limit(10000)", "identifier":"kVrQip", "status":0, "triggerDatasetId":0, "discovery":{ "tableName":"someTable", "limit":10000 }, "accessLevel":1, "triggered":false } ] } |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER"
https://www.knowi.com/api/1.0/queries
Get Query
This endpoint returns the queries of a given query id
Query
GET /api/1.0/queries/<objectId>?loadJoinDataSources=true
Parameter | Comments |
---|---|
objectId | Query ID (integer) to view or Query Identifier (string) |
loadJoinDataSources | <loadJoinDataSources> is optional query parameter. If set to true, then also joined Queries will be loaded associated with selected query/td> |
Response
HTTP Status | Response |
---|---|
200 OK | Output example:
{ "createdDate":1492400077000, "lastModDate":1492400077000, "jsonConfig":"{\n \"entityName\" : \"test123\",\n \"queryStr\" : \"db[someTable].find().limit(10000)\",\n \"datasourceId\" : 1427,\n \"discovery\" : {\n \"tableName\" : \"someTable\",\n \"limit\" : 10000\n },\n \"direct\" : false,\n \"triggered\" : false,\n \"overrideVals\" : {\n \"replaceAll\" : true\n }\n}", "strId":"pvH8wk", "op":1, "connectorSyncStatus":1, "id":2017, "entityName":"test123", "datasourceId":1427, "userId":10077, "customerId":1033, "queryStr":"db[someTable].find().limit(10000)", "identifier":"kVrQip", "status":0, "triggerDatasetId":0, "discovery":{ "tableName":"someTable", "limit":10000 }, "accessLevel":1, "triggered":false } |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
403 FORBIDDEN |
{ "message": <Error details>, "documentation_url": <Documentation link> } Error details:
|
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER"
https://www.knowi.com/api/1.0/queries/123
Share Query to Users/Groups
This endpoint is for sharing the queries with users and groups of a given query id
Query
PUT /api/1.0/queries/<objectId>/share
Parameter | Comments |
---|---|
objectId | Id of Query to edit |
sso_user | Optional bool. Set to `true` if sharing to sso user |
JSON PUT payload:
Parameter | Comments |
---|---|
shareProperties | Share properties json array. Available fields:
|
Response
HTTP Status | Response |
---|---|
200 OK | No response body |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
403 FORBIDDEN |
{ "message": <Error details>, "documentation_url": <Documentation link> }Error details:
|
415 UNSUPPORTED_MEDIA_TYPE | Cannot consume content type - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method. |
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -H "Content-Type: application/json" -X PUT -d "{\"shareProperties\": [ { \"type\" : \"Users\", \"access_level\" : 1, \"name\" : \"someUser@host.com\" } ] }"
https://www.knowi.com/api/1.0/queries/105530
Create Query
This endpoint is for creating a new query
Query
POST /api/1.0/queries/
POST JSON payload:
Parameter | Comments |
---|---|
properties | Json object containing properties of new query. Example of object:
{ "entityName":"test123", "queryStr":"db['someTable'].find().limit(10000)", "c9QLFilter":"", "datasourceId":1427, "datasource":"mongo", "dsName":"LocalMongo", "discovery":{ "tableName":"someTable", "metrics":[ ], "dimensions":[ ], "sort":[ ], "limit":10000, "filters":[ ], "datasourceId":1427, "datasource":"mongo", "dsName":"LocalMongo" }, "direct":false, "triggered":false, "overrideVals":"All" } |
Response
HTTP Status | Response |
---|---|
200 OK | Return created Query json info (same as "Get Query" command). Output example:
{ "createdDate":1492400077000, "lastModDate":1492400077000, "jsonConfig":"{\n \"entityName\" : \"test123\",\n \"queryStr\" : \"db[someTable].find().limit(10000)\",\n \"datasourceId\" : 1427,\n \"discovery\" : {\n \"tableName\" : \"someTable\",\n \"limit\" : 10000\n },\n \"direct\" : false,\n \"triggered\" : false,\n \"overrideVals\" : {\n \"replaceAll\" : true\n }\n}", "strId":"pvH8wk", "op":1, "connectorSyncStatus":1, "id":2017, "entityName":"test123", "datasourceId":1427, "userId":10077, "customerId":1033, "queryStr":"db[someTable].find().limit(10000)", "identifier":"kVrQip", "status":0, "triggerDatasetId":0, "discovery":{ "tableName":"someTable", "limit":10000 }, "accessLevel":1, "triggered":false } |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
415 UNSUPPORTED_MEDIA_TYPE | Cannot consume content type - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method. |
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -H "Content-Type: application/json" -X POST -d "{\"properties\":{\"entityName\":\"test123\", \"queryStr\":\"db['someTable'].find().limit(10000)\", \"c9QLFilter\":\"\", \"datasourceId\":1427, \"datasource\":\"mongo\", \"dsName\":\"LocalMongo\", \"discovery\":{\"tableName\":\"someTable\", \"metrics\":[], \"dimensions\":[], \"sort\":[], \"limit\":10000, \"filters\":[], \"datasourceId\":1427, \"datasource\":\"mongo\", \"dsName\":\"LocalMongo\"}, \"direct\":false, \"triggered\":false, \"overrideVals\":\"All\"} }"
https://www.knowi.com/api/1.0/queries
Delete Query
This endpoint is for deleting a query of a given query id
Query
DELETE /api/1.0/queries/<objectId>
Parameter | Type | Comments |
---|---|---|
objectId | Integer | Id of Query to delete |
removeWidgets | Boolean | Delete any associated widgets |
Response
HTTP Status | Response |
---|---|
200 OK | No response body |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
403 FORBIDDEN |
{ "message": <Error details>, "documentation_url": <Documentation link> } Error details:
|
415 UNSUPPORTED_MEDIA_TYPE | Cannot consume content type - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method. |
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -X DELETE
https://www.knowi.com/api/1.0/queries/20038
Edit Query
This endpoint is for updating/modifying the query of a given query id
Query
PUT /api/1.0/queries/<objectId>
Parameter | Comments |
---|---|
objectId | Id of Query to edit |
PUT JSON payload:
Parameter | Comments |
---|---|
properties | Json object containing edited properties of query. Example of object:
{ "entityName":"test123", "queryStr":"db['someTable'].find().limit(10000)", "c9QLFilter":"", "datasourceId":1427, "datasource":"mongo", "dsName":"LocalMongo", "discovery":{ "tableName":"someTable", "metrics":[ ], "dimensions":[ ], "sort":[ ], "limit":10000, "filters":[ ], "datasourceId":1427, "datasource":"mongo", "dsName":"LocalMongo" }, "direct":false, "triggered":false, "overrideVals":"All" } |
Response
HTTP Status | Response |
---|---|
200 OK | Return edited Query json info (same as "Get Query" command). Output example:
{ "createdDate":1492400077000, "lastModDate":1492400077000, "jsonConfig":"{\n \"entityName\" : \"test123\",\n \"queryStr\" : \"db[someTable].find().limit(10000)\",\n \"datasourceId\" : 1427,\n \"discovery\" : {\n \"tableName\" : \"someTable\",\n \"limit\" : 10000\n },\n \"direct\" : false,\n \"triggered\" : false,\n \"overrideVals\" : {\n \"replaceAll\" : true\n }\n}", "strId":"pvH8wk", "op":1, "connectorSyncStatus":1, "id":2017, "entityName":"test123", "datasourceId":1427, "userId":10077, "customerId":1033, "queryStr":"db[someTable].find().limit(10000)", "identifier":"kVrQip", "status":0, "triggerDatasetId":0, "discovery":{ "tableName":"someTable", "limit":10000 }, "accessLevel":1, "triggered":false } |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
403 FORBIDDEN |
{ "message": <Error details>, "documentation_url": <Documentation link> } Error details:
|
415 UNSUPPORTED_MEDIA_TYPE | Cannot consume content type - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method. |
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -H "Content-Type: application/json" -X PUT -d "{\"properties\":{\"entityName\":\"test123\", \"queryStr\":\"db['someTable'].find().limit(10000)\", \"c9QLFilter\":\"\", \"datasourceId\":1427, \"datasource\":\"mongo\", \"dsName\":\"LocalMongo\", \"discovery\":{\"tableName\":\"someTable\", \"metrics\":[], \"dimensions\":[], \"sort\":[], \"limit\":10000, \"filters\":[], \"datasourceId\":1427, \"datasource\":\"mongo\", \"dsName\":\"LocalMongo\"}, \"direct\":false, \"triggered\":false, \"overrideVals\":\"All\"} }"https://www.knowi.com/api/1.0/queries/20050
Clone Query
This endpoint is for cloning a query of a given query id
Query
POST /api/1.0/queries/<objectIdToClone>
Parameter | Comments |
---|---|
objectIdToClone | Query id of Query to clone |
POST JSON payload:
Parameter | Comments |
---|---|
clonedQueryName | New (cloned) Name of Query |
Response
HTTP Status | Response |
---|---|
200 OK | Return cloned Query json info (same as "Get Query" command). Output example:
{ "createdDate":1492400077000, "lastModDate":1492400077000, "jsonConfig":"{\n \"entityName\" : \"test123\",\n \"queryStr\" : \"db[someTable].find().limit(10000)\",\n \"datasourceId\" : 1427,\n \"discovery\" : {\n \"tableName\" : \"someTable\",\n \"limit\" : 10000\n },\n \"direct\" : false,\n \"triggered\" : false,\n \"overrideVals\" : {\n \"replaceAll\" : true\n }\n}", "strId":"pvH8wk", "op":1, "connectorSyncStatus":1, "id":2017, "entityName":"test123", "datasourceId":1427, "userId":10077, "customerId":1033, "queryStr":"db[someTable].find().limit(10000)", "identifier":"kVrQip", "status":0, "triggerDatasetId":0, "discovery":{ "tableName":"someTable", "limit":10000 }, "accessLevel":1, "triggered":false } |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
403 FORBIDDEN |
{ "message": <Error details>, "documentation_url": <Documentation link> } Error details:
|
415 UNSUPPORTED_MEDIA_TYPE | Cannot consume content type - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method. |
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -H "Content-Type: application/json" -X POST -d "{\"clonedQueryName\":\"newName123\"}"https://www.knowi.com/api/1.0/queries/12345
Refresh Query
This endpoint is for refreshing the queries of a given id
Query
POST /api/1.0/queries/<queryId>/refreshQuery
Parameter | Comments |
---|---|
queryId | Query id of Query to run/refresh |
HTTP Status | Response |
---|---|
200 OK | No response body |
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
403 FORBIDDEN |
{ "message": <Error details>, "documentation_url": <Documentation link> } Error details:
|
415 UNSUPPORTED_MEDIA_TYPE | Cannot consume content type - The server refused this request because the request entity is in a format not supported by the requested resource for the requested method. |
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -H "Content-Type: application/json" -X POST https://www.knowi.com/api/1.0/queries/12345/refreshQuery