mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
Add interlinear API endpoint
Add /api/interlinear/{book}/{chapter}/{verse} endpoint to fetch
word-by-word interlinear data including:
- Original Hebrew/Greek text
- Transliteration
- Strong's concordance numbers
- Parsing information
- English translations
- Definitions
The endpoint returns interlinear_available flag and gracefully
handles verses without interlinear data by returning an empty
words array.
Updated API index to include the new interlinear endpoint.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+44
-1
@@ -857,7 +857,8 @@ def api_index():
|
||||
"search": "/api/search?q={query}",
|
||||
"verse_of_the_day": "/api/verse-of-the-day",
|
||||
"verse": "/api/verse/{book}/{chapter}/{verse}",
|
||||
"verse_range": "/api/verse-range/{book}/{chapter}/{start}/{end}"
|
||||
"verse_range": "/api/verse-range/{book}/{chapter}/{start}/{end}",
|
||||
"interlinear": "/api/interlinear/{book}/{chapter}/{verse}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2024,6 +2025,48 @@ def api_get_verse_range(book: str, chapter: int, start: int, end: int):
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@app.get("/api/interlinear/{book}/{chapter}/{verse}")
|
||||
def api_get_interlinear(book: str, chapter: int, verse: int):
|
||||
"""API endpoint to get interlinear (word-by-word) data for a verse"""
|
||||
try:
|
||||
# Normalize book name variations
|
||||
canonical_name = normalize_book_name(book)
|
||||
if canonical_name:
|
||||
book = canonical_name
|
||||
|
||||
# Check if verse exists
|
||||
verse_text = bible.get_verse_text(book, chapter, verse)
|
||||
if not verse_text:
|
||||
raise HTTPException(status_code=404, detail="Verse not found")
|
||||
|
||||
# Check if interlinear data is available
|
||||
if not has_interlinear_data(book, chapter, verse):
|
||||
return JSONResponse({
|
||||
"book": book,
|
||||
"chapter": chapter,
|
||||
"verse": verse,
|
||||
"reference": f"{book} {chapter}:{verse}",
|
||||
"text": verse_text,
|
||||
"interlinear_available": False,
|
||||
"words": []
|
||||
})
|
||||
|
||||
# Get interlinear data
|
||||
interlinear_words = get_interlinear_data(book, chapter, verse)
|
||||
|
||||
return JSONResponse({
|
||||
"book": book,
|
||||
"chapter": chapter,
|
||||
"verse": verse,
|
||||
"reference": f"{book} {chapter}:{verse}",
|
||||
"text": verse_text,
|
||||
"interlinear_available": True,
|
||||
"words": interlinear_words
|
||||
})
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@app.get("/biblical-maps", response_class=HTMLResponse)
|
||||
def biblical_maps_page(request: Request):
|
||||
"""Biblical maps page showing important biblical locations"""
|
||||
|
||||
Reference in New Issue
Block a user