Skip to main content

python interface for communication with AniDB API

Project description


zenchi is a python3 application that communicates with AniDB UDP API. It provides an interface to convert raw responses strings into python objects. It does very little by itself and its only intention is to parse data for other applications to use.

Currently, only Data commands are supported.


pip install -U zenchi


Fairly straightforward:

>>> import zenchi
>>> zenchi.create_socket(anidb_server='', anidb_port=9000)
<socket.socket ...>
({'port': 25065}, 300)

Every command response is a tuple (data, code). data is a dictionary of variable keys containing the parsed response, and code is the response code.

Environment variables

ZENCHI_CLIENTNAME and ZENCHI_CLIENTVERSION should be replaced by your own keys generated at AniDB site. (no guarantee these values are valid at the time of your reading!)



If these values are set, the socket is created automatically and it's much simpler. You can skip the call for create_socket entirely and just call the commands:

>>> import zenchi
>>> zenchi.auth()
({'session': 'ELahj'}, 200)
>>> zenchi.character(1)
(..., 235)

Anime masks

The ANIME command receives a mask as parameter to filter the anime data. zenchi provides an easy way to create these masks with the module zenchi.mappings.anime.mask.

>>> import zenchi.mappings.anime.mask as amask
>>> zenchi.anime(amask.aid | amask.romaji_name | amask.english_name | amask.short_name | amask.year, aid=3433)
({'aid': 3433, 'english_name': 'Mushi-Shi', 'romaji_name': 'Mushishi', 'short_name': ['Mushi'], 'updated_at': datetime.datetime(2019, 11, 10, 19, 55, 18, 1000), 'year': '2005-2006'}, 230)


zenchi uses a very basic optional MongoDB database as cache, named anidb_cache. It uses the environment variable MONGODB_URI to check the connection string. If the variable is not set, a warning will be issued and all cache usage will be ignored (highly unadvised, as per AniDB specifications).

Any operations that use the cache have the parameter use_cache that defaults to True. You can set this to False to skip the cache for that specific command (for example, when you want to update the cached data). All cached data also returns a updated_at key (see example above), which is the last time that data was updated in the database.

If you don't want to use anidb_cache or MONGODB_URI, manually call zenchi.cache.setup with the appropriate values before sending requests to the API.


It's actually fairly simple to add new commands to zenchi, and I just wrote what I personally intend to use. Feel free to send PRs or request something in the issues.


This project is under MIT License.

For data collection and usage, make sure to read AniDB Policies

Project details

Download files

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

Files for zenchi, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size zenchi-1.2.0.tar.gz (16.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page