Skip to main content

Search Library Genesis. This library enables you to search Library Genesis programmatically.

Project description

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 async and sync functions 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 BookData objects for consistent and predictable data handling.
  • Minimal Dependencies: Built with aiohttp, requests, and rich to 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.

Project details


Download files

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

Source Distribution

libgenesis_api-1.0.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

libgenesis_api-1.0.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file libgenesis_api-1.0.0.tar.gz.

File metadata

  • Download URL: libgenesis_api-1.0.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for libgenesis_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d4587b729cb4fc66a9a0942589693f4ab6bb2cec1994c84c1ce1c5458f183ff3
MD5 cd52c53c7106de730d48b6311b816762
BLAKE2b-256 be980212b96526d7b51ffed3b1d4625452e7c62d85e0695884162cbda2f563d5

See more details on using hashes here.

File details

Details for the file libgenesis_api-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: libgenesis_api-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for libgenesis_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1506b2c1f5aaedb3eef755fb32f63a7e8837c6c2636e5fb04d12313c5d4acc9c
MD5 540c14c642df7b145c8b4c789d74ffa0
BLAKE2b-256 2e5d8edeb8f80de4a7c9ada9794ae223469db2c42658f9e8b050e44e3655911e

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