Hacking the Knowledge Graph

Google recently facilitated sharing of Knowledge Graph Panels, and some other features (http://bit.ly/1q6hM6o - thanks +Jennifer Slegg).

This comes not too far on the heels of Google's release of the Knowledge Graph Search API in December of 2015 (http://bit.ly/1ZfYwPI).

In playing around with the URL now available from a Knowledge Panel, it became immediately apparent (and wasn't surprising) that the Knowledge Graph identifier there was the same one you can retrieve through a search using the Knowledge Graph API search.

For example, the ID returned from Knowledge Graph for everyone's favorite orange-haired politician is:
kg:/m/0cqt90

Which, transformed into an HTTP address using the "kg" prefix provided in the API search results, is:
http://g.co/kg/m/0cqt90

Which resolves (via a 301) to:
https://www.google.com/search?q=knowledge+graph+search+api&kponly&kgmid=/m/0cqt90

Compare this to the Knowledge Panel share URL when one searches for "donald trump":
https://g.co/kgs/WfM0k

Resolves (via a 301) to:
https://www.google.com/search?kgmid=/m/0cqt90&hl=en-US&kgs=8e22a3957a443dc9&q=Donald+Trump&shndl=0&source=sh/x/kp&entrypoint=sh/x/kp

The difference is, as per the clue offered by the parameter "kponly" in the fully-resolved URL from the Knowledge Graph Search API results, is that g.co/kg/* returns only the Knowledge Graph Panel, without any search context (the query term displayed is actually, for all Panels retrieved via the prefix URL, is "knowledge graph search api") - again:
http://g.co/kg/m/0cqt90

However, deconstructing the URL to which a shortened Knowledge Panel share resolves exposes some parameters that can be used to expose a Knowledge Panel in a more meaningful content.

By modifying the "hl" parameter you can, of course, change the language of the content displayed - including the content of the Knowledge Panel:
https://www.google.com/search?kgmid=/m/0cqt90&hl=fr-FR&kgs=8e22a3957a443dc9&q=Donald+Trump&shndl=0&source=sh/x/kp&entrypoint=sh/x/kp

It turns out this also works when using the "kg" URL provided in Knowledge Graph API search results:
https://www.google.com/search?q=knowledge+graph+search+api&kponly&kgmid=/m/0cqt90&hl=fr-FR

But by hacking the structure of the share URL you can provide users with search results and an accompanying Knowledge Panel where the query is only related to the entity in the search result:
https://www.google.com/search?kgmid=/m/0cqt90&hl=en-US&kgs=8e22a3957a443dc9&q=donald+trump+nuclear+weapons&shndl=0&source=sh/x/kp&entrypoint=sh/x/kp

Or, as per the call-out image (which is a direct screenshot, not a Photoshop treatment), not related to the Knowledge Panel at all (in this case the query might be related - I'll the reader decide):
https://www.google.com/search?kgmid=/m/0cqt90&hl=en-US&kgs=8e22a3957a443dc9&q=baboon&shndl=0&source=sh/x/kp&entrypoint=sh/x/kp

I don't know what the other parameters do (though "source" and "entrypoint" seem straightforward enough).  "kgmid" and "q" in themselves seem sufficient to generate a search result accompanied by a Knowledge Panel:
https://www.google.com/search?kgmid=/m/0cqt90&q=baboon&shndl=0

None of this, at first blush, has earth-shattering practical implications, although I now know how to generate a Knowledge Panel in a language other than English, and - should it ever become useful - I know now how to send a user to a Knowledge Panel with the search query context of my choosing.

Oh, and worth noting the share URL now provides a method of retrieving a Knowledge Graph ID without using the search API:  if you're able to generate a Knowledge Panel via search, you can now simply expose the ID by copying and pasting the share link.

#knowledgegraph   #google   #identifiers  
Photo
Shared publiclyView activity