brain-api

API Wrapper for the Brain API

Usage no npm install needed!

<script type="module">
  import brainApi from 'https://cdn.skypack.dev/brain-api';
</script>

README

Brain API

With this module you can easily use the Brain API

Info

The module and API are still in the alpha phase. So it could be that a lot of things do not yet work as intended.

Installation

npm install brain-api

Get Token

To get a token you have to register here.

It is free of charge

Usage

const brain = require("brain-api");
const brainBot = new brain();

brainBot.setToken("YOUR_TOKEN");
brainBot.ask("Wer ist Barack Obama?").then(data => {
  console.log(data);
});

Lang Options

You can also optionally specify a language code. The default language code is the one you selected when you registered.

So far you can use these: |Code| Function| |--|--| | de | Returns an German answer | | en | Returns an English answer | |auto|Returns an answer automatically adapted to the question|

const brain = require("brain-api");
const brainBot = new brain();

brainBot.setLang("LANG_CODE"); // (From the upper table)

Example Output

{
BrainSolution:
'Barack Hussein Obama II (/bəˈrɑːk huːˈseɪn oʊˈbɑːmə/ born August 4, 1961) is an American politician and attorney who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African-American president of the United States. He previously served as a U.S. senator from Illinois from 2005 to 2008 and an Illinois state senator from 1997 to 2004.',

FullData: {
name: 'Barack Obama',
link: 'https://en.wikipedia.org/wiki/Barack_Obama',
description: 'Barack Hussein Obama II (/bəˈrɑːk huːˈseɪn oʊˈbɑːmə/ born August 4, 1961) is an American politician and attorney who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African-American president of the United States. He previously served as a U.S. senator from Illinois from 2005 to 2008 and an Illinois state senator from 1997 to 2004.'
}

Input Examples

Cooming Soon ...