Formatting devotional insights using canonical Scripture as the fixed source of truth
Many modern applications format devotional or reflective content from Scripture for newsletters, reading plans, and study tools. This example demonstrates how to anchor such workflows in canonical Bible data using the BibleBridge API and Python.
BibleBridge is responsible solely for Scripture retrieval. Any downstream formatting or reflection occurs outside the API, preserving a clear boundary between canonical text and derived content.
This pattern is commonly used in devotional apps, study tools, newsletters, and automated content pipelines where Scripture must remain authoritative.
This Python example fetches John 3:16 using a canonical Book ID, then uses the verse text as grounded input for downstream devotional formatting.
import os
import requests
from openai import OpenAI
BIBLE_API_BASE = "https://holybible.dev/api/scripture"
BIBLEBRIDGE_API_KEY = os.environ.get("BIBLEBRIDGE_API_KEY")
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
if not BIBLEBRIDGE_API_KEY:
raise RuntimeError("Missing BIBLEBRIDGE_API_KEY. Set it as an environment variable before running.")
if not OPENAI_API_KEY:
raise RuntimeError("Missing OPENAI_API_KEY. Set it as an environment variable before running.")
params = {
"bookID": 43,
"chapter": 3,
"verse": 16,
"version": "KJV",
}
headers = {
"Authorization": f"Bearer {BIBLEBRIDGE_API_KEY}"
}
response = requests.get(
BIBLE_API_BASE,
params=params,
headers=headers,
timeout=10
)
response.raise_for_status()
verse_text = response.json()["data"]["text"]
formatter = OpenAI(api_key=OPENAI_API_KEY)
prompt = (
"Format a short devotional reflection based on the Scripture below. "
"Do not rewrite or paraphrase the verse itself.\n\n"
f"\"{verse_text}\""
)
completion = formatter.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You format devotional reflections while preserving Scripture verbatim."
},
{
"role": "user",
"content": prompt
},
],
)
formatted_output = completion.choices[0].message.content
print("Scripture:")
print(verse_text)
print("\nDevotional Reflection:")
print(formatted_output)
Scripture retrieval works with a free API key. Downstream formatting requires an external provider.
To run this example, sign up for a free BibleBridge API key and set both API keys as environment variables.
Grounding downstream workflows in canonical Scripture ensures that devotional outputs remain anchored to authoritative biblical text. BibleBridge acts as a fixed reference point, while all formatting and reflection occurs downstream.
This separation allows developers to experiment with different tools, providers, or presentation layers without altering the underlying Scripture source.
For endpoint details and licensing information, see the BibleBridge API documentation.