Socket
Socket
Sign inDemoInstall

knowledge-node

Package Overview
Dependencies
62
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    knowledge-node

Simple Node.js module for Google Knowledge API.


Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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 = require('knowledge-node')({ serverKey: '<Your Google Server Key>' });

const allTypes = Knowledge.types;

console.log(allTypes);

//"types": {
//    "book": "Book",
//    "bookSeries": "BookSeries",
//    "educationalOrganization": "EducationalOrganization",
//    ...
//}

Build Parameters

Builds parameter object to be used on search request.

ParameterTypeRequiredInformation
queryStringYes
limitNumberNoDefault: 20
indentBooleanNoDefaut: true
typesArray[Types]Yes

Example

const Knowledge = require('knowledge-node')({ serverKey: '<Your Google Server Key>' });

const query = 'Harry Potter';
const types = [
    Knowledge.types.book,
    Knowledge.types.bookSeries
];
const limit = 5;
const indent = true;

const parameters = Knowledge.buildParams(query, types, limit, indent);

//{
//    "query": "Harry Potter",
//    "limit": 5,
//    "indent": true, 
//    "key": "<Google API Key>",
//    "types": [
//        "Book",
//        "BookSeries"
//    ]
//}

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 = require('knowledge-node')({ serverKey: '<Your Google Server Key>' });

const query = 'Harry Potter';
const types = [
    Knowledge.types.book,
    Knowledge.types.bookSeries
];

const params = Knowledge.buildParams(query, types);
return Knowledge.search(params)
                .then(body => {
                    //do something with success response
                })
                .catch(error => {
                    //handle error
                });

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.

Keywords

FAQs

Last updated on 23 Apr 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc