Skip to main content

A library to access the Project Gutenberg API

Project description

py-gutenberg

Install from pip Tests Status Build Status License Latest Release Version Number Supported Python Versions

Overview

The py-gutenberg package is a Python library that provides methods to access the Project Gutenberg library. Users can search for books based on a variety of metadata, get full texts in various formats, and retrieve metadata for books by their ID number.

Installation

⚠️ This package has only been tested on Python 3.7 and above. There are no plans for a Python 2 version.

The package can be installed using the pip package manager:

pip install py-gutenberg

Usage

You should import the module like so:

from gutenberg import GutenbergAPI

The GutenbergAPI constructor defaults to using the public instance of the Gutendex API, https://gutendex.com. If you are self-hosting the API, you can specify the IP address or URL of your instance with the instance_url parameter.

# Uses the public instance
gb = GutenbergAPI()
# Uses a self-hosted instance
gb_private = GutenbergAPI(instance_url="https://gutendex-two.com")

Book Lists and Searching

Here's a simple example to get a list of the most recently uploaded books:

gb.get_all_books()

Or, to get only public domain books:

gb.get_public_domain_books()

Individual Books

To get an individual book's metadata:

gb.get_book_metadata()

Or, to get the full text of a book:

gb.get_book_text()

Full usage information is available in the documentation

Thanks

This module is built on the wonderful but unofficial API built by @garethbjohnson over at gutendex.com. I have no reason to believe the hosting they've setup is meant to sustain more than a few concurrent users, so please be kind a limit your requests where possible. Additionally, if you intend to use this in a production environment, it is highly encouraged that you self-host.

Read about self-hosting the API here!

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

py-gutenberg-1.0.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

py_gutenberg-1.0.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file py-gutenberg-1.0.2.tar.gz.

File metadata

  • Download URL: py-gutenberg-1.0.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for py-gutenberg-1.0.2.tar.gz
Algorithm Hash digest
SHA256 00d40f2ee2200f737ac4c4ca6bf8fc5d9ef402950f488a3f6c9509ff5626c27f
MD5 36ca51f6b8c91e587c65fab638bc00dd
BLAKE2b-256 e9a9e15d14aa4e536b865f9fea70fe788c429d1b06848477b9f2708ba091b414

See more details on using hashes here.

File details

Details for the file py_gutenberg-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for py_gutenberg-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7cdf5d8ce6b4b049bb0681d716f09e4c0040f097ea9db764b2cfb95ec274c87
MD5 73b85dc7f588edc9dc5e3a7d8eaa2494
BLAKE2b-256 30fe34f19de3d5133f61278ce86a365ca146fec01b005f655779d05f0a3d313b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page