Bible IO
Bible IO is a typed Python content layer for Bible applications. It loads validated translation data into edition-aware models and provides stable navigation, multilingual references, lossless JSON round-tripping, metadata, catalogs, and Unicode search.
Features
- Validated
Bible,Book,Chapter, andVersevalue models - Versioned schema v1 with explicit canon order and extensible annotations
- Strict validation with path-aware
BibleDataFormatErrordiagnostics - Construction from files, strings, UTF-8 bytes, decoded mappings, or models
- Eager, lazy, or disabled search indexes
- Canonically normalized multilingual exact/all/any and fuzzy search
- Paginated, display-ready hits with safe snippets and accurate Python ranges
- Full
bible-io-references1.1 API re-export - Rich passages, custom edition order, OSIS/USFM, and localized formatting
- Edition-aware keys for bookmarks, highlights, notes, and reading progress
- Translation metadata, catalogs, statistics, and performance diagnostics
Installation
Bible IO supports Python 3.10 and later.
pip install bible-io
bible-io-references is a dependency and its public API is re-exported, so one
import provides both content and reference types.
Quick start
from bible_io import Bible, BibleBookEnum
bible = Bible("path/to/en_kjv.json")
genesis_1_1 = bible.get_verse(BibleBookEnum.Genesis, 1, 1)
john_3_16 = bible.get_verse_by_ref("John 3:16")
print(genesis_1_1.text)
print(john_3_16.text)
Declared coordinates—not list offsets—drive lookups. Sparse chapters and verses therefore work correctly.
book = bible[BibleBookEnum.Genesis]
chapter = bible[BibleBookEnum.Genesis, 1]
verse = bible[BibleBookEnum.Genesis, 1, 1]
Loading
The compatibility constructor loads a JSON path. Equivalent constructors cover other application boundaries:
from bible_io import Bible
from_path = Bible.load("path/to/bible.json")
from_text = Bible.from_json(json_text)
from_bytes = Bible.from_utf8_bytes(payload)
from_mapping = Bible.from_decoded_json(decoded)
# Keep an asyncio event loop responsive while reading and processing a file.
from_path_async = await Bible.load_async("path/to/bible.json")
# Adapters with load_string(key) can provide bundled application assets.
from_asset = await Bible.load_asset(asset_bundle, "bibles/en_kjv")
Load progress uses stable reading, processing, and complete phases:
def report(progress):
print(progress.phase, f"{progress.fraction:.0%}")
bible = Bible("path/to/bible.json", on_load_progress=report)
Search indexes can be retained eagerly, built on first compatible search, or disabled:
from bible_io import BibleLoadOptions, SearchIndexMode
options = BibleLoadOptions(search_index_mode=SearchIndexMode.LAZY)
bible = Bible("path/to/bible.json", options=options)
print(bible.has_search_index) # False
bible.prewarm_search_index()
bible.clear_search_index()
Content values are immutable. Derive edits with verse.with_text(...) and the
model copy_with(...) helpers; retained search indexes therefore cannot become
stale through public mutation.
Validation and schema v1
Strict validation is the default. It requires at least one book, chapter, and
verse and rejects blank verse text. It also rejects malformed types, invalid
identifiers, duplicate semantic books or numeric coordinates, inconsistent
parents, unsupported schema versions, incomplete bookOrder, and non-JSON
annotations.
Use the permissive policy only for intentionally skeletal content:
from bible_io import Bible, BibleDataValidationOptions, BibleLoadOptions
partial = Bible.from_decoded_json(
{"schemaVersion": 1, "books": {}},
options=BibleLoadOptions(
validation=BibleDataValidationOptions.PERMISSIVE,
),
)
Permissive validation relaxes only the four content-presence requirements; it does not accept malformed structure.
Schema v1 supports legacy plain verse strings and annotated values together:
{
"schemaVersion": 1,
"language": "English",
"metadata": {
"id": "eng-example-2026",
"translationName": "Example Translation",
"abbreviation": "EXT"
},
"bookOrder": ["gn"],
"books": {
"gn": {
"name": "Genesis",
"section": "Pentateuch",
"chapters": {
"1": {
"heading": "Creation",
"verses": {
"1": {
"text": "In the beginning...",
"paragraphStart": true
},
"2": "The earth was formless..."
}
}
}
}
}
}
Unknown JSON-compatible fields are retained at their original root, metadata,
source, book, chapter, or verse level. bible.to_json() emits canonical schema
v1 data with the effective book order.
References, passages, and navigation
Parsing prefers the loaded edition's language and custom book names while
remaining multilingual by default. Supplying input_language makes the input
language explicit.
from bible_io import BibleLanguageEnum
verse = bible.get_verse_by_ref(
"Juan 3:16",
input_language=BibleLanguageEnum.SPANISH,
)
range_verses = bible.get_verse_range_by_ref("John 21:25-Acts 1:2")
passage = bible.get_passage("John 3:16,18-20; Acts 2:1-4; Romans 8")
Rich passages include whole books, chapter ranges, verse lists/ranges, and
semicolon-separated sequences. Overlaps and explicit sequence duplicates are
preserved. Cross-book ranges and navigation follow the loaded bookOrder,
including custom canons.
current = verse.location
next_location = bible.next_verse(current)
previous_location = bible.previous_verse(current)
Persist UI state with an edition-aware key rather than a location alone:
key = bible.key_for_verse(verse)
stored = key.to_json()
restored = type(key).from_json(stored)
The Bible metadata must define a stable, trimmed id before a key can be
created.
Search
search() is a fast all-terms search, not an exact phrase search:
verses = bible.search("faith hope")
Advanced search controls modes, scopes, normalization, and pagination:
from bible_io import SearchMode, SearchOptions
page = bible.search_with_options(
"creacion",
SearchOptions(
mode=SearchMode.ANY,
ignore_diacritics=True,
offset=20,
max_results=20,
),
)
print(page.count, page.has_more, page.next_offset)
for hit in page.hits:
print(hit.reference, hit.snippet, hit.snippet_match_ranges)
Canonical NFC normalization is enabled by default. Diacritic folding is explicit because marks can be meaningful in Hebrew and Arabic. Unspaced Han, kana, Thai, Lao, Khmer, and Myanmar queries receive substring-aware token matching. Typo-tolerant search uses bounded Unicode edit distance:
page = bible.fuzzy_search(
"beginnig creatd",
max_distance=1,
mode=SearchMode.ALL,
max_results=20,
)
TextRange values use half-open Python string indices, so they can be passed
directly to normal Python slicing.
Metadata and catalogs
BibleMetadata carries edition identity, language, display name,
abbreviation, direction, provenance, copyright, content license, canon, and
version date. BibleSource represents a catalog/load source and can infer
common values from an asset path.
from bible_io import BibleCatalog
catalog = BibleCatalog.from_decoded_json(catalog_data)
source = catalog.find_by_id("eng-kjv-1769")
english_sources = catalog.for_language("en")
Catalogs accept lists, ID-keyed maps, nested language maps, and the documented
sources, bibles, or translations container names.
Statistics and diagnostics
print(bible.stats)
print(bible.get_book(BibleBookEnum.Genesis).stats)
print(bible.get_chapter(BibleBookEnum.Genesis, 1).stats)
print(bible.performance_metrics)
Performance and memory values are estimates intended for diagnostics, not heap profiling.
Development
uv run pytest
uv run coverage run -m pytest
uv run coverage report
uv run mypy src test
uv build
Coverage measures branches as well as statements and is gated at 90% combined
coverage. The parity suites mirror the current Rust and Dart contracts across
schema validation, immutable values, loaders and progress, sparse navigation,
references and passages, metadata and catalogs, Unicode search, persisted
state, results, statistics, and index lifecycle. They were audited against
bible-io-package-rs main at 13cf07b
and bible-io-package-dart main at 8f056b6.
The test fixture is development-only and is not included in package archives.
License
Bible IO source code is licensed under the GNU Affero General Public License
v3 (AGPL-3.0-only); see LICENSE.
Bible translations, study notes, and other loaded content are independent
works. Applications and data distributors must obtain and honor the rights for
each edition; the metadata copyright and license fields can carry those
terms with the content.
Metadata
Release files for bible-io 1.1.1
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 |
|---|---|---|---|---|
| bible_io-1.1.1.tar.gz | 69.3 kB | With provenance | Details for bible_io-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bible_io-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for bible_io-1.1.1-py3-none-any.whl |
Total release size: 145.5 kB
Release files / bible_io-1.1.1.tar.gz
| Download URL | bible_io-1.1.1.tar.gz |
|---|---|
| Size | 69.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
731cbb8ab0f5dd8c5d6bc929eabd98da5841fc3471b2816da1937d30dce88abe
|
|
BLAKE2b-256 checksum How to use checksums |
c5cf44f9bb9e79202abfe40398a910bf25bd66dc231bf81d11cabc570e524c47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency logRelease files / bible_io-1.1.1-py3-none-any.whl
| Download URL | bible_io-1.1.1-py3-none-any.whl |
|---|---|
| Size | 76.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
354016792748d7e257bb17983fbd8575525fb8743061a8849a20c1cc7753b731
|
|
BLAKE2b-256 checksum How to use checksums |
85f7b16a5e1753f6c2c7edb179cf3072d56fb1d6db9e63828777b7279d09c2de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency logSecurity for bible-io 1.1.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bible_io-1.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.
Transparency logA 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.