New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aki-api

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aki-api

An API for Akinator. Supports up to 15 languages.

  • 7.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-14.88%
Maintainers
1
Weekly downloads
 
Created
Source

aki-api (Akinator)

npm version License: MIT Actions Status

An API for Akinator based in NodeJS.

Installation

npm i aki-api

Regions

 [
  'en',
  'ar',
  'cn',
  'de',
  'es',
  'fr',
  'il',
  'it',
  'jp',
  'kr',
  'nl',
  'pl',
  'pt',
  'ru',
  'tr',
  'id'
]

Usage

const { Aki } = require('aki-api');

const run = async () => {
    const region = 'en';
    const childMode = false;
    const proxy = undefined;

    const aki = new Aki({ region, childMode, proxy });
    await aki.start();
    console.log('question:', aki.question);
    console.log('answers: ', aki.answers);
}

run().catch(console.error);

Output from above console.log

question: Is your character real?
answers: [  
  "Yes",
  "No",
  "Don't know",
  "Probably",
  "Probably not"
]

Get regions that I support

  const { regions } = require('aki-api');
  
  console.log(regions);

Answer a Question (step)

const { Aki } = require('aki-api');

const run = async () => {
    const region = 'en';
    const aki = new Aki({ region });
    
    await aki.start();

    const myAnswer = 0; // yes = 0
    
    await aki.step(myAnswer);

    console.log('question:', aki.question);
    console.log('answers:', aki.answers);
    console.log('progress:', aki.progress);
}

run().catch(console.error);

Win/Show the akinator's guess

Akinator will automatically guess when calling the answer() method
const { Aki } = require('aki-api');

const run = async () => {
    const region = 'en';
    const aki = new Aki({ region });
    
    const guessOrResponse = await aki.answer(); // check if it is a guess by akinator or another question
    
    // if you do not like the answer...
    await aki.continue();
}

run().catch(console.error);

Enable child mode

Simply pass in true or false for the childMode parameter

The child mode prevents showing explicit questions.

const { Aki } = require('aki-api');

const run = async () => {
    const region = 'en';
    const childMode = true;
    const aki = new Aki({ region, childMode });
}

run().catch(console.error);

Example Code for Back

const { Aki } = require('aki-api');

const run = async () => {
    const region = 'en';
    const aki = new Aki({ region });

    await aki.start();

    const myAnswer = 1; // no = 1

    await aki.step(myAnswer);
    await aki.back();

    console.log('question:', aki.question);
    console.log('answers:', aki.answers);
}

run().catch(console.error);

Keywords

FAQs

Package last updated on 15 May 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc