bible-kit
Version:
An NPM package to use bible data from the Free Bible Use API. You will be able to get data for all available translations, books for a specific translation, chapters of a specific book and chapter details.
97 lines (57 loc) • 3.4 kB
Markdown
This project contains a set of JavaScript functions for interacting with the Bible API at https://bible.helloao.org. It allows you to fetch available Bible translations, books within a translation, chapters of a book, and the detailed content of a specific chapter.
The API base URL is:
https://bible.helloao.org
The script retrieves the following URL parameters to be used in the functions: language, translation, book, and chapter.
**Example URL:**
http://your-website.com?language=eng\&translation=kjv\&book=GEN\&chapter=1
This module exports several functions to interact with the Bible API.
Fetches all available Bible translations from the API.
* **Returns:** {Promise\<Array\>} \- A promise that resolves to an array of translation objects.
import { getAllLanguagesTranslations } from './index.js';
const allTranslations \= await getAllLanguagesTranslations();
console.log(allTranslations);
Fetches all available Bible translations for a specific language.
* **Parameters:**
* language (string): The language code (e.g., 'eng', 'spa').
* **Returns:** {Promise\<Array\>} \- A promise that resolves to an array of translation objects for the specified language.
import { getTranslationsFromSingleLanguage } from './index.js';
const englishTranslations \= await getTranslationsFromSingleLanguage('eng');
console.log(englishTranslations);
Fetches the list of books for a specific Bible translation.
* **Parameters:**
* translation (string): The translation ID (e.g., 'kjv', 'web').
* **Returns:** {Promise\<Object\>} \- A promise that resolves to an object containing information about the translation and an array of its books.
import { getTranslationBooks } from './index.js';
const kjvBooks \= await getTranslationBooks('kjv');
console.log(kjvBooks);
Fetches the chapter numbers for a specific book within a given translation.
* **Parameters:**
* translation (string): The translation ID (e.g., 'kjv').
* book (string): The book ID (e.g., 'GEN', 'JHN').
* **Returns:** {Promise\<Array\>} \- A promise that resolves to an array of numbers representing the chapters in the book.
import { getBookChapters } from './index.js';
const genesisChapters \= await getBookChapters('kjv', 'GEN');
console.log(genesisChapters); // \[1, 2, 3, ..., 50\]
Fetches the content and details for a specific chapter of a book in a given translation.
* **Parameters:**
* translation (string): The translation ID (e.g., 'kjv').
* book (string): The book ID (e.g., 'GEN').
* chapter (number): The chapter number.
* **Returns:** {Promise\<Object\>} \- A promise that resolves to an object containing detailed information about the book, chapter, and an array of its verses.
import { getChapterDetails } from './index.js';
const genesisChapter1 \= await getChapterDetails('kjv', 'GEN', 1);
console.log(genesisChapter1);