Skip to main content

akipy

PyPI version Downloads Python Version License Repo Size

A Python wrapper library for the Akinator game API. Akinator is the popular web-based game that guesses characters you're thinking of by asking a series of questions. This library allows you to integrate Akinator's functionality into your Python applications with both synchronous and asynchronous support.

Table of Contents

Features

  • Both synchronous and asynchronous API support
  • Context manager support for automatic resource cleanup
  • Type hints for better IDE support
  • Comprehensive error handling with custom exceptions
  • Multiple language support
  • Child mode support
  • Optional Cloudflare bypass via FlareSolverr, TRAWL, or any FlareSolverr v2-compatible solver

Quick Links

Installation

pip install akipy

Usage

There is both synchronous and asynchronous variants of akipy available.

Synchronous: from akipy import Akinator

Asynchronous: from akipy.async_akinator import Akinator

I'll provide a sample usage for synchronous usage of Akinator. All the examples are also in the project's examples folder. So please check them out as well.

import akipy

aki = akipy.Akinator()
aki.start_game()

while not aki.win:
    ans = input(str(aki) + "\n\t")
    if ans == "b":
        try:
            aki.back()
        except akipy.CantGoBackAnyFurther:
            pass
    else:
        try:
            aki.answer(ans)
        except akipy.InvalidChoiceError:
            pass

print(aki)
print(aki.name_proposition)
print(aki.description_proposition)
print(aki.pseudo)
print(aki.photo)

Cloudflare / challenge solvers (optional)

If Akinator is behind Cloudflare, pass a solver that speaks the FlareSolverr v2 POST /v1 API:

Solver Notes
FlareSolverr Cloudflare proxy
TRAWL FlareSolverr-compatible API
Other v2-compatible proxies Same request format

Direct requests run first. On a Cloudflare challenge, akipy calls the solver once, applies cookies and User-Agent to the client, then continues over normal HTTP.

Run a solver locally

FlareSolverr:

docker run -d --name=flaresolverr -p 8191:8191 ghcr.io/flaresolverr/flaresolverr:latest

TRAWL:

docker run -d --name=trawl -p 8191:8191 --shm-size=1gb ghcr.io/germondai/trawl:latest

Use with akipy

import akipy

# FlareSolverr, TRAWL, or any compatible host
aki = akipy.Akinator(solver_url="http://localhost:8191")
# aki = akipy.Akinator(solver_url="https://trawl.example.com")
# aki = akipy.Akinator(solver_url="localhost:8191")  # defaults to http
# aki = akipy.Akinator(solver_url="https://fs.example.com/v1")

aki.start_game()

Or set the env var:

export AKIPY_SOLVER_URL="http://localhost:8191"

AKIPY_FLARESOLVERR_URL and flaresolverr_url= still work as aliases.

CI integration tests start FlareSolverr as a service on the runner (http://127.0.0.1:8191). Remote public solvers are often unreachable from GitHub Actions (403 from edge WAF).

Errors

Exception When
CloudflareBlockedError Challenge detected and no solver_url configured
SolverError Solver unreachable or returned a non-ok status (FlareSolverrError is an alias)

Contributing

For contributing to this library, please check CONTRIBUTING.md

Download files

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

Source Distribution

akipy-1.6.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

akipy-1.6.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file akipy-1.6.0.tar.gz.

File metadata

  • Download URL: akipy-1.6.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for akipy-1.6.0.tar.gz
Algorithm Hash digest
SHA256 4af780bc76cf8a9d2771c33ea6b0ca89badd606696b90adf01c631d457a75614
MD5 2a8fdbc91925f692bc8bee020f6d9127
BLAKE2b-256 afb023325f83dfccc420d2950d4344c372b61930a19eda1c2df748fd0b511458

See more details on using hashes here.

File details

Details for the file akipy-1.6.0-py3-none-any.whl.

File metadata

  • Download URL: akipy-1.6.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for akipy-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da60a27324e282750bcd193bfdba67965e9cf067f9dd1e987fb567cbdbab6ae6
MD5 db8c24f62f49d1b92a1af1309ed47cde
BLAKE2b-256 01de4a9fa765b3f3af8a0ea94259fdf895e3e14e18512491375ed5727d9c3e49

See more details on using hashes here.

Supported by

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