Skip to main content
https://raw.githubusercontent.com/Ombucha/akinator.py/main/banner.png PyPI version PyPI downloads Lines of code Repository size

A modern, easy-to-use Python wrapper for the Akinator web game, supporting both synchronous and asynchronous usage.

Background

Originally, there was a popular Python library called akinator.py, which provided a simple interface to interact with the Akinator API. However, this library suddenly disappeared from public repositories without notice. In response, a mirror was created here to preserve its functionality. Unfortunately, it too stopped working after Akinator made changes to their backend API. Later, another library called akipy emerged to fill the gap, but it also became non-functional when Cloudflare protection was introduced on Akinator’s endpoints. This library revives Akinator interaction by replacing the standard requests library with cloudscraper, allowing it to bypass Cloudflare’s anti-bot measures and restoring full functionality.

Features

  • Play Akinator in Python (sync and async)

  • Supports all official Akinator languages and themes

  • Simple, Pythonic interface

  • Type hints for better editor support

  • Custom exceptions for robust error handling

  • Well-tested and documented

  • Actively maintained and open source

Requirements

Installation

To install the latest stable version:

python3 -m pip install akinator

To install the development version:

git clone https://github.com/Ombucha/akinator.py
cd akinator.py
python3 -m pip install -e .

Getting Started

Synchronous Example

import akinator

aki = akinator.Akinator()
aki.start_game()

while not aki.finished:
    print(f"\nQuestion: {str(aki)}")
    user_input = input(
        "Your answer ([y]es/[n]o/[i] don't know/[p]robably/[pn] probably not, [b]ack): "
    ).strip().lower()
    if user_input == "b":
        try:
            aki.back()
        except akinator.CantGoBackAnyFurther:
            print("You can't go back any further!")
    else:
        try:
            aki.answer(user_input)
        except akinator.InvalidChoiceError:
            print("Invalid answer. Please try again.")

print("\n--- Game Over ---")
print(f"Proposition: {aki.name_proposition}")
print(f"Description: {aki.description_proposition}")
print(f"Pseudo: {aki.pseudo}")
print(f"Photo: {aki.photo}")
print(f"Final Message: {aki.question}")

Asynchronous Example

import asyncio
import akinator

aki = akinator.Akinator()

async def play():
    await aki.start_game()

    while not aki.finished:
        print(f"\nQuestion: {str(aki)}")
        user_input = input(
            "Your answer ([y]es/[n]o/[i] don't know/[p]robably/[pn] probably not, [b]ack): "
        ).strip().lower()
        if user_input == "b":
            try:
                await aki.back()
            except akinator.CantGoBackAnyFurther:
                print("You can't go back any further!")
        else:
            try:
                await aki.answer(user_input)
            except akinator.InvalidChoiceError:
                print("Invalid answer. Please try again.")

    print("\n--- Game Over ---")
    print(f"Proposition: {aki.name_proposition}")
    print(f"Description: {aki.description_proposition}")
    print(f"Pseudo: {aki.pseudo}")
    print(f"Photo: {aki.photo}")
    print(f"Final Message: {aki.question}")

asyncio.run(play())

Advanced Usage

  • Languages: All official Akinator languages are supported (see LANG_MAP in the code).

  • Themes: Use “c” for characters, “a” for animals, “o” for objects (not all themes are available in all languages).

  • Error Handling: All errors raise custom exceptions like CantGoBackAnyFurther, InvalidLanguageError, InvalidChoiceError, and InvalidThemeError.

  • Custom Session: You can pass your own cloudscraper.CloudScraper session for advanced usage.

  • Async and Sync: Both sync and async clients are available for all use cases.

  • Testing: Comprehensive test suite for both sync and async clients.

  • Examples: See the examples/ directory for CLI and bot scripts.

Contributing

Contributions are welcome! Please see the CONTRIBUTING.md file for details.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for akinator 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for akinator 2.1.0
File Size Uploaded
akinator-2.1.0.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for akinator 2.1.0
File Interpreter ABI Platform
akinator-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.9 kB

Release files / akinator-2.1.0.tar.gz

Download URL akinator-2.1.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3828a5a2d32da54595a3c2ae20b8ba3030b4bd27d7b73a7ab4c5f9138e0997e7
BLAKE2b-256 checksum
How to use checksums
e3c188dbb73cdfc4d8a14fdb28c12182c62ca18e1904a8adc3cf1f52a40cb704
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / akinator-2.1.0-py3-none-any.whl

Download URL akinator-2.1.0-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a8e3480608d4629c4eded5e9ab2af35745c8151772cd78e624dcaadea7ed714
BLAKE2b-256 checksum
How to use checksums
647d8446e368fd04ccd15f888bdff4ed2ee238fdb01769752329b8c08fa79f16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page