Skip to main content

A API wrapper for the AkinatorAPI

Project description

Akinator-python

An API wrapper for the AkinatorAPI

>>pip install akinator-python<<

日本語は -> README_ja

Requirement

  • requests
  • bs4

Usage

Install this module, download example.py and run

example.py

from akinator_python import Akinator

akinator=Akinator(lang="en")
akinator.start_game()
while True:
    try:
        print(akinator.question)
        ans=input("answer:")
        if ans=="b":
            akinator.go_back()
        else:
            akinator.post_answer(ans)
            if akinator.answer_id:
                print(f"{akinator.name} / {akinator.description}")
                ans=input("is it correct?:")
                if ans=="n":
                    akinator.exclude()
                elif ans=="y":
                    break
                else:
                    break
    except Exception as e:
        print(e)
        continue

I have prepared a super simple example code
You can just run and enjoy it in terminal :)
0

Know a little more

Akinator()

  • You can set language, theme, child mode in arguments
  • language=str, The endpoint URL is determined based on this argument
    If nothing is specified, lang=jp Japanese will be selected
  • theme=str, characters or objects or animals
    If nothing is specified, theme=characters characters will be selected
  • child_mode=bool
    default is False

Akinator.start_game()

  • Start the Akinator game
    it will return a first question in str

Akinator.post_answer()

  • answer=str
    Answers are Yes : y No : n I don't know : idk probably : p probably not : pn

Akinator.go_back()

  • Yes, you can go back to the previous question

Akinator.exclude()

  • If Akinator's answer is incorrect, you can restart the question

Akinator.step

  • Always int, you can check the number of questions

Akinator.progression

  • Always float, progress of Akinator's "guess"

Akinator.question

  • Always str, just a question

When Akinator makes a guess

Akinator.name

  • Default is None, when it becomes available str, Character name guessed by Akinator

Akinator.description

  • Same as .name, Character description guessed by Akinator

Akinator.photo

  • Same as .name, photo URL in str Character photo guessed by Akinator

Supplement

.post_ansewer() .go_back() .exclude() are return a dict

Question in progress

{'completion': 'OK', 'akitude': 'serein.png', 'step': '1', 'progression': '0.00000',
 'question_id': '464', 'question': 'Is your character a girl?'}

When Akinator makes a guess

{'completion': 'OK', 'id_proposition': '309720', 'id_base_proposition': '10657795', 'valide_contrainte': '1',
 'name_proposition': 'Arihara Nanami', 'description_proposition': 'Riddle Joker', 
 'flag_photo': '2', 'photo': 'https://photos.clarinea.fr/BL_2_en/600/partenaire/p/10657795__894179331.png', 'pseudo': 'MrSand', 'nb_elements': 1}

Contacts

Discord server / https://discord.gg/aSyaAK7Ktm
Discord username / .taka.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Akinator-python-1.6.0.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file Akinator-python-1.6.0.tar.gz.

File metadata

  • Download URL: Akinator-python-1.6.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for Akinator-python-1.6.0.tar.gz
Algorithm Hash digest
SHA256 6dc0ecb14901a7ec77e12c99d9cc77647c624de0bb20e849c1c334e4ed2d615f
MD5 d5921317252d54e4282f12a1bec4d19c
BLAKE2b-256 f229e9a16eeaca0da11faa2ff814827743a78624b98d29ba65a4c79c0455b011

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page