A basic API wrapper for Akinator.
Project description
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
Python 3.9 or higher
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.
Links
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file akinator-2.0.2.tar.gz.
File metadata
- Download URL: akinator-2.0.2.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1073ed670afc08fc337f468a7bd7fe129e332654e2b0c803375c1646792a4786
|
|
| MD5 |
48e525705bbb7975a1b41f73d5a7710f
|
|
| BLAKE2b-256 |
50a1cb7e77b802b3f1052ff71dca19496130aa4d2906e35139209ad7652946f9
|
File details
Details for the file akinator-2.0.2-py3-none-any.whl.
File metadata
- Download URL: akinator-2.0.2-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76628f0703ccd344260d16bb29dbbdffa7d4426ffa3251386f37b4e1fb8f926e
|
|
| MD5 |
a36fb5f996a90be0ea7b862e00fd668d
|
|
| BLAKE2b-256 |
f7a722748a01a658962fd97de9f9ffc928b5ce9ab9c42b50294ab184cb3a7456
|