Skip to main content

“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.txt
# additionally install the following dependencies
pip install flake8 pytest wheel
# run all unit tests
pytest --verbose -s
# create wheel
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)

# True
Hentai.exists(doujin.id)

# METAMORPHOSIS
print(doujin.title(Format.Pretty))

# [Tag(id=3981, type='artist', name='shindol', url='https://nhentai.net/artist/shindol/', count=279)]
print(doujin.artist)

# ['dark skin', 'group', ... ]
print([tag.name for tag in doujin.tag])

# 2016-10-18 12:28:49+00:00
print(doujin.upload_date)

# ['https://i.nhentai.net/galleries/987560/1.jpg', ... ]
print(doujin.image_urls)

# get the source
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())

# recommend me something good!
print(Utils.get_random_hentai())

# advanced search with queries
for doujin in Utils.search_by_query('tag:loli', sort=Sort.PopularWeek):
    print(doujin.title(Format.Pretty))

# print all character names from all doujins
for character in Tag.list(Option.Character):
    print(character.name)

# store custom meta data as JSON file to disk
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 --verbose 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.

Metadata

Release files for hentai 3.2.7

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

Source distribution (sdist)

Source distribution for hentai 3.2.7
File Size Uploaded
hentai-3.2.7.tar.gz 1.3 MB Details

Built distribution (wheel)

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

Total release size: 2.6 MB

Release files / hentai-3.2.7.tar.gz

Download URL hentai-3.2.7.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
23be6e91f6ac7199f4b4b00e95db58f641f811db3f6511188b451f1d044d0aab
BLAKE2b-256 checksum
How to use checksums
a71b2d3bcc0d4f2f530e66fd2ea585d00270e0878afdb4408719fc8a56c0eb21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

Release files / hentai-3.2.7-py3-none-any.whl

Download URL hentai-3.2.7-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3df554dba3844ee278fce8345c246ee5ebd1b2e8071f4e74a25c76c8f5498a5e
BLAKE2b-256 checksum
How to use checksums
96269243b6d86ae653acf3ae1026fa598fbd984c0cbd59df749ee962c6ef549d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9

Release history Release notifications | RSS feed

3.2.10

2 release files

3.2.9

2 release files

3.2.8

2 release files

This release

3.2.7 This release

2 release files

3.2.6

2 release files

3.2.5

2 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.3

2 release files

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.5

2 release files

0.0.3

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