Skip to main content

catholic-bible

CI Build License PyPI Version versions

Provides an API for scraping the USCCB Bible website of the United States Conference of Catholic Bishops, returning structured verse data in both English and Spanish.

About catholic-bible

This package facilitates pulling books, chapters, and individual verses from the Catholic Bible. Please open new issues for any bugs you find — support is greatly appreciated! If you have a new feature, feel free to open a pull request.

Installation

To install catholic-bible from PyPI:

$ pip install catholic-bible

To install from source as editable:

$ pip install -e .

API Usage

Fetch a single chapter

import asyncio
from catholic_bible import USCCB, models

async def main() -> None:
    async with USCCB() as usccb:
        chapter = await usccb.get_chapter("genesis", 1)
        if chapter:
            print(chapter.title)          # "Genesis, Chapter 1"
            print(chapter.url)
            for section in chapter.sections:
                if section.heading:
                    print(section.heading)
                for verse in section.verses:
                    print(verse)          # "1[a] In the beginning..."

asyncio.run(main())

Fetch a single verse

import asyncio
from catholic_bible import USCCB, models

async def main() -> None:
    async with USCCB() as usccb:
        verse = await usccb.get_verse("john", 3, 16)
        if verse:
            print(verse.text)

asyncio.run(main())

Fetch all chapters of a book

import asyncio
from catholic_bible import USCCB, models

async def main() -> None:
    async with USCCB() as usccb:
        chapters = await usccb.get_book("psalms")
    for chapter in chapters:
        print(chapter.title)

asyncio.run(main())

Save chapters to JSON

import asyncio
import json
from pathlib import Path
from catholic_bible import USCCB, models

async def main() -> None:
    async with USCCB() as usccb:
        chapters = await usccb.get_book("genesis")
    out = Path("genesis")
    out.mkdir(exist_ok=True)
    for chapter in chapters:
        (out / f"chapter-{chapter.number:04d}.json").write_text(
            json.dumps(chapter.to_dict(), ensure_ascii=False, indent=2)
        )

asyncio.run(main())

Fetch in Spanish

Pass language=models.Language.SPANISH to any method:

import asyncio
from catholic_bible import USCCB, models

async def main() -> None:
    async with USCCB() as usccb:
        chapter = await usccb.get_chapter("genesis", 1, language=models.Language.SPANISH)
        if chapter:
            print(chapter)

asyncio.run(main())

Browse the book catalogue

from catholic_bible import constants

# Attribute access
print(constants.OLD_TESTAMENT_BOOKS.Genesis.num_chapters)   # 50
print(constants.NEW_TESTAMENT_BOOKS.Matthew.name)           # "Matthew"
print(constants.NEW_TESTAMENT_BOOKS.Corinthians1.name)      # "1 Corinthians"

# All 73 books in canonical order
for book in constants.ALL_BOOKS:
    print(book.name, book.num_chapters)

# Lookup by URL name
genesis = constants.BIBLE_BOOKS["genesis"]
print(genesis.short_abbreviation)  # "Gn"
print(genesis.long_abbreviation)   # "Gen"

Book lookup utilities

Books can be looked up by full name, URL name, or abbreviation (case-insensitive):

from catholic_bible.utils import lookup_book, book_url_name

book = lookup_book("Gen")          # long abbreviation
book = lookup_book("Gn")           # short abbreviation
book = lookup_book("genesis")      # URL name (lowercase, no spaces)
book = lookup_book("Genesis")      # full display name
book = lookup_book("Song of Songs")

print(book_url_name(book))         # "songofsongs"

CLI Usage

# List all 73 books
python -m catholic_bible list-books

# List only Old Testament books
python -m catholic_bible list-books --testament old

# List only New Testament books
python -m catholic_bible list-books --testament new

# Fetch a chapter and print to stdout
python -m catholic_bible get-chapter --book genesis --chapter 1

# Fetch a chapter and save to JSON
python -m catholic_bible get-chapter --book genesis --chapter 1 --save genesis-1.json

# Fetch a single verse
python -m catholic_bible get-verse --book john --chapter 3 --verse 16

# Fetch an entire book (all chapters)
python -m catholic_bible get-book --book psalms

# Save all chapters of a book to a directory
python -m catholic_bible get-book --book genesis --save-dir ./genesis/

# Fetch in Spanish
python -m catholic_bible get-chapter --book genesis --chapter 1 --language SPANISH
python -m catholic_bible get-book --book genesis --language SPANISH --save-dir ./genesis-es/

Key Types

Type Description
USCCB Async client — use as an async context manager
BibleChapter A parsed chapter with book, number, language, url, title, sections
BibleSection A named section within a chapter (heading, verses)
BibleVerse A single verse (number, text, footnote_refs)
Language Language.ENGLISH or Language.SPANISH
BibleBookInfo Book metadata (name, title, short_abbreviation, long_abbreviation, num_chapters)

Documentation

The documentation for catholic-bible can be found here or in the project's docstrings.

Development

Setup Python Environment

uv install
uvx pre-commit install

Re-lock dependencies

uv lock

Run code

uv run python -m catholic_bible

Generating test fixtures

# Fetch and save a chapter for use as a test fixture
python -m catholic_bible get-chapter --book genesis --chapter 1 --save tests/data/genesis-chapter-1.json

Run tests

uv run pytest

Metadata

Release files for catholic-bible 0.2.0

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

Source distribution (sdist)

Source distribution for catholic-bible 0.2.0
File Size Uploaded
catholic_bible-0.2.0.tar.gz 40.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for catholic-bible 0.2.0
File Interpreter ABI Platform
catholic_bible-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.0 kB

Release files / catholic_bible-0.2.0.tar.gz

Download URL catholic_bible-0.2.0.tar.gz
Size 40.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5966272908f1d64e0d97c5a17230ab115dc859cfd4208d100e7c5dfa906e13a0
BLAKE2b-256 checksum
How to use checksums
79f11a7cc56411b2d35b38049f2c95687cb093e58ad62ef645663797e7cc5738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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 / catholic_bible-0.2.0-py3-none-any.whl

Download URL catholic_bible-0.2.0-py3-none-any.whl
Size 29.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0552e6ed40f3022c9d94cc73144168ec9a98ff0f62de3c1078495e123283c6f4
BLAKE2b-256 checksum
How to use checksums
7be565de0f2d480b8eba31ef017be91f014deb47489e6d638e9d6004026dae27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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 history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

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