knowledge-node
Simple Node.js module for Google Graph Knowledge API.
Module Usage
Types
Returns all possible types
to build search
parameters.
Example
const Knowledge = serverKey: '<Your Google Server Key>' ; const allTypes = Knowledgetypes; console; //"types": {// "book": "Book",// "bookSeries": "BookSeries",// "educationalOrganization": "EducationalOrganization",// ...//}
Build Parameters
Builds parameter object to be used on search
request.
Parameter | Type | Required | Information |
---|---|---|---|
query | String | Yes | |
limit | Number | No | Default: 20 |
indent | Boolean | No | Defaut: true |
types | Array[Types] | Yes |
Example
const Knowledge = serverKey: '<Your Google Server Key>' ; const query = 'Harry Potter';const types = Knowledgetypesbook KnowledgetypesbookSeries;const limit = 5;const indent = true; const parameters = Knowledge; //{// "query": "Harry Potter",// "limit": 5,// "indent": true, // "key": "<Google API Key>",// "types": [// "Book",// "BookSeries"// ]//}
Search
Makes search request to Google Knowledge API.
You must define correctly the search
parameters: please read Build Parameters
section.
For more extensive information about errors
and successful body response
, please read Google Knowledge Graph API Documentation.
Example
const Knowledge = serverKey: '<Your Google Server Key>' ; const query = 'Harry Potter';const types = Knowledgetypesbook KnowledgetypesbookSeries; const params = Knowledge;return Knowledge ;
Test
First you should follow the Google Knowledge Graph Search API Prerequisites, so you have your Google Account setup.
Edit ./test/fixtures/auth.json file and add your Google Server Key. Install the dev dependencies and run the tests:
$ npm install
$ npm test
License
Licensed under the MIT License.