Context Window

Retrieve Context Around a Verse

Use /api/context to retrieve surrounding Scripture using deterministic canonical verse coordinates — crossing chapter and book boundaries automatically.

Many applications need more than a single verse. Study tools, AI systems, and reading apps often require nearby verses for interpretation, display, or navigation. The /context endpoint returns a deterministic window of Scripture centered on any canonical coordinate.


1

Request a context window

Provide a verse_id and a window size. The API returns that many verses before and after the center, plus the center itself.

curl --get https://holybible.dev/api/context \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --data verse_id=45008028 \
  --data window=2

Context window (window=2)

Romans 8:28 at center. 2 verses before and after returned automatically:

window=2 around Romans 8:28
−2 Romans 8:26 45008026
−1 Romans 8:27 45008027
0 Romans 8:28 45008028
+1 Romans 8:29 45008029
+2 Romans 8:30 45008030

Each row maps to one data[] item in the response. The offset field tells you its position relative to center.

Example response

{
  "status": "success",
  "center": {
    "verse_id": 45008028,
    "verse_index": 28145,
    "reference": "Romans 8:28",
    "osis_id": "Rom.8.28"
  },
  "window": 2,
  "results_count": 5,
  "data": [
    { "verse_id": 45008026, "verse_index": 28143,
      "reference": "Romans 8:26", "offset": -2 },
    { "verse_id": 45008027, "verse_index": 28144,
      "reference": "Romans 8:27", "offset": -1 },
    { "verse_id": 45008028, "verse_index": 28145,
      "reference": "Romans 8:28", "offset": 0 },
    { "verse_id": 45008029, "verse_index": 28146,
      "reference": "Romans 8:29", "offset": 1 },
    { "verse_id": 45008030, "verse_index": 28147,
      "reference": "Romans 8:30", "offset": 2 }
  ]
}

How context windows work

BibleBridge assigns every verse in the Protestant canon a globally consistent verse index (1–31,102). Context windows use this index to calculate nearby verses without requiring the client to determine chapter boundaries. This allows context retrieval to function across chapter transitions and even across book boundaries automatically.


Coordinate-based workflow

The three endpoints form a pipeline: normalize → expand → retrieve context.

1
/api/resolve
Normalize human input → canonical spans + OSIS + book_id
2
/api/expand
Expand spans → ordered list of atomic verse coordinates
3
/api/context
Retrieve surrounding verses using verse_id or verse_index

Common use cases

“Read in context” UX for bookmarks and search results
AI grounding: retrieve surrounding verses before sending to an LLM
Sermon passage display with verse before/after context
Next/previous navigation across chapter and book boundaries

Ready to retrieve context?

A free API key gives you 500 calls per day — no credit card required.

Get a free API key View API docs