Skip to main content

Bookshare API Wrapper

Tests Python 3.8+

Python wrapper for Bookshare API v1. Note: API v1 is officially sunset but still functional.

Installation

uv add bookshare

Authentication

All three required: API key, Bookshare username, and Bookshare password.

from bookshare import BookshareAPI

# Pass all credentials at initialization
api = BookshareAPI(
    API_key="bookshare_api_key",
    username="bookshare_username",
    password="bookshare_password"
)

# Or set username/password separately
api = BookshareAPI(API_key="bookshare_api_key")
api.set_credentials("bookshare_username", "bookshare_password")  # Required before use

Usage

# Search
results = api.title_search("python programming", page=1)
results = api.author_search("asimov", page=1)
results = api.full_text_search("robotics", page=1)

# Lookup
book = api.isbn_lookup("9780134685991")
book = api.book_lookup("12345")

# Browse
latest = api.latest(page=1)
popular = api.popular(page=1)

# Download
content = api.download(id="12345", version=1, chunk_size=8192)
for chunk in content:
    # Process chunk
    pass

Command-Line Interface

Installing the package also provides a bookshare command. Credentials come from --api-key / --username / --password flags, or the BOOKSHARE_API_KEY, BOOKSHARE_USERNAME, and BOOKSHARE_PASSWORD environment variables.

# Search the catalog (default --by title; also author, fts, all, isbn)
bookshare search "python programming"
bookshare search "asimov" --by author
bookshare search "9780134685991" --by isbn

# Machine-readable output (raw book records)
bookshare search "robotics" --by fts --json

# Download a book by its numeric id (from search results)
bookshare download 12345 -o book.epub          # write to a file
bookshare download 12345 > book.epub           # or stream to stdout

Run it without installing via uvx:

BOOKSHARE_API_KEY=... uvx bookshare search "asimov" --by author --json

API Methods

Search:

  • title_search(title, page=1)
  • author_search(author, page=1)
  • author_and_title_search(text, page=1)
  • full_text_search(text, page=1)
  • category_search(category, page=1)
  • grade_search(grade, page=1)

Lookup:

  • isbn_lookup(isbn)
  • book_lookup(id)
  • periodical_lookup(id)
  • periodical_edition_lookup(id, edition)

Browse:

  • latest(page=1)
  • popular(page=1)
  • periodical_list(page=1, limit=100)

Reference:

  • category_list()
  • grade_list()

Content:

  • download(id, version=1, chunk_size=8192) - Returns iterator

User:

  • user_info()

Development

# Setup
git clone https://github.com/accessibleapps/bookshare.git
cd bookshare
uv sync --extra dev

# Test
uv run pytest
uv run pytest --cov=bookshare

# Lint
uv run ruff check .
uv run ruff format .

Download files

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

Source Distribution

bookshare-0.13.0.tar.gz (552.2 kB view details)

Uploaded Source

Built Distribution

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

bookshare-0.13.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file bookshare-0.13.0.tar.gz.

File metadata

  • Download URL: bookshare-0.13.0.tar.gz
  • Upload date:
  • Size: 552.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for bookshare-0.13.0.tar.gz
Algorithm Hash digest
SHA256 d611c241d6bed67e738f9ba23b484131dc85f7155f8edc315cfe2f3fc7ddf73c
MD5 466e255e7ac46c7803091cfcaa9d9f7d
BLAKE2b-256 01099e3bb020546a99cfdf74dc8aa23c4f81f9c89a3bdc44cafa095dedc9dd37

See more details on using hashes here.

File details

Details for the file bookshare-0.13.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bookshare-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce27de42a88dbfc405f8854b626e2281e9d5a25b4d1e0955aa681a88fd6e7d70
MD5 46871e87e13b80b594eab2d2251421bf
BLAKE2b-256 2f578dcaea225d0a3d7cca0d686de13171e7f592a2b4332c5c6aab7fcc7b174f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 files

0.11.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page