You are here: Home Documentation REST API kb/query

kb/query

Retrieve semantic connections and properties from the KnowledgeBase.

Resource URL

GET/POST http(s)://api.idilia.com /1/kb/query.json

Description

Send a request to obtain content in the KnowledgeBase. Several relations such as sensekeys for a lemma or parents/children of a fine sense are available. The query is written as a JSON object and the response is also a JSON object that mirrors the JSON request. Refer to Query Language for a description of the query language.

Each request may contain several queries where each query is a JSON object in the request array. The response for each query is at the same index in the response array.

The server is HTTP 1.1 compliant and multiple requests may be issued without closing the connection. Requests from a connection are processed sequentially and returned in the order received. When issuing a single request per connection, HTTP header "Connection: close" should be transmitted by the client.

The KnowledgeBase uses ISO-8859-1 character set encoding. The HTTP ContentType of the response is always "application/json; charset=iso-8859-1". The client may specify a character set in the query by issuing a POST request with HTTP header "Content-Type" set appropriately (e.g., Content-Type: application/json; charset=utf8).

Request

The request is an HTTP GET or POST with the following query parameters:

key

When using simple authentication, this parameter contains the concatenation of your access key and private key. See Authentication for more details.

Optional. Default: none

Example value : Idi123rlzKT90yoUavrzoRbkdHgsoZTiYR2qaYA8SxA

requestId

Unique identifier supplied by the application to assist correlating the server's responses with the application's requests. Echoed transparently by the server.

Optional. Default: none

Example value : some-app-req-1234

pretty

A modifier that when present indicates that the JSON response should be formatted for a human. Specified value is ignored.

Optional. Default: none

Example value : 1

query

A JSON array with one or more query expressed in the JSON query language.

Mandatory. Default: none

Example value : [{ "fs":"The_Matrix/N2", "neInfo":null }]

Response

The response to the request is a JSON object with the elements:

errorMsg This parameter is present when an error was encountered when processing the request (i.e., status != 200). It is a string containing a descriptive cause of the error encountered.
requestId This parameter echoes the string provided as parameter requestId in the request. It can be used by applications to correlate requests and responses.
result A JSON array of response objects matching their counterpart in the JSON array supplied in parameter query of the request.
status This parameter is a numeric return code for the request. The value corresponds to the HTTP return codes. For example, "200" indicates that the request was successfully processed. "400" is the code for a bad request.

Request Authentification

All requests must be authenticated as described in Authentication. Two methods are available: simple and signed requests. The basic method requires the addition of the key parameter as described in this page. The signed requests require the addition of a few HTTP headers (Content-MD5, Date, Authorization).

Example

http(s)://api.idilia.com/1/kb/query.json?
  requestId=kb123&
  key=34akdadhe3&
  pretty=1&
  query=[{"lemma":"dog", "limit":2, "fsk":[{ "fsk":null, "definition":null, "parents":[{"fs":null, "depth<":3}] }] }]
{
    "status" : 200,
    "requestId" : "kb123",
    "result" : [
        {
            "lemma" : "dog",
            "fsk" : [
                {
                    "fsk" : "dog/N6",
                    "definition" : "a hinged catch that fits into a notch of a ratchet ...",
                    "parents" : [
                        {
                            "fs" : "catch/N6",
                            "depth" : 1
                        },
                        {
                            "fs" : "restraint/N6",
                            "depth" : 2
                        }
                    ]
                },
                {
                    "fsk" : "dog/V2",
                    "definition" : "to cause inconvenience or discomfort to.",
                    "parents" : [
                        {
                            "fs" : "affect/V1",
                            "depth" : 1
                        },
                        {
                            "fs" : "change/V2",
                            "depth" : 2
                        }
                    ]
                }
            ]
        }
    ]
}