A simple wrapper for Google's Knowledge Graph Search API
google-kgsearch is a wrapper for Google's Knowledge Graph Search API. It is lightweight, simple, and easy to understand.
About Google's Knowledge Graph Search API:
An excerpt from: https://developers.google.com/knowledge-graph/
Some examples of how you can use the Knowledge Graph Search API include:
KGSearch instance with your API Key, store it in a variable (in this case:
kGraph), and then call
const kGraph =let params =query: 'Taylor Swift'types: 'Person'limit: 1kGraph
'@type': 'EntitySearchResult'result:'@id': 'kg:/m/0dl567'name: 'Taylor Swift''@type': objectdescription: 'Singer-songwriter'image: objectdetailedDescription: objecturl: ''resultScore: 280279816
See the example for more information.
google-kgsearch is as simple as installing any other npm module:
$ npm install google-kgsearch --save
To use this API you need an API key. An API key identifies your project to check quotas and access. Go to the Credentials page to get an API key.
Check out Google Developers' guide for more information.
After importing the
google-kgsearch file, you need to initialize a new
KGSearch instance with your
API_TOKEN and store it in a variable (in this case its
const kGraph =
.search() method to search Google's Knowledge Graph.
/* ... */kGraph
kGraph.search(params, callback) method takes
params as a first argument. Under the hood the module converts these into query strings.
It also takes a callback function to handle the data received from the API.
||Enables access to the Google's Knowledge Graph Search API|
||API query parameters (query, types, limit, etc.)|
||A function that handles the response data from the API|
callback takes two arguments:
err(for error handling;
nullif there are no errors)
data(the data returned by the API)
Copyright (c) 2016 Kristian Muñiz