Libgen API
Libgen-API-Modern is a lightweight, simple, and blazingly fast Python library for interacting with Library Genesis. It provides both synchronous and asynchronous methods to search for and resolve download links for books, all with a modern and elegant interface.
This library focuses exclusively on the modern Libgen web interface, ensuring high performance and reliability without the need for fallbacks to older, less structured APIs.
Features
- Blazingly Fast: Optimized for speed with efficient HTML parsing and direct API interaction.
- Async & Sync: Provides both
asyncandsyncfunctions to fit any project architecture. - Simple & Elegant API: A clean and minimal set of functions (
search_async,search_sync). - Direct Download Link Resolution: Intelligently parses mirror pages to find the most direct and reliable download links.
- Robust Data Models: Search results are returned as
BookDataobjects for consistent and predictable data handling. - Minimal Dependencies: Built with
aiohttp,requests, andrichto keep the library lightweight. - Versatile CLI: A powerful command-line tool for searching, downloading, and interactive sessions.
Installation
pip install libgen-api-modern
Usage as a Library
The core functions are search_async and search_sync. Both return a list of BookData objects.
Asynchronous Example
import asyncio
from libgen import search_async, LibgenError
async def main():
try:
results = await search_async("the art of war")
if not results:
print("No results found.")
return
for book in results:
print(f"Title: {book.title}")
print(f"Authors: {', '.join(book.authors) if book.authors else 'N/A'}")
if book.download_links and book.download_links.get_link:
print(f"Direct Download: {book.download_links.get_link}")
print("-" * 40)
except LibgenError as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
asyncio.run(main())
Synchronous Example
from libgen import search_sync, LibgenError
try:
results = search_sync("the art of war")
if not results:
print("No results found.")
else:
for book in results:
print(f"Title: {book.title}")
print(f"Authors: {', '.join(book.authors) if book.authors else 'N/A'}")
if book.download_links and book.download_links.get_link:
print(f"Direct Download: {book.download_links.get_link}")
print("-" * 40)
except LibgenError as e:
print(f"An error occurred: {e}")
Usage as a Command-Line Tool
The CLI offers three main commands.
Search
libgen search "the art of war"
Download
Download a file directly from a known Libgen mirror URL.
libgen download "MIRROR_URL" --output "mybook.pdf"
Interactive Mode
For repeated searches and downloads in a single session.
libgen interactive
License
This project is licensed under the MIT License.
Metadata
Release files for libgenesis-api 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| libgenesis_api-1.0.0.tar.gz | 11.8 kB | Without provenance | Details for libgenesis_api-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| libgenesis_api-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for libgenesis_api-1.0.0-py3-none-any.whl |
Total release size: 24.9 kB
Release files / libgenesis_api-1.0.0.tar.gz
| Download URL | libgenesis_api-1.0.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4587b729cb4fc66a9a0942589693f4ab6bb2cec1994c84c1ce1c5458f183ff3
|
|
BLAKE2b-256 checksum How to use checksums |
be980212b96526d7b51ffed3b1d4625452e7c62d85e0695884162cbda2f563d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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}
|
Release files / libgenesis_api-1.0.0-py3-none-any.whl
| Download URL | libgenesis_api-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1506b2c1f5aaedb3eef755fb32f63a7e8837c6c2636e5fb04d12313c5d4acc9c
|
|
BLAKE2b-256 checksum How to use checksums |
2e5d8edeb8f80de4a7c9ada9794ae223469db2c42658f9e8b050e44e3655911e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","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}
|
Security for libgenesis-api 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.