@aqul/akinator-api
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Akinator API

Install

npm install @aqul/akinator-api

Usage

Simple Usage

const { Akinator, AkinatorAnswer } = require("@aqul/akinator-api")

const run = async () => {
  const region = "en"
  const api = new Akinator({ region, childMode: false })
  await api.start()
  console.log(`Question: ${api.question}, progress: ${api.progress}`)

    // To answer
  await api.answer(AkinatorAnswer.Yes) // or you can use 0-4
  console.log(`Question: ${api.question}, progress: ${api.progress}`)

  // To check is win or not
  while (!api.isWin) {
    await api.answer(Math.floor(Math.random() * 5)) // random 0-5
    console.log(`Question: ${api.question}, progress: ${api.progress}`)

    // To back last question
    if (Math.floor(Math.random() * 10) + 1 < 4) {
      await api.cancelAnswer()
      console.log(`Question: ${api.question}, progress: ${api.progress}`)
    }
  }

  // if is win
  if (api.isWin) {
    console.log(api.sugestion_name)
    console.log(api.sugestion_desc)
    console.log(api.sugestion_photo)
  }
}

run()

To check region

const { regions } = require("@aqul/akinator-api")
console.log(regions)

Use proxy

const { Akinator } = require("@aqul/akinator-api")
const tunnel = require("tunnel")

const httpsAgent = tunnel.httpsOverHttp({
  proxy: {
    host: "xxx.xxx.xxx",
    port: 8080,
    proxyAuth: "username:password"
  }
})

const region = "en"
const api = new Akinator({ region, childMode: false, config: {
  httpsAgent
}})

Package Sidebar

Install

npm i @aqul/akinator-api

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

12.5 kB

Total Files

13

Last publish

Collaborators

  • aqul