API Reference
Translations
Bases: ABC
Base class for all Bible translations. Implementations should define async methods; sync wrappers are provided for convenience.
Source code in src/bible_translations/translations/base.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
aget_book(name, *, on_chapter_complete=None)
abstractmethod
async
Asynchronously return a single book by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The book name (e.g., "Genesis", "John"). |
required |
on_chapter_complete
|
Callback function to invoke after each chapter is loaded. |
None
|
Returns:
| Type | Description |
|---|---|
Book
|
Book: The corresponding |
Source code in src/bible_translations/translations/base.py
64 65 66 67 68 69 70 71 72 73 | |
aget_books(on_book_complete=None)
abstractmethod
async
Asynchronously return all books available in this translation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_book_complete
|
Callback function to invoke after each book is loaded. |
None
|
Returns:
| Type | Description |
|---|---|
list[Book]
|
list[Book]: A list of all |
Source code in src/bible_translations/translations/base.py
45 46 47 48 49 50 51 52 53 | |
aget_chapter(book_name, chapter_number)
abstractmethod
async
Asynchronously return a single chapter by book name and chapter number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
book_name
|
str
|
Name of the book (e.g., "John"). |
required |
chapter_number
|
int
|
Chapter number to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Chapter
|
Chapter: The |
Source code in src/bible_translations/translations/base.py
85 86 87 88 89 90 91 92 93 94 | |
aget_selection(start_ref=None, end_ref=None, *, start_book=None, start_chapter=None, start_verse=None, end_book=None, end_chapter=None, end_verse=None)
async
Asynchronously return a continuous selection of verses between two points.
Can be called with string references or explicit numeric arguments:
await aget_selection("John 3:16", "John 5:1")
await aget_selection(
start_book="John", start_chapter=3, start_verse=16,
end_book="John", end_chapter=5, end_verse=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_ref
|
str | None
|
Optional string reference for the start (e.g., "John 3:16"). |
None
|
end_ref
|
str | None
|
Optional string reference for the end (e.g., "John 5:1"). |
None
|
start_book
|
str | None
|
Start book name if using numeric mode. |
None
|
start_chapter
|
int | None
|
Start chapter number. |
None
|
start_verse
|
int | None
|
Start verse number. |
None
|
end_book
|
str | None
|
End book name if using numeric mode. |
None
|
end_chapter
|
int | None
|
End chapter number. |
None
|
end_verse
|
int | None
|
End verse number. |
None
|
Returns:
| Type | Description |
|---|---|
list[Book]
|
list[Verse]: A list of |
Source code in src/bible_translations/translations/base.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
aget_verse(book_name, chapter_number, verse_number)
abstractmethod
async
Asynchronously return a single verse by book, chapter, and verse number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
book_name
|
str
|
Name of the book. |
required |
chapter_number
|
int
|
Chapter number. |
required |
verse_number
|
int
|
Verse number. |
required |
Returns:
| Type | Description |
|---|---|
Verse
|
Verse: The requested |
Source code in src/bible_translations/translations/base.py
106 107 108 109 110 111 112 113 114 115 116 | |
get_book(name, *, on_chapter_complete=None)
Synchronously return a single book by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The book name (e.g., "Genesis", "John"). |
required |
on_chapter_complete
|
Callback function to invoke after each chapter is loaded. |
None
|
Returns:
| Type | Description |
|---|---|
Book
|
Book: The corresponding |
Source code in src/bible_translations/translations/base.py
75 76 77 78 79 80 81 82 83 | |
get_books(on_book_complete=None)
Synchronously return all books available in this translation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_book_complete
|
Callback function to invoke after each book is loaded. |
None
|
Returns:
| Type | Description |
|---|---|
list[Book]
|
list[Book]: A list of all |
Source code in src/bible_translations/translations/base.py
55 56 57 58 59 60 61 62 | |
get_chapter(book_name, chapter_number)
Synchronously return a single chapter by book name and chapter number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
book_name
|
str
|
Name of the book (e.g., "John"). |
required |
chapter_number
|
int
|
Chapter number to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Chapter
|
Chapter: The |
Source code in src/bible_translations/translations/base.py
96 97 98 99 100 101 102 103 104 | |
get_selection(start_ref=None, end_ref=None, *, start_book=None, start_chapter=None, start_verse=None, end_book=None, end_chapter=None, end_verse=None)
Synchronously return a continuous selection of verses between two points.
Can be called with string references or explicit numeric arguments:
get_selection("John 3:16", "John 5:1")
get_selection(
start_book="John", start_chapter=3, start_verse=16,
end_book="John", end_chapter=5, end_verse=1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_ref
|
str | None
|
Optional string reference for the start (e.g., "John 3:16"). |
None
|
end_ref
|
str | None
|
Optional string reference for the end (e.g., "John 5:1"). |
None
|
start_book
|
str | None
|
Start book name if using numeric mode. |
None
|
start_chapter
|
int | None
|
Start chapter number. |
None
|
start_verse
|
int | None
|
Start verse number. |
None
|
end_book
|
str | None
|
End book name if using numeric mode. |
None
|
end_chapter
|
int | None
|
End chapter number. |
None
|
end_verse
|
int | None
|
End verse number. |
None
|
Returns:
| Type | Description |
|---|---|
list[Book]
|
list[Verse]: A list of |
Source code in src/bible_translations/translations/base.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
get_verse(book_name, chapter_number, verse_number)
Synchronously return a single verse by book, chapter, and verse number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
book_name
|
str
|
Name of the book. |
required |
chapter_number
|
int
|
Chapter number. |
required |
verse_number
|
int
|
Verse number. |
required |
Returns:
| Type | Description |
|---|---|
Verse
|
Verse: The requested |
Source code in src/bible_translations/translations/base.py
118 119 120 121 122 123 124 125 126 127 | |
parse_ref(ref)
staticmethod
Parse a string reference into components.
Example: "John 3:16" → ("John", 3, 16) "1 John 3:16" → ("1 John", 3, 16) "2 Kings 5:10" → ("2 Kings", 5, 10) "Song of Solomon 2:1" → ("Song of Solomon", 2, 1) "Song of Songs 2:1" → ("Song of Solomon", 2, 1) "John 3" → ("John", 3, 1) "1 Kings 6" → ("1 Kings", 6, 1) "John" → ("John", 1, 1) "Mark" → ("Mark", 1, 1) "1 Kings" → ("1 Kings", 1, 1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str
|
Reference string formatted as "Book Chapter:Verse", "Book Chapter", or "Book". |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, int, int]
|
tuple[str, int, int]: (book_name, chapter_number, verse_number) |
Source code in src/bible_translations/translations/base.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
Get a translation class by its abbreviation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
abbreviation
|
str
|
The translation abbreviation (e.g., "KJV"). |
required |
Returns:
| Type | Description |
|---|---|
|
The translation class. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the translation is not found. |
Source code in src/bible_translations/translations/__init__.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Models
Source code in src/bible_translations/models/book.py
7 8 9 10 11 | |
Source code in src/bible_translations/models/chapter.py
6 7 8 9 | |
Source code in src/bible_translations/models/verse.py
4 5 6 7 8 9 10 | |
Source code in src/bible_translations/models/info.py
4 5 6 7 8 9 10 11 | |
Flattening
Flatten a list of Book objects into a flat list of per-verse records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
books
|
list[Book]
|
List of Book objects to flatten. |
required |
Returns:
| Type | Description |
|---|---|
list[FlatVerse]
|
list[FlatVerse]: One record per verse, in book/chapter/verse order. |
Source code in src/bible_translations/utils/flatten.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
A single verse flattened out of the nested Book/Chapter/Verse structure.
Source code in src/bible_translations/utils/flatten.py
6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Exporting
Export Bible translations to various formats.
Source code in src/bible_translations/utils/exporter.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
__init__(output_dir='exports')
Initialize the exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str | Path
|
Directory to save exported files |
'exports'
|
Source code in src/bible_translations/utils/exporter.py
21 22 23 24 25 26 27 28 | |
export(books, file_format='json', compression='.zip', folder_name=None, flat=False)
Export books to the specified format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str | None
|
Name of the exported folder |
None
|
compression
|
Literal['.tar.gz', '.tgz', '.zip']
|
Type of compression to use (tar.gz, tgz, zip) |
'.zip'
|
books
|
List[Book]
|
List of Book objects to export |
required |
file_format
|
str
|
Export format (json, txt, csv, xml) |
'json'
|
flat
|
bool
|
If True, export a single flat list of verse records instead of the nested book/chapter/verse structure. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the exported file |
Source code in src/bible_translations/utils/exporter.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
Exceptions
Bases: Exception
Raised when a requested book cannot be found.
Source code in src/bible_translations/exceptions.py
7 8 9 10 | |
Bases: Exception
Raised when a requested chapter cannot be found.
Source code in src/bible_translations/exceptions.py
13 14 15 16 | |