Search the Knowledge Graph using DQL
Request
| Authentication | |
|---|---|
token | Cache and insert token into example requests (15d expiry) |
| Query parameters | |
|---|---|
type | Query type (default: One of: |
query | DQL Query |
col | Comma-delimited list of custom crawl collections to query. Specify |
from | Return results starting at Please note that the from parameter is no longer applicable to Article queries and has been deprecated. In the future, using this parameter will result in an error. (default: |
size | Maximum number of results to return. |
format | Output format (default: One of: |
exportspec | The spec defines the columns to export. This is applicable for csv, xls and xslx formats. Export spec specifies how to export the entity JSON to a csv. A simple export spec looks like |
exportseparator | The export separator |
exportfile | For export endpoint, The file name of the export file |
filter | Semi-colon separated path filter to filter response json. You can use a simple dot notation |
filterExclude | Semi-colon separated path filter to filter and exclude data from response json. You can use a simple dot notation |
jsonmode |
One of: |
nonCanonicalFacts |
|
noDedupArticles |
|
cluster | Articles only. Utilize Diffbot clustering algorithms to identify related or similar objects.
One of: |
report | Generate coverage report. See Coverage Reports for more details on generating coverage reports for DQL queries. (default: |
view | |
Example request
curl --request GET \
--url 'https://kg.diffbot.com/kg/v3/dql?type=query&query=type%3AOrganization%20locations.city.name%3A%22San%20Francisco%22%20nbEmployees%3E5000&col=all&from=0&size=50&format=json&nonCanonicalFacts=false&noDedupArticles=false&report=false&token=<DIFFBOT_TOKEN>' \
--header 'Accept: application/json'
Response
| 200Query results | |
|---|---|
version | Response version |
hits | |
results | Number of results in this response |
kgversion | Version of KG that was queried |
diffbot_type | Diffbot type of returned results |
facet | Was this a facet query? |
data | Results of the query |
score | score |
entity | Entity. Can be null if no entity was found. |
empty | |
entity_ctx | Entity-level context |
errors | |
callbackQuery | The query for the facet |
upperBound | The upper bound of the facet |
lowerBound | The lower bound of the facet |
count | The count of the facet |
value | The value of the facet |
uri | The uri of the facet value (for uri facets) |
rewrites | |
query | |
reason | |
textFallback | Whether the query fell back to text search. |
reportId | Identifier for the generated coverage report. Present only when |
{
"version": 3,
"hits": 642,
"results": 2,
"kgversion": "477",
"diffbot_type": "Organization",
"facet": false,
"textFallback": false,
"data": [
{
"score": 1584.3050537109375,
"entity": {
"name": "Yandex",
"homepageUri": "yandex.com",
"nbEmployees": 26361
},
"entity_ctx": {
"inner_hits": {
"locations": [
39
]
},
"matched_clauses": []
}
},
{
"score": 1558.7650146484375,
"entity": {
"name": "Google",
"homepageUri": "google.com",
"nbEmployees": 187000
},
"entity_ctx": {
"inner_hits": {
"locations": [
192,
161,
261,
215
]
},
"matched_clauses": []
}
}
]
}
| 400Error parsing the query | |
|---|---|
error | |
message | |
line | |
column | |
htmlMessage | The message with the offending token wrapped in |
{
"line": 1,
"column": 6,
"htmlMessage": "<span>type:<mark>:</mark>:Bogus((</span>",
"error": true,
"message": "Encountered \" \":\" \": \"\" at line 1, column 6."
}
| 401Unauthorized | |
|---|---|
code | |
message | |
requestId |
{
"code": 401,
"message": "Unauthorized. Incorrect token.",
"requestId": "a9cbf96bb0e2084d5c1595ae8f526576"
}
| 422Invalid or missing parameters | |
|---|---|
error | |
message |
{
"error": true,
"message": "Parameter 'query' not specified"
}
| 500Internal Server Error | |
|---|---|
code | |
message |
{
"code": 500,
"message": "HTTP 500 Internal Server Error"
}