An Introduction to Google’s Knowledge Graph Search API

The Knowledge Graph Search API can be a powerful tool in the hands of the right SEO.

It allows a user to interrogate the Knowledge Graph database. By entering a search term, with some other parameters, the API returns the associated entities for that search term, thereby opening a window on how Google is organising information.

Let’s take a look.

First up, you’ll want to go here, for the tool and you’ll be presented with an interface that looks like this:

This article is only intended as an introduction to the API so, for our purposes, we are going to look at queries.

But before getting into that, it’s probably worth talking a bit about what entities and the Knowledge Graph, actually are. After all, this is what this API is all about.

Entities and the Knowledge Graph

Entities are things. They are events, places, brands, dates and people; names of flowers, lists of astronauts, chemical compounds, airports, works of art, institutions and places on a map, are all entities.

The knowledge graph consists of information about those entities. So, if the entity is Barack Obama, then the knowledge graph would consist of his date of birth, his education; the fact that he was a US president and other ‘essential’ facts.

When you search on Google (a query), for instance ‘does Barack Obama eat apples?’ then we can expect that the entities, ‘Barack Obama’ and ‘apple’ are factored into how that query is returned, alongside Knowledge Graph elements for those queries.

And this is what this tool does: it shows you the entities that are referenced by certain search queries.

Example Search

So, without inputting any other information, let’s see what happens when we enter ‘Barack Obama’ into the query field and click ‘execute’.

What happens is we get a retuned JSON file, using the vocabulary of Schema.org. And don’t worry, if you are, in any way, worried about reading code. This stuff should be easy enough to get your head around.


{
  "@context": {
    "resultScore": "goog:resultScore",
    "goog": "http://schema.googleapis.com/",
    "detailedDescription": "goog:detailedDescription",
    "@vocab": "http://schema.org/",
    "kg": "http://g.co/kg",
    "EntitySearchResult": "goog:EntitySearchResult"
  },
  "@type": "ItemList",
  "itemListElement": [
    {
      "resultScore": 22405.169921875,
      "result": {
        "@type": [
          "Thing",
          "Person"
        ],
        "image": {
          "contentUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSkJEGgR2wJ0bp8DhOXx2QuexPLTslqt0v-G2iTiDWVp3iRhSnc",
          "url": "https://fr.m.wikipedia.org/wiki/Fichier:BarackObama2005portrait.jpg"
        },
        "detailedDescription": {
          "articleBody": "Barack Hussein Obama II is an American statesman, politician and former attorney who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African American to be elected to the presidency. ",
          "url": "https://en.wikipedia.org/wiki/Barack_Obama",
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
        },
        "@id": "kg:/m/02mjmr",
        "description": "44th U.S. President",
        "name": "Barack Obama",
        "url": "https://www.barackobama.com/"
      },
      "@type": "EntitySearchResult"
    },
    {
      "@type": "EntitySearchResult",
      "result": {
        "image": {
          "url": "https://en.wikipedia.org/wiki/Presidency_of_Barack_Obama",
          "contentUrl": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQGP98ramoxRFniqLdy7O8BOqb1uTBSs2R6StbkQaT6MekFCQ5J"
        },
        "name": "Presidency of Barack Obama",
        "@id": "kg:/m/05b6w1g",
        "@type": [
          "Thing"
        ],
        "detailedDescription": {
          "url": "https://en.wikipedia.org/wiki/Presidency_of_Barack_Obama",
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License",
          "articleBody": "The presidency of Barack Obama began at noon EST on January 20, 2009, when Barack Obama was inaugurated as the 44th President of the United States, and ended on January 20, 2017. "
        }
      },
      "resultScore": 1954.17041015625
    },
    {
      "@type": "EntitySearchResult",
      "result": {
        "@id": "kg:/m/03qccxj",
        "name": "Barack Obama Sr.",
        "@type": [
          "Thing",
          "Person"
        ],
        "description": "Kenyan economist",
        "detailedDescription": {
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License",
          "url": "https://en.wikipedia.org/wiki/Barack_Obama_Sr.",
          "articleBody": "Barack Hussein Obama Sr. was a Kenyan senior governmental economist and the father of Barack Obama, the 44th president of the United States. He is a central figure of his son's memoir, Dreams from My Father. Obama married in 1954 and had two children with his first wife, Kezia. "
        },
        "image": {
          "contentUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQfsSm-kZfrazpdFMtTymmY1UbUwbQS2VU6hsuG_2BcpDF780M7",
          "url": "https://he.m.wikipedia.org/wiki/%D7%A7%D7%95%D7%91%D7%A5:Sarah_Onyango_home-Barack_Obama_Sr_grave-2.jpg"
        }
      },
      "resultScore": 1552.603515625
    },
    {
      "@type": "EntitySearchResult",
      "result": {
        "@type": [
          "Thing",
          "Book"
        ],
        "description": "Book by Nikki Grimes",
        "@id": "kg:/m/04x6ghg",
        "name": "Barack Obama: Son of Promise, Child of Hope"
      },
      "resultScore": 194.46965026855469
    },
    {
      "@type": "EntitySearchResult",
      "resultScore": 131.0160217285156,
      "result": {
        "@id": "kg:/m/05f34xs",
        "@type": [
          "Thing"
        ],
        "detailedDescription": {
          "url": "https://en.wikipedia.org/wiki/Barack_Obama_in_comics",
          "articleBody": "Barack Obama has appeared as a character in comic books published by a number of publishing companies, sometimes appearing as a realistic fictionalized version of himself and sometimes as a spoof.",
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
        },
        "description": "Comic book character",
        "name": "Barack Obama in comics"
      }
    },
    {
      "@type": "EntitySearchResult",
      "resultScore": 71.060264587402344,
      "result": {
        "@type": [
          "Thing"
        ],
        "@id": "kg:/m/09ryzqt",
        "name": "Barack Obama",
        "description": "Fictional character"
      }
    },
    {
      "result": {
        "@type": [
          "Thing"
        ],
        "name": "Barack Obama",
        "@id": "kg:/m/0h2yj33"
      },
      "@type": "EntitySearchResult",
      "resultScore": 24
    },
    {
      "resultScore": 24,
      "@type": "EntitySearchResult",
      "result": {
        "@type": [
          "Thing"
        ],
        "@id": "kg:/g/11b80c5gfl",
        "name": "Barack Obama"
      }
    },
    {
      "result": {
        "name": "Barack Obama",
        "@id": "kg:/m/01077xpc",
        "@type": [
          "Thing"
        ]
      },
      "@type": "EntitySearchResult",
      "resultScore": 24
    },
    {
      "result": {
        "name": "Barack Obama",
        "@id": "kg:/m/011mdr5x",
        "@type": [
          "Thing"
        ]
      },
      "resultScore": 24,
      "@type": "EntitySearchResult"
    },
    {
      "resultScore": 24,
      "result": {
        "@type": [
          "Thing"
        ],
        "@id": "kg:/g/11bwcvl41q",
        "name": "Barack Obama"
      },
      "@type": "EntitySearchResult"
    },
    {
      "result": {
        "description": "Fictional character",
        "@id": "kg:/g/11f03ntswn",
        "name": "Barack Obama",
        "@type": [
          "Thing"
        ]
      },
      "resultScore": 24,
      "@type": "EntitySearchResult"
    },
    {
      "result": {
        "name": "Barack Obama",
        "@type": [
          "Thing"
        ],
        "@id": "kg:/m/0v_3pgz"
      },
      "@type": "EntitySearchResult",
      "resultScore": 24
    },
    {
      "@type": "EntitySearchResult",
      "resultScore": 24,
      "result": {
        "name": "Barack Obama",
        "@type": [
          "Thing"
        ],
        "@id": "kg:/g/11j60b_ylp"
      }
    },
    {
      "resultScore": 24,
      "result": {
        "@type": [
          "Thing"
        ],
        "@id": "kg:/m/0_0x88v",
        "name": "Barack Obama"
      },
      "@type": "EntitySearchResult"
    },
    {
      "result": {
        "@type": [
          "Thing",
          "MusicRecording"
        ],
        "@id": "kg:/m/0g0dxvr",
        "name": "Barack Obama"
      },
      "@type": "EntitySearchResult",
      "resultScore": 24
    },
    {
      "resultScore": 24,
      "@type": "EntitySearchResult",
      "result": {
        "@type": [
          "Thing"
        ],
        "@id": "kg:/m/011cplxv",
        "name": "Barack Obama"
      }
    },
    {
      "result": {
        "name": "Barack Obama",
        "@type": [
          "Thing"
        ],
        "@id": "kg:/g/11f_f4q7m2"
      },
      "resultScore": 24,
      "@type": "EntitySearchResult"
    },
    {
      "@type": "EntitySearchResult",
      "resultScore": 24,
      "result": {
        "@id": "kg:/g/11ftzr25sq",
        "description": "Song by Dorce Gamalama",
        "@type": [
          "Thing"
        ],
        "name": "Barack Obama"
      }
    },
    {
      "@type": "EntitySearchResult",
      "resultScore": 24,
      "result": {
        "name": "Barack Obama",
        "@type": [
          "Thing"
        ],
        "@id": "kg:/g/11hdjd41zx"
     }
    }
  ]
}

How Useful is this for SEOs?

Google says that the API ‘isn’t suitable for use as a production-critical service‘ – agreed – but while placing it front-and-centre in your SEO efforts would be a mistake, it has a role to play in brand development and research.

If Google recognises your company, your event or you, as a person-of-note (an entity, in other words), then the rest of your efforts will prove easier. And this the way to test, whether or not you have achieved entity status for your brand, is to see what connections Google is making for your branded search terms.

There’s a keyword research element to all of this as well. If you can see which entities are related to which search terms then your understanding of what is expected from you, in the content you produce, will increase, leading to a better chance of success.

And then there is a competitive edge. Creating new entities and hijacking existing ones is possible, by nature of Google’s algorithm. A better understanding of the landscape will always raise your game.

One Last Trick

This subject is huge and I’ve made every effort to not even scratch the surface of it, in order to gently push towards a certain mode of thinking for SEO and avoid a sledgehammer approach.

But there is one little trick I quite like for flushing out the primary references Google uses to understand entity based searches (NB they’re almost always Wikipedia entries).

The trick is to use a URL that contains both a search query and an API key for the Knowledge Graph Search API eg

https://kgsearch.googleapis.com/v1/entities:search?query=virgin+media&key=ENTERAPIKEYHERE&limit=1&indent=True

To get an API key all you have to do is visit Google Cloud Services, search for the Knowledge Graph API, go to Credentials and generate a key.

Then, if you replace ENTERAPIKEYHERE for it, in the URL above, you will be able to see the JSON entity for Virgin Media or a query of your choice, as it exists on Google’s database; rendering in the following text, in your browser.


{
  "@context": {
    "detailedDescription": "goog:detailedDescription",
    "EntitySearchResult": "goog:EntitySearchResult",
    "@vocab": "http://schema.org/",
    "kg": "http://g.co/kg",
    "goog": "http://schema.googleapis.com/",
    "resultScore": "goog:resultScore"
  },
  "@type": "ItemList",
  "itemListElement": [
    {
      "resultScore": 47883.06640625,
      "result": {
        "image": {
          "url": "https://commons.wikimedia.org/wiki/File:Virgin_Media.svg",
          "contentUrl": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcT1nNid8Pr2Tgoa1-6Nq1Imu3X7uu1t4-StbwGalWV92dwaIv6w"
        },
        "@type": [
          "Event",
          "Organization",
          "Corporation",
          "Thing",
          "CableOrSatelliteProvider"
        ],
        "detailedDescription": {
          "url": "https://en.wikipedia.org/wiki/Virgin_Media",
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License",
          "articleBody": "Virgin Media is a British telecommunications company which provides telephone, television and internet services in the United Kingdom. Its headquarters are at Green Park in Reading, England. "
        },
        "name": "Virgin Media",
        "url": "http://www.virginmedia.com/",
        "description": "Telecommunications company",
        "@id": "kg:/m/0963jy"
      },
      "@type": "EntitySearchResult"
    }
  ]
}

Pretty nifty, eh?