The NLP API lets you develop applications to list query suggestions and retrieve the associated response from the query. With this API, you can make NLP requests to search across datasets within a given user's account.
The result of the NLP query is a JSON object that includes query suggestions with matching datasetId or the parsed results from the NLP query.
List suggestions
Get query suggestions with keyword searches
Query
GET /api/1.0/nlp/suggestions?query=average
Parameter | Comments |
---|---|
query | Query which will be used for generation of autosuggestions |
Response
HTTP Status | Response |
---|---|
200 OK | Output example:
[ { "query": "average conversions", "datasetId": "16042", "datasetName": "report 2" }, { "query": "average spam", "datasetId": "16041", "datasetName": "report 1" }, { "query": "average unitprice", "datasetId": "16037", "datasetName": "Online_Retail_2" }, { "query": "average customerid", "datasetId": "16036", "datasetName": "Online_Retail_1" }, { "query": "average opened", "datasetId": "16042", "datasetName": "report 2" } ] |
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": "Current user is not allowed to use natural language processing", "documentation_url": "https://knowi.com/docs/managementAPI.html" } Common error details:
|
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -X GET "http://localhost:9090/api/1.0/nlp/suggestions?query=aver"
Parse suggestion
Returns results of parsed NLP query
Query
POST /api/1.0/nlp/query/parse
Parameter | Required | Comments |
---|---|---|
query | Yes | Query to process |
datasetId | Yes | Dataset that your query relates to |
format | Yes | Format of the response (json, txt). Defaults to json |
Response
HTTP Status | Response |
---|---|
200 OK | Output example:
[ { "Average Conversions": 3295.814814814815 } ] |
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": "Current user is not allowed to use natural language processing", "documentation_url": "https://knowi.com/docs/managementAPI.html" } Common error details:
|
Example
curl -i -H "Authorization: Bearer HEREISYOUR_BEARER" -H "Content-Type: application/x-www-form-urlencoded" -d "datasetId=16040&query=average%20conversions&format=json"
NLP across dataset
Returns results of parsed NLP query with best match dataset.
Query
POST /api/1.0/nlp/dataset
POST JSON payload:
Parameter | Required | Comments |
---|---|---|
query | Yes | Query to process |
Response
HTTP Status | Response |
---|---|
200 OK | Output example:
{ "data":[ { "sent": 100 }, { "sent": 200 } ], "datasetName":"csv157", "datasetId":15532" } |
204 NO_CONTENT |
{ "message": "No datasets found to match query", "documentation_url": "https://www.knowi.com/docs/managementAPI.html" } Error details:
|
400 BAD_REQUEST |
{ "message": <Error details>, "documentation_url": <Documentation link> } Error details:
|
401 UNAUTHORIZED |
{ "message": <Error details>, "documentation_url": <Documentation link> } Common error details:
|
403 FORBIDDEN | Error details:
|
500 INTERNAL_SERVER_ERROR | Error details:
|
Example
curl -i -H "Authorization: Bearer HERE_IS_YOUR_BEARER" -H "Content-Type: application/x-www-form-urlencoded" -d "query=show%20where%20sending_activity%20grater%20than%20100" http://localhost:9090/api/1.0/nlp/dataset