free-use-bible-api 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +253 -139
  3. package/dist/cjs/FreeUseBibleApi.cjs +499 -0
  4. package/dist/cjs/FreeUseBibleApi.cjs.map +7 -0
  5. package/dist/cjs/index.cjs +4 -6
  6. package/dist/cjs/index.cjs.map +2 -2
  7. package/dist/cjs/{apis/index.cjs → types.gen.cjs} +3 -11
  8. package/dist/cjs/types.gen.cjs.map +7 -0
  9. package/dist/esm/FreeUseBibleApi.js +473 -0
  10. package/dist/esm/FreeUseBibleApi.js.map +7 -0
  11. package/dist/esm/index.js +2 -3
  12. package/dist/esm/index.js.map +2 -2
  13. package/dist/esm/types.gen.js +2 -0
  14. package/dist/esm/types.gen.js.map +7 -0
  15. package/dist/types/FreeUseBibleApi.d.ts +408 -0
  16. package/dist/types/index.d.ts +2 -3
  17. package/dist/types/types.gen.d.ts +2022 -0
  18. package/package.json +34 -33
  19. package/dist/cjs/apis/DefaultApi.cjs +0 -432
  20. package/dist/cjs/apis/DefaultApi.cjs.map +0 -7
  21. package/dist/cjs/apis/FreeUseBibleApi.cjs +0 -97
  22. package/dist/cjs/apis/FreeUseBibleApi.cjs.map +0 -7
  23. package/dist/cjs/apis/index.cjs.map +0 -7
  24. package/dist/cjs/models/ApiAvailableCommentaries.cjs +0 -63
  25. package/dist/cjs/models/ApiAvailableCommentaries.cjs.map +0 -7
  26. package/dist/cjs/models/ApiAvailableDatasets.cjs +0 -63
  27. package/dist/cjs/models/ApiAvailableDatasets.cjs.map +0 -7
  28. package/dist/cjs/models/ApiAvailableTranslations.cjs +0 -63
  29. package/dist/cjs/models/ApiAvailableTranslations.cjs.map +0 -7
  30. package/dist/cjs/models/ApiCommentary.cjs +0 -119
  31. package/dist/cjs/models/ApiCommentary.cjs.map +0 -7
  32. package/dist/cjs/models/ApiCommentaryBook.cjs +0 -94
  33. package/dist/cjs/models/ApiCommentaryBook.cjs.map +0 -7
  34. package/dist/cjs/models/ApiCommentaryBookChapter.cjs +0 -83
  35. package/dist/cjs/models/ApiCommentaryBookChapter.cjs.map +0 -7
  36. package/dist/cjs/models/ApiCommentaryBookChapterChapter.cjs +0 -68
  37. package/dist/cjs/models/ApiCommentaryBookChapterChapter.cjs.map +0 -7
  38. package/dist/cjs/models/ApiCommentaryBooks.cjs +0 -67
  39. package/dist/cjs/models/ApiCommentaryBooks.cjs.map +0 -7
  40. package/dist/cjs/models/ApiDataset.cjs +0 -115
  41. package/dist/cjs/models/ApiDataset.cjs.map +0 -7
  42. package/dist/cjs/models/ApiDatasetBook.cjs +0 -87
  43. package/dist/cjs/models/ApiDatasetBook.cjs.map +0 -7
  44. package/dist/cjs/models/ApiDatasetBookChapter.cjs +0 -86
  45. package/dist/cjs/models/ApiDatasetBookChapter.cjs.map +0 -7
  46. package/dist/cjs/models/ApiDatasetBooks.cjs +0 -67
  47. package/dist/cjs/models/ApiDatasetBooks.cjs.map +0 -7
  48. package/dist/cjs/models/ApiTranslation.cjs +0 -125
  49. package/dist/cjs/models/ApiTranslation.cjs.map +0 -7
  50. package/dist/cjs/models/ApiTranslationBook.cjs +0 -95
  51. package/dist/cjs/models/ApiTranslationBook.cjs.map +0 -7
  52. package/dist/cjs/models/ApiTranslationBookChapter.cjs +0 -92
  53. package/dist/cjs/models/ApiTranslationBookChapter.cjs.map +0 -7
  54. package/dist/cjs/models/ApiTranslationBookChapterChapter.cjs +0 -70
  55. package/dist/cjs/models/ApiTranslationBookChapterChapter.cjs.map +0 -7
  56. package/dist/cjs/models/ApiTranslationBooks.cjs +0 -67
  57. package/dist/cjs/models/ApiTranslationBooks.cjs.map +0 -7
  58. package/dist/cjs/models/ApiTranslationComplete.cjs +0 -67
  59. package/dist/cjs/models/ApiTranslationComplete.cjs.map +0 -7
  60. package/dist/cjs/models/ApiTranslationCompleteBook.cjs +0 -87
  61. package/dist/cjs/models/ApiTranslationCompleteBook.cjs.map +0 -7
  62. package/dist/cjs/models/BookId.cjs +0 -163
  63. package/dist/cjs/models/BookId.cjs.map +0 -7
  64. package/dist/cjs/models/ChapterContent.cjs +0 -78
  65. package/dist/cjs/models/ChapterContent.cjs.map +0 -7
  66. package/dist/cjs/models/ChapterFootnote.cjs +0 -72
  67. package/dist/cjs/models/ChapterFootnote.cjs.map +0 -7
  68. package/dist/cjs/models/ChapterFootnoteCaller.cjs +0 -51
  69. package/dist/cjs/models/ChapterFootnoteCaller.cjs.map +0 -7
  70. package/dist/cjs/models/ChapterFootnoteReference.cjs +0 -65
  71. package/dist/cjs/models/ChapterFootnoteReference.cjs.map +0 -7
  72. package/dist/cjs/models/ChapterHeading.cjs +0 -70
  73. package/dist/cjs/models/ChapterHeading.cjs.map +0 -7
  74. package/dist/cjs/models/ChapterHebrewSubtitle.cjs +0 -71
  75. package/dist/cjs/models/ChapterHebrewSubtitle.cjs.map +0 -7
  76. package/dist/cjs/models/ChapterHebrewSubtitleContentInner.cjs +0 -69
  77. package/dist/cjs/models/ChapterHebrewSubtitleContentInner.cjs.map +0 -7
  78. package/dist/cjs/models/ChapterLineBreak.cjs +0 -67
  79. package/dist/cjs/models/ChapterLineBreak.cjs.map +0 -7
  80. package/dist/cjs/models/ChapterVerse.cjs +0 -74
  81. package/dist/cjs/models/ChapterVerse.cjs.map +0 -7
  82. package/dist/cjs/models/ChapterVerseContentInner.cjs +0 -80
  83. package/dist/cjs/models/ChapterVerseContentInner.cjs.map +0 -7
  84. package/dist/cjs/models/DatasetChapterData.cjs +0 -66
  85. package/dist/cjs/models/DatasetChapterData.cjs.map +0 -7
  86. package/dist/cjs/models/DatasetChapterVerseContent.cjs +0 -66
  87. package/dist/cjs/models/DatasetChapterVerseContent.cjs.map +0 -7
  88. package/dist/cjs/models/FormattedText.cjs +0 -66
  89. package/dist/cjs/models/FormattedText.cjs.map +0 -7
  90. package/dist/cjs/models/InlineHeading.cjs +0 -62
  91. package/dist/cjs/models/InlineHeading.cjs.map +0 -7
  92. package/dist/cjs/models/InlineLineBreak.cjs +0 -67
  93. package/dist/cjs/models/InlineLineBreak.cjs.map +0 -7
  94. package/dist/cjs/models/ScoredVerseRef.cjs +0 -78
  95. package/dist/cjs/models/ScoredVerseRef.cjs.map +0 -7
  96. package/dist/cjs/models/TranslationBookChapter.cjs +0 -66
  97. package/dist/cjs/models/TranslationBookChapter.cjs.map +0 -7
  98. package/dist/cjs/models/VerseFootnoteReference.cjs +0 -62
  99. package/dist/cjs/models/VerseFootnoteReference.cjs.map +0 -7
  100. package/dist/cjs/models/index.cjs +0 -97
  101. package/dist/cjs/models/index.cjs.map +0 -7
  102. package/dist/cjs/runtime.cjs +0 -360
  103. package/dist/cjs/runtime.cjs.map +0 -7
  104. package/dist/esm/apis/DefaultApi.js +0 -416
  105. package/dist/esm/apis/DefaultApi.js.map +0 -7
  106. package/dist/esm/apis/FreeUseBibleApi.js +0 -61
  107. package/dist/esm/apis/FreeUseBibleApi.js.map +0 -7
  108. package/dist/esm/apis/index.js +0 -4
  109. package/dist/esm/apis/index.js.map +0 -7
  110. package/dist/esm/models/ApiAvailableCommentaries.js +0 -32
  111. package/dist/esm/models/ApiAvailableCommentaries.js.map +0 -7
  112. package/dist/esm/models/ApiAvailableDatasets.js +0 -32
  113. package/dist/esm/models/ApiAvailableDatasets.js.map +0 -7
  114. package/dist/esm/models/ApiAvailableTranslations.js +0 -32
  115. package/dist/esm/models/ApiAvailableTranslations.js.map +0 -7
  116. package/dist/esm/models/ApiCommentary.js +0 -81
  117. package/dist/esm/models/ApiCommentary.js.map +0 -7
  118. package/dist/esm/models/ApiCommentaryBook.js +0 -63
  119. package/dist/esm/models/ApiCommentaryBook.js.map +0 -7
  120. package/dist/esm/models/ApiCommentaryBookChapter.js +0 -58
  121. package/dist/esm/models/ApiCommentaryBookChapter.js.map +0 -7
  122. package/dist/esm/models/ApiCommentaryBookChapterChapter.js +0 -37
  123. package/dist/esm/models/ApiCommentaryBookChapterChapter.js.map +0 -7
  124. package/dist/esm/models/ApiCommentaryBooks.js +0 -39
  125. package/dist/esm/models/ApiCommentaryBooks.js.map +0 -7
  126. package/dist/esm/models/ApiDataset.js +0 -77
  127. package/dist/esm/models/ApiDataset.js.map +0 -7
  128. package/dist/esm/models/ApiDatasetBook.js +0 -56
  129. package/dist/esm/models/ApiDatasetBook.js.map +0 -7
  130. package/dist/esm/models/ApiDatasetBookChapter.js +0 -61
  131. package/dist/esm/models/ApiDatasetBookChapter.js.map +0 -7
  132. package/dist/esm/models/ApiDatasetBooks.js +0 -39
  133. package/dist/esm/models/ApiDatasetBooks.js.map +0 -7
  134. package/dist/esm/models/ApiTranslation.js +0 -87
  135. package/dist/esm/models/ApiTranslation.js.map +0 -7
  136. package/dist/esm/models/ApiTranslationBook.js +0 -64
  137. package/dist/esm/models/ApiTranslationBook.js.map +0 -7
  138. package/dist/esm/models/ApiTranslationBookChapter.js +0 -67
  139. package/dist/esm/models/ApiTranslationBookChapter.js.map +0 -7
  140. package/dist/esm/models/ApiTranslationBookChapterChapter.js +0 -42
  141. package/dist/esm/models/ApiTranslationBookChapterChapter.js.map +0 -7
  142. package/dist/esm/models/ApiTranslationBooks.js +0 -39
  143. package/dist/esm/models/ApiTranslationBooks.js.map +0 -7
  144. package/dist/esm/models/ApiTranslationComplete.js +0 -39
  145. package/dist/esm/models/ApiTranslationComplete.js.map +0 -7
  146. package/dist/esm/models/ApiTranslationCompleteBook.js +0 -59
  147. package/dist/esm/models/ApiTranslationCompleteBook.js.map +0 -7
  148. package/dist/esm/models/BookId.js +0 -127
  149. package/dist/esm/models/BookId.js.map +0 -7
  150. package/dist/esm/models/ChapterContent.js +0 -58
  151. package/dist/esm/models/ChapterContent.js.map +0 -7
  152. package/dist/esm/models/ChapterFootnote.js +0 -44
  153. package/dist/esm/models/ChapterFootnote.js.map +0 -7
  154. package/dist/esm/models/ChapterFootnoteCaller.js +0 -17
  155. package/dist/esm/models/ChapterFootnoteCaller.js.map +0 -7
  156. package/dist/esm/models/ChapterFootnoteReference.js +0 -31
  157. package/dist/esm/models/ChapterFootnoteReference.js.map +0 -7
  158. package/dist/esm/models/ChapterHeading.js +0 -34
  159. package/dist/esm/models/ChapterHeading.js.map +0 -7
  160. package/dist/esm/models/ChapterHebrewSubtitle.js +0 -38
  161. package/dist/esm/models/ChapterHebrewSubtitle.js.map +0 -7
  162. package/dist/esm/models/ChapterHebrewSubtitleContentInner.js +0 -35
  163. package/dist/esm/models/ChapterHebrewSubtitleContentInner.js.map +0 -7
  164. package/dist/esm/models/ChapterLineBreak.js +0 -31
  165. package/dist/esm/models/ChapterLineBreak.js.map +0 -7
  166. package/dist/esm/models/ChapterVerse.js +0 -41
  167. package/dist/esm/models/ChapterVerse.js.map +0 -7
  168. package/dist/esm/models/ChapterVerseContentInner.js +0 -44
  169. package/dist/esm/models/ChapterVerseContentInner.js.map +0 -7
  170. package/dist/esm/models/DatasetChapterData.js +0 -35
  171. package/dist/esm/models/DatasetChapterData.js.map +0 -7
  172. package/dist/esm/models/DatasetChapterVerseContent.js +0 -35
  173. package/dist/esm/models/DatasetChapterVerseContent.js.map +0 -7
  174. package/dist/esm/models/FormattedText.js +0 -32
  175. package/dist/esm/models/FormattedText.js.map +0 -7
  176. package/dist/esm/models/InlineHeading.js +0 -28
  177. package/dist/esm/models/InlineHeading.js.map +0 -7
  178. package/dist/esm/models/InlineLineBreak.js +0 -31
  179. package/dist/esm/models/InlineLineBreak.js.map +0 -7
  180. package/dist/esm/models/ScoredVerseRef.js +0 -47
  181. package/dist/esm/models/ScoredVerseRef.js.map +0 -7
  182. package/dist/esm/models/TranslationBookChapter.js +0 -35
  183. package/dist/esm/models/TranslationBookChapter.js.map +0 -7
  184. package/dist/esm/models/VerseFootnoteReference.js +0 -28
  185. package/dist/esm/models/VerseFootnoteReference.js.map +0 -7
  186. package/dist/esm/models/index.js +0 -40
  187. package/dist/esm/models/index.js.map +0 -7
  188. package/dist/esm/runtime.js +0 -304
  189. package/dist/esm/runtime.js.map +0 -7
  190. package/dist/types/apis/DefaultApi.d.ts +0 -176
  191. package/dist/types/apis/FreeUseBibleApi.d.ts +0 -34
  192. package/dist/types/apis/index.d.ts +0 -3
  193. package/dist/types/models/ApiAvailableCommentaries.d.ts +0 -34
  194. package/dist/types/models/ApiAvailableDatasets.d.ts +0 -34
  195. package/dist/types/models/ApiAvailableTranslations.d.ts +0 -34
  196. package/dist/types/models/ApiCommentary.d.ts +0 -145
  197. package/dist/types/models/ApiCommentaryBook.d.ts +0 -100
  198. package/dist/types/models/ApiCommentaryBookChapter.d.ts +0 -72
  199. package/dist/types/models/ApiCommentaryBookChapterChapter.d.ts +0 -46
  200. package/dist/types/models/ApiCommentaryBooks.d.ts +0 -41
  201. package/dist/types/models/ApiDataset.d.ts +0 -138
  202. package/dist/types/models/ApiDatasetBook.d.ts +0 -82
  203. package/dist/types/models/ApiDatasetBookChapter.d.ts +0 -78
  204. package/dist/types/models/ApiDatasetBooks.d.ts +0 -41
  205. package/dist/types/models/ApiTranslation.d.ts +0 -169
  206. package/dist/types/models/ApiTranslationBook.d.ts +0 -100
  207. package/dist/types/models/ApiTranslationBookChapter.d.ts +0 -96
  208. package/dist/types/models/ApiTranslationBookChapterChapter.d.ts +0 -47
  209. package/dist/types/models/ApiTranslationBooks.d.ts +0 -41
  210. package/dist/types/models/ApiTranslationComplete.d.ts +0 -41
  211. package/dist/types/models/ApiTranslationCompleteBook.d.ts +0 -83
  212. package/dist/types/models/BookId.d.ts +0 -125
  213. package/dist/types/models/ChapterContent.d.ts +0 -34
  214. package/dist/types/models/ChapterFootnote.d.ts +0 -53
  215. package/dist/types/models/ChapterFootnoteCaller.d.ts +0 -27
  216. package/dist/types/models/ChapterFootnoteReference.d.ts +0 -39
  217. package/dist/types/models/ChapterHeading.d.ts +0 -46
  218. package/dist/types/models/ChapterHebrewSubtitle.d.ts +0 -47
  219. package/dist/types/models/ChapterHebrewSubtitleContentInner.d.ts +0 -51
  220. package/dist/types/models/ChapterLineBreak.d.ts +0 -40
  221. package/dist/types/models/ChapterVerse.d.ts +0 -53
  222. package/dist/types/models/ChapterVerseContentInner.d.ts +0 -70
  223. package/dist/types/models/DatasetChapterData.d.ts +0 -40
  224. package/dist/types/models/DatasetChapterVerseContent.d.ts +0 -40
  225. package/dist/types/models/FormattedText.d.ts +0 -45
  226. package/dist/types/models/InlineHeading.d.ts +0 -33
  227. package/dist/types/models/InlineLineBreak.d.ts +0 -40
  228. package/dist/types/models/ScoredVerseRef.d.ts +0 -70
  229. package/dist/types/models/TranslationBookChapter.d.ts +0 -42
  230. package/dist/types/models/VerseFootnoteReference.d.ts +0 -33
  231. package/dist/types/models/index.d.ts +0 -39
  232. package/dist/types/runtime.d.ts +0 -185
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 AO Lab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,139 +1,253 @@
1
- # Free Use Bible API
2
-
3
- The Free Use Bible API provides access to over 1000 Bible translations in hundreds of languages.
4
-
5
- This package is an auto-generated TypeScript and JavaScript client for the public API hosted at:
6
-
7
- - https://bible.helloao.org
8
-
9
- ## Installation
10
-
11
- Install with your preferred package manager:
12
-
13
- ```bash
14
- npm install free-use-bible-api
15
- ```
16
-
17
- ```bash
18
- pnpm add free-use-bible-api
19
- ```
20
-
21
- ```bash
22
- yarn add free-use-bible-api
23
- ```
24
-
25
- ## Quick Start
26
-
27
- Create a client and point it at the production API:
28
-
29
- ```ts
30
- import { Configuration, FreeUseBibleApi } from 'free-use-bible-api';
31
-
32
- const config = new Configuration({
33
- basePath: 'https://bible.helloao.org',
34
- });
35
-
36
- const api = new FreeUseBibleApi(config);
37
- ```
38
-
39
- ## Translation Usage Guide
40
-
41
- This section covers the most common translation flow:
42
-
43
- 1. Get available translations.
44
- 2. Pick a translation ID.
45
- 3. Get books for that translation.
46
- 4. Fetch a chapter.
47
- 5. Optionally fetch the full translation payload.
48
-
49
- ### 1. Get Available Translations
50
-
51
- ```ts
52
- import { Configuration, FreeUseBibleApi } from 'free-use-bible-api';
53
-
54
- const api = new FreeUseBibleApi(
55
- new Configuration({ basePath: 'https://bible.helloao.org' })
56
- );
57
-
58
- const result = await api.getAvailableTranslations();
59
-
60
- console.log('Total translations:', result.translations.length);
61
- console.log('First translation:', result.translations[0]);
62
- ```
63
-
64
- ### 2. Get Books For A Translation
65
-
66
- Use a translation ID from the previous step, for example `BSB`:
67
-
68
- ```ts
69
- const books = await api.getTranslationBooks({
70
- translation: 'BSB',
71
- });
72
-
73
- console.log('Books in translation:', books.books.length);
74
- console.log('First book:', books.books[0]);
75
- ```
76
-
77
- ### 3. Get A Translation Chapter
78
-
79
- Use a USFM book ID and chapter number:
80
-
81
- ```ts
82
- import { BookId } from 'free-use-bible-api';
83
-
84
- const chapter = await api.getTranslationBookChapter({
85
- translation: 'BSB',
86
- book: BookId.GEN,
87
- chapter: 1,
88
- });
89
-
90
- console.log('Chapter number:', chapter.chapter.number);
91
- console.log('Verse count:', chapter.numberOfVerses);
92
- ```
93
-
94
- ### 4. Get A Complete Translation
95
-
96
- Some workflows need the entire translation document in one call:
97
-
98
- ```ts
99
- const complete = await api.getTranslationComplete({
100
- translation: 'BSB',
101
- });
102
-
103
- console.log('Translation:', complete.translation.id);
104
- console.log('Book count:', complete.books.length);
105
- ```
106
-
107
- ## Direct HTTP Examples For Translations
108
-
109
- If you do not want to use the SDK, these translation endpoints are available directly:
110
-
111
- - GET `/api/available_translations.json`
112
- - GET `/api/{translation}/books.json`
113
- - GET `/api/{translation}/{book}/{chapter}.json`
114
- - GET `/api/{translation}/complete.json`
115
-
116
- Example requests:
117
-
118
- ```bash
119
- curl https://bible.helloao.org/api/available_translations.json
120
- curl https://bible.helloao.org/api/BSB/books.json
121
- curl https://bible.helloao.org/api/BSB/GEN/1.json
122
- ```
123
-
124
- ## Error Handling
125
-
126
- A 404 response usually means one of these values is invalid:
127
-
128
- - translation
129
- - book
130
- - chapter
131
-
132
- Use available translations and books responses to drive your UI selections and reduce bad requests.
133
-
134
- ## Notes
135
-
136
- - This client uses fetch under the hood.
137
- - In modern Node.js versions, fetch is available globally.
138
- - For custom environments, pass a custom fetch implementation in `Configuration`.
139
-
1
+ # Free Use Bible API
2
+
3
+ TypeScript and JavaScript client for the public Free Use Bible API:
4
+
5
+ - `https://bible.helloao.org`
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install free-use-bible-api
11
+ ```
12
+
13
+ ```bash
14
+ pnpm add free-use-bible-api
15
+ ```
16
+
17
+ ```bash
18
+ yarn add free-use-bible-api
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```ts
24
+ import { FreeUseBibleApi } from 'free-use-bible-api';
25
+
26
+ const api = new FreeUseBibleApi();
27
+
28
+ const available = await api.getAvailableTranslations();
29
+ console.log('Total translations:', available.translations.length);
30
+
31
+ const books = await api.getTranslationBooks('BSB');
32
+ console.log('Books in BSB:', books.books.length);
33
+
34
+ const chapter = await api.getTranslationBookChapter('BSB', 'GEN', 1);
35
+ console.log('Verses in Genesis 1:', chapter.numberOfVerses);
36
+ ```
37
+
38
+ ## Client Options
39
+
40
+ You can customize the client with `FreeUseBibleApiOptions`:
41
+
42
+ ```ts
43
+ import { FreeUseBibleApi } from 'free-use-bible-api';
44
+
45
+ const api = new FreeUseBibleApi({
46
+ endpoint: 'https://bible.helloao.org/',
47
+ useCache: true,
48
+ });
49
+ ```
50
+
51
+ - `endpoint`: Base API endpoint.
52
+ - `useCache`: Enables in-memory response caching (default: `true`).
53
+
54
+ ## API Methods
55
+
56
+ ### Translations
57
+
58
+ - `getAvailableTranslations(endpoint?)`
59
+ - `getTranslationBooks(translation, endpoint?)`
60
+ - `getTranslationBookChapter(translation, book, chapter, endpoint?)`
61
+ - `getTranslationBookChapterWords(translation, book, chapter, endpoint?)`
62
+ - `getCompleteTranslation(translation, endpoint?)`
63
+ - `getSimpleTranslationBookChapter(translation, book, chapter, endpoint?)`
64
+ - `getSimpleTranslationBookChapterWords(translation, book, chapter, endpoint?)`
65
+ - `getSimpleCompleteTranslation(translation, endpoint?)`
66
+
67
+ `getCompleteTranslation()` and `getSimpleCompleteTranslation()` disable per-request cache internally because payloads are typically large.
68
+
69
+ ### Commentaries
70
+
71
+ - `getAvailableCommentaries(endpoint?)`
72
+ - `getCommentaryBooks(commentary, endpoint?)`
73
+ - `getCommentaryBookChapter(commentary, book, chapter, endpoint?)`
74
+ - `getSimpleCommentaryBookChapter(commentary, book, chapter, endpoint?)`
75
+
76
+ ### Datasets
77
+
78
+ - `getAvailableDatasets(endpoint?)`
79
+ - `getDatasetBooks(dataset, endpoint?)`
80
+ - `getDatasetBookChapter(dataset, book, chapter, endpoint?)`
81
+
82
+ ### Chapter Navigation Helpers
83
+
84
+ - `getNextChapter(chapter, endpoint?)`
85
+ - `getPreviousChapter(chapter, endpoint?)`
86
+
87
+ ### Chapter & Verse Helpers
88
+
89
+ - `getVerseText(verse)`
90
+ - `getChapterVerseText(chapter)`
91
+
92
+ These helpers work with translation, commentary, and dataset chapter responses, as well as simplified translation and commentary chapter responses.
93
+
94
+ ### Word Annotations
95
+
96
+ Some translations include word-level annotations (Strong's numbers and related source data) for their chapters.
97
+
98
+ - `getChapterWords(chapter, endpoint?)` - gets the annotations for a chapter you already loaded, or `null` if it doesn't have any.
99
+ - `getWordText(verse, word)` - gets the text that a single annotation applies to.
100
+ - `getVerseWords(verse, words)` - gets the annotations for a verse, each paired with the text it applies to.
101
+
102
+ Each annotation is anchored to a range of characters in a single item of a verse's `content` array: `contentIndex` is the index of the item, and `start`/`end` are character offsets into that item's text (`end` is exclusive). Anchoring per content item keeps the offsets correct for verses whose content is split into multiple items, such as poem lines and the words of Jesus.
103
+
104
+ `getWordText()` and `getVerseWords()` resolve those offsets for you, so you don't have to walk the content array yourself.
105
+
106
+ ### Simplified Chapters
107
+
108
+ Every translation and commentary chapter can also be fetched in a simplified format, where each verse's content is a single string instead of a list of formatted content. Footnotes, inline headings, the Words of Jesus, and poetry are represented as offset ranges into that string instead of being split across multiple content items.
109
+
110
+ - `getSimpleTranslationBookChapter(translation, book, chapter, endpoint?)`
111
+ - `getSimpleCommentaryBookChapter(commentary, book, chapter, endpoint?)`
112
+ - `getSimpleCompleteTranslation(translation, endpoint?)`
113
+ - `getSimpleChapter(chapter, endpoint?)` - follows a chapter's `simpleChapterApiLink`, or `null` if simplified chapters aren't available for it.
114
+ - `getSimpleTranslationBookChapterWords(translation, book, chapter, endpoint?)` / `getSimpleChapterWords(chapter, endpoint?)` - the same as the regular word annotations, but with offsets into the simplified verse text instead of a verse's content array.
115
+ - `getSimpleWordText(verse, word)` / `getSimpleVerseWords(verse, words)` - the same as `getWordText()`/`getVerseWords()`, but for simplified verses and annotations.
116
+ - `getSimpleChapterVerseText(chapter, options?)` - the same as `getChapterVerseText()`, but for a simplified chapter.
117
+
118
+ `getNextChapter()` and `getPreviousChapter()` also accept simplified chapters, returning the next/previous simplified chapter.
119
+
120
+ Datasets don't have a simplified format.
121
+
122
+ ## Examples
123
+
124
+ ### Get a complete translation
125
+
126
+ ```ts
127
+ const complete = await api.getCompleteTranslation('BSB');
128
+ console.log(complete.translation.id);
129
+ console.log(complete.books.length);
130
+ ```
131
+
132
+ ### Read a commentary chapter
133
+
134
+ ```ts
135
+ const comm = await api.getCommentaryBookChapter('matthew_henry', 'GEN', 1);
136
+ console.log(comm.book.name);
137
+ ```
138
+
139
+ ### Read a dataset chapter
140
+
141
+ ```ts
142
+ const dataChapter = await api.getDatasetBookChapter(
143
+ 'cross_references',
144
+ 'JHN',
145
+ 3
146
+ );
147
+ console.log(dataChapter.book.name);
148
+ ```
149
+
150
+ ### Navigate to next/previous chapter
151
+
152
+ ```ts
153
+ const current = await api.getTranslationBookChapter('BSB', 'GEN', 1);
154
+
155
+ const next = await api.getNextChapter(current);
156
+ const previous = await api.getPreviousChapter(current);
157
+
158
+ console.log(next?.chapter.number);
159
+ console.log(previous?.chapter.number);
160
+ ```
161
+
162
+ ### Read the Strong's numbers for a chapter
163
+
164
+ ```ts
165
+ const chapter = await api.getTranslationBookChapter('engwebp', 'JHN', 1);
166
+ const words = await api.getChapterWords(chapter);
167
+
168
+ if (!words) {
169
+ // This translation has no word-level annotations for the chapter.
170
+ return;
171
+ }
172
+
173
+ for (const content of chapter.chapter.content) {
174
+ if (content.type !== 'verse') {
175
+ continue;
176
+ }
177
+
178
+ for (const word of api.getVerseWords(content, words)) {
179
+ console.log(word.text, word.strongs);
180
+ }
181
+ }
182
+
183
+ // In [ 'G1722' ]
184
+ // the [ 'G1722' ]
185
+ // beginning [ 'G0746' ]
186
+ // ...
187
+ ```
188
+
189
+ ### Read a simplified chapter
190
+
191
+ ```ts
192
+ const chapter = await api.getSimpleTranslationBookChapter('BSB', 'JHN', 1);
193
+
194
+ for (const content of chapter.chapter.content) {
195
+ if (content.type !== 'verse') {
196
+ continue;
197
+ }
198
+ console.log(content.number, content.text);
199
+ }
200
+ ```
201
+
202
+ ## Direct HTTP Endpoints
203
+
204
+ ### Translation endpoints
205
+
206
+ - `GET /api/available_translations.json`
207
+ - `GET /api/{translation}/books.json`
208
+ - `GET /api/{translation}/{book}/{chapter}.json`
209
+ - `GET /api/{translation}/{book}/{chapter}.words.json`
210
+ - `GET /api/{translation}/complete.json`
211
+ - `GET /api/{translation}/{book}/{chapter}.simple.json`
212
+ - `GET /api/{translation}/{book}/{chapter}.words.simple.json`
213
+ - `GET /api/{translation}/complete.simple.json`
214
+
215
+ ### Commentary endpoints
216
+
217
+ - `GET /api/available_commentaries.json`
218
+ - `GET /api/c/{commentary}/books.json`
219
+ - `GET /api/c/{commentary}/{book}/{chapter}.json`
220
+ - `GET /api/c/{commentary}/{book}/{chapter}.simple.json`
221
+
222
+ ### Dataset endpoints
223
+
224
+ - `GET /api/available_datasets.json`
225
+ - `GET /api/d/{dataset}/books.json`
226
+ - `GET /api/d/{dataset}/{book}/{chapter}.json`
227
+
228
+ Example requests:
229
+
230
+ ```bash
231
+ curl https://bible.helloao.org/api/available_translations.json
232
+ curl https://bible.helloao.org/api/BSB/books.json
233
+ curl https://bible.helloao.org/api/BSB/GEN/1.json
234
+ curl https://bible.helloao.org/api/available_commentaries.json
235
+ curl https://bible.helloao.org/api/available_datasets.json
236
+ ```
237
+
238
+ ## Error Handling
239
+
240
+ Methods throw on non-2xx responses.
241
+
242
+ A 404 response usually means one of the path values is invalid, for example:
243
+
244
+ - translation
245
+ - commentary
246
+ - dataset
247
+ - book
248
+ - chapter
249
+
250
+ ## Notes
251
+
252
+ - Uses the global `fetch` API.
253
+ - For Node.js, use a runtime that provides `fetch` (Node 18+ recommended) or polyfill it.