Google Knowledge Graph Search API

The Knowledge Graph Search API lets you find entities in the Google Knowledge Graph. The API uses standard types and is compliant with the JSON-LD specification.

Typical use cases

Some examples of how you can use the Knowledge Graph Search API include:

  • Getting a ranked list of the most notable entities that match certain criteria.
  • Predictively completing entities in a search box.
  • Annotating/organizing content using the Knowledge Graph entities.

For detailed information about the API methods and parameters, see the API Reference.

Sample request

The following example shows one kind of request you can send to the API. (But check the Prerequisites section first. You'll also need to insert your own API key.)

The sample search above returns a JSON-LD result similar to the following:

  "@context": {
    "@vocab": "",
    "goog": "",
    "resultScore": "goog:resultScore",
    "detailedDescription": "goog:detailedDescription",
    "EntitySearchResult": "goog:EntitySearchResult",
    "kg": ""
  "@type": "ItemList",
  "itemListElement": [
      "@type": "EntitySearchResult",
      "result": {
        "@id": "kg:/m/0dl567",
        "name": "Taylor Swift",
        "@type": [
        "description": "Singer-songwriter",
        "image": {
          "contentUrl": "",
          "url": "",
          "license": ""
        "detailedDescription": {
          "articleBody": "Taylor Alison Swift is an American singer-songwriter and actress. Raised in Wyomissing, Pennsylvania, she moved to Nashville, Tennessee, at the age of 14 to pursue a career in country music. ",
          "url": "",
          "license": ""
        "url": ""
      "resultScore": 4850

The following code samples show how to perform a similar search in various supported languages. This search returns entries matching Taylor Swift.


"""Example of Python client calling Knowledge Graph Search API."""
import json
import urllib

api_key = open('.api_key').read()
query = 'Taylor Swift'
service_url = ''
params = {
    'query': query,
    'limit': 10,
    'indent': True,
    'key': api_key,
url = service_url + '?' + urllib.urlencode(params)
response = json.loads(urllib.urlopen(url).read())
for element in response['itemListElement']:
  print(element['result']['name'] + ' (' + str(element['resultScore']) + ')')



import com.jayway.jsonpath.JsonPath;
import java.util.Properties;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

/** Example of Java client calling Knowledge Graph Search API */
public class SearchExample {
  public static Properties properties = new Properties();
  public static void main(String[] args) {
    try {
      properties.load(new FileInputStream(""));

      HttpTransport httpTransport = new NetHttpTransport();
      HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
      JSONParser parser = new JSONParser();
      GenericUrl url = new GenericUrl("");
      url.put("query", "Taylor Swift");
      url.put("limit", "10");
      url.put("indent", "true");
      url.put("key", properties.get("API_KEY"));
      HttpRequest request = requestFactory.buildGetRequest(url);
      HttpResponse httpResponse = request.execute();
      JSONObject response = (JSONObject) parser.parse(httpResponse.parseAsString());
      JSONArray elements = (JSONArray) response.get("itemListElement");
      for (Object element : elements) {
        System.out.println(, "$").toString());
    } catch (Exception ex) {


<!DOCTYPE html>
    <script src=""></script>
  var service_url = '';
  var params = {
    'query': 'Taylor Swift',
    'limit': 10,
    'indent': true,
    'key' : '<put your api_key here>',
  $.getJSON(service_url + '?callback=?', params, function(response) {
    $.each(response.itemListElement, function(i, element) {
      $('<div>', {text:element['result']['name']}).appendTo(document.body);


require '.api_key';
$service_url = '';
$params = array(
  'query' => 'Taylor Swift',
  'limit' => 10,
  'indent' => TRUE,
  'key' => $api_key);
$url = $service_url . '?' . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch), true);
foreach($response['itemListElement'] as $element) {
  echo $element['result']['name'] . '<br/>';

Knowledge Graph entities

The Knowledge Graph has millions of entries that describe real-world entities like people, places, and things. These entities form the nodes of the graph.

The following are some of the types of entities found in the Knowledge Graph: