Skip to main content

getBible Librarian

CI Live API Integration PyPI Python

GetBible Librarian is the Python library used to resolve scripture references, retrieve verses, and perform Unicode-aware searches against GetBible API translations. It supports standalone scripts as well as threaded and multi-process API services.

Installation

python -m pip install getbible

Python 3.10 or newer is required.

Retrieve scripture

import json

from getbible import GetBible


bible = GetBible()

selection = bible.select("Genesis 1:1-3;John 3:16", "kjv")
print(json.dumps(selection, ensure_ascii=False, indent=2))

encoded = bible.scripture("Psalm 23:1-6", "kjv")
print(encoded)

select() returns the established chapter-keyed dictionary. scripture() returns the same structure encoded as JSON.

Search scripture

import json

from getbible import GetBible, SearchBible, SearchLimits


bible = GetBible(
    search_limits=SearchLimits(
        max_work_units=50_000_000,
        max_response_bytes=4 * 1024 * 1024,
        deadline_seconds=5.0,
    )
)
criteria = SearchBible(
    words="all",
    match="whole_word",
    case_sensitive=False,
    scope="new_testament",
    books=("John", "1 John"),
    exclude=("darkness",),
    sort="canonical",
    limit=20,
    offset=0,
)

response = bible.search("word life", "kjv", criteria)
print(json.dumps(response, ensure_ascii=False, indent=2))

Search responses contain three top-level objects:

  • query: normalized criteria, translation metadata, exact total, pagination, SHA, cache state, and deterministic search cost.
  • results: the same grouped scripture object format returned by select().
  • matches: ordered per-verse match metadata, including score, occurrences, and matched terms.

This keeps existing scripture templates reusable. With relevance sorting, matches is the authoritative cross-chapter order.

Matching is derived from the text, not chosen by the caller. Librarian classifies every run of a verse and of a query by the writing system it is actually in, and applies that system's rules, so a bare query string works in every translation the API publishes:

bible.search("神爱世人", "cus")          # Chinese, nothing delimits a word
bible.search("사랑", "korean")            # Korean, inside an inflected word
bible.search("בראשית", "modernhebrew")   # unpointed, reaches pointed text
bible.search("λογος", "moderngreek")     # unaccented, reaches accented text

There is no match mode to select and no script to detect. Applications carrying a helper that inspects the query and switches to substring should delete it. See Scripture search for the matching policy, the response contract, and the 1.x migration.

Search criteria may also be supplied as a JSON-decoded dictionary:

response = bible.search(
    "faith hope",
    "kjv",
    {
        "words": "phrase",
        "scope": "bible",
        "limit": 50,
        "offset": 0,
    },
)

Official HTTP services

Librarian powers two independent read-only API services:

GET https://query.getbible.net/v2/{translation}/{reference}
GET https://search.getbible.net/v2/{translation}?q={query}

Query uses the lightweight select() path and does not expose search. Search uses search() and accepts filtering through URL query parameters; it does not expose reference routes or POST requests. See HTTP GET service integration for the complete parameter mapping, response contracts, cache separation, and deployment model.

Cache behavior

Reference retrieval keeps the lightweight chapter request path. Search downloads the selected full translation once, verifies it against /v2/{translation}.sha, and builds a compact in-memory postings index.

By default, full translations are cached under the operating system's user cache directory and checked every seven days. Configure a shared service cache explicitly:

from datetime import timedelta

from getbible import GetBible


bible = GetBible(
    cache_dir="/var/cache/getbible",
    cache_ttl=timedelta(days=7),
    strict_freshness=False,
    require_checksums=True,
)

Remote production checksums are required. Full corpora and their independent books indexes are completely validated before immutable, content-addressed payloads are atomically committed. A last-known-good translation remains available during temporary repository or newly published integrity failures unless strict_freshness=True.

Production caches are bounded by default. A service can warm its expected translation without issuing an artificial query and can expose cache counters to its internal metrics system:

bible = GetBible(
    cache_dir="/var/cache/getbible",
    search_corpus_limit=4,
    translation_cache_limit=4,
)
bible.warm_translation("kjv")
cache_state = bible.cache_info()

Atomically updated local mirrors can coordinate application response caches and worker-local invalidation with source_operation() and transition_source(). See Cache validation and retention.

Call bible.close() during worker shutdown, or use GetBible as a context manager in short-lived scripts.

Documentation

Source installation

The primary project home remains on VDM Gitea:

git clone https://git.vdm.dev/getBible/librarian.git
cd librarian
python -m venv .venv
.venv/bin/python -m pip install -e .

The GitHub deployment mirror can also be cloned:

git clone https://github.com/getbible/librarian.git
cd librarian
python -m venv .venv
.venv/bin/python -m pip install -e .

Development

./scripts/run_release_gate.sh

This creates or reuses .venv, installs every development tool, and runs the local deterministic release gate. GitHub's manually dispatchable CI workflow is the authoritative Python 3.10–3.14 check. Live API tests remain separate and intentionally opt-in:

./scripts/run_release_gate.sh --live

See the security and reliability release gate for manual commands, expected diagnostics, and GitHub workflow instructions.

License

GetBible Librarian is licensed under the GNU General Public License v2.0 or later. See LICENSE.

Download files

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

Source Distribution

getbible-2.0.0.tar.gz (180.9 kB view details)

Uploaded Source

Built Distribution

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

getbible-2.0.0-py3-none-any.whl (141.5 kB view details)

Uploaded Python 3

File details

Details for the file getbible-2.0.0.tar.gz.

File metadata

  • Download URL: getbible-2.0.0.tar.gz
  • Upload date:
  • Size: 180.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for getbible-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ced6fd053ebb25df1784d43ec6b16b0931f245620d6ded8a534b2b31a194230d
MD5 a1817b59647d4472ebce4fbe59186e93
BLAKE2b-256 ccd1e40e04f25b526cbcda7657a127f604dc7cc1711d9d370769ac4910af4537

See more details on using hashes here.

Provenance

The following attestation bundles were made for getbible-2.0.0.tar.gz:

Publisher: release.yml on getbible/librarian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file getbible-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: getbible-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 141.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for getbible-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4f1fba5ae333eed18f83acb4ca02d53dca1cb2a6598d16994ea976af038d2fc
MD5 41da9ae116d709e868c4329a3e67a246
BLAKE2b-256 9967850c1c311e28f30de53034d5ea281582fac85ffb10b1b1e518d1c26e6d28

See more details on using hashes here.

Provenance

The following attestation bundles were made for getbible-2.0.0-py3-none-any.whl:

Publisher: release.yml on getbible/librarian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.1.0

2 files

This release

2.0.0 This release

2 files

1.2.1

2 files

1.2.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 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