“De gustibus non est disputandum.”
Python Hentai API Wrapper
English | 简体中文
This python package implements a wrapper class around nhentai's RESTful API.
Please be aware that this is not an official API, technical questions about
nhentai.net should be redirected to
support@nhentai.com.
Further note that the content of this module is generally considered NSFW. Finally,
I would like to comment at this point that you should under no circumstances use
this module to make an unreasonable amount of requests in a short period of time.
Installation
Get the most recent stable release from PyPI:
pip install hentai --only-binary all
Dev Notes for Contributors
Alternatively, if you're looking to make a
contribution
fork this repository and run
python -m venv venv/
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
pip install flake8 pytest wheel
pytest --verbose -s
python setup.py bdist_wheel --universal
Make sure to checkout rec-hentai
so that your work is up-to-date with the next
release candidate. Don't implement any features that are incompatible with
version 3.7+ of python.
Documentation
You can find the documentation
online, or use the wiki
to learn more about this module.
Basic Usage
Hentai
makes it very easy to browse through nhentai.net. It implements a flat
namespace for easy access of all their endpoints:
from hentai import Hentai, Format
doujin = Hentai(177013)
Hentai.exists(doujin.id)
print(doujin.title(Format.Pretty))
print(doujin.artist)
print([tag.name for tag in doujin.tag])
print(doujin.upload_date)
print(doujin.image_urls)
doujin.download(progressbar=True)
Apart from that, hentai.Utils
also provides a handful of miscellaneous helper
methods:
from hentai import Utils, Sort, Option, Tag
from pathlib import Path
print(Utils.get_random_id())
print(Utils.get_random_hentai())
for doujin in Utils.search_by_query('tag:loli', sort=Sort.PopularWeek):
print(doujin.title(Format.Pretty))
for character in Tag.list(Option.Character):
print(character.name)
popular_loli = Utils.search_by_query('tag:loli', sort=Sort.PopularWeek)
custom = [Option.ID, Option.Title, Option.Epos]
Utils.export(popular_loli, filename=Path('popular_loli.json'), options=custom)
See also https://nhentai.net/info/ for more information
on search queries.
Command Line Interface
Starting with version 3.2.4, this module also provides a rudimentary CLI for downloading
doujins within the terminal:
# get help
hentai --help
# download this doujin to the CWD
hentai download --id 177013
# check the module version
hentai --version
Get In Touch
You can reach me at dev.hentai-chan@outlook.com
for private questions and inquires that don't belong to the issue tab.