Introduction to Search (DQL API)

Search the Diffbot Knowledge Graph for organizations, people, articles, and more with DQL API.

The Search or DQL API is one of two methods of accessing data from the Diffbot Knowledge Graph.

The API takes a DQL (Diffbot Query Language) query, filters facts from the Knowledge Graph based on the instructions of that query, and returns a data response.

A simple DQL query looks like this:

type:Organization locations.city.name:"San Francisco" nbEmployees>5000

This query is searching for all Organizations (type:Organization) located in San Francisco (locations.city.name:"San Francisco") with more than 5000 employees (nbEmployees>5000).

Passing this query to the DQL API endpoint is similarly straight forward. The only parameters required is your Diffbot token and the query itself. Here is how it looks:

curl --request GET \
     --url 'https://kg.diffbot.com/kg/v3/dql?token=YOURTOKEN&query=type%3AOrganization%20locations.city.name%3A%22San%20Francisco%22%20nbEmployees%3E5000' \
     --header 'Accept: application/json'
import requests

url = "https://kg.diffbot.com/kg/v3/dql?token=YOURTOKEN&query=type%3AOrganization%20locations.city.name%3A%22San%20Francisco%22%20nbEmployees%3E5000"

headers = {"Accept": "application/json"}

response = requests.get(url, headers=headers)

print(response.text)

Next Steps

Start with the Day 1 Guide to Knowledge Graph Search for a comprehensive overview and step-by-step on what you can do with the DQL API.

For a faster start, the DQL reference will help you get acquainted with the syntax of specific methods.

DQL should take no time to pick up if you've had experience working with JSON and basic logical operators. You might find it helpful to browse the catalog of useful DQL queries to see how DQL works.

If you're ready, you can also dive right into the DQL Search API Reference.