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:

Which, transformed into an HTTP address using the "kg" prefix provided in the API search results, is:

Which resolves (via a 301) to:

Compare this to the Knowledge Panel share URL when one searches for "donald trump":

Resolves (via a 301) to:

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:

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:

It turns out this also works when using the "kg" URL provided in Knowledge Graph API search results:

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:

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):

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:

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  
Shared publiclyView activity