UNPKG

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
# **Bible API Fetcher** 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. ## **Base URL** The API base URL is: https://bible.helloao.org ## **Setup** 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 ## **API Functions** This module exports several functions to interact with the Bible API. ### **getAllLanguagesTranslations()** Fetches all available Bible translations from the API. * **Returns:** {Promise\<Array\>} \- A promise that resolves to an array of translation objects. #### **Example Usage:** import { getAllLanguagesTranslations } from './index.js'; const allTranslations \= await getAllLanguagesTranslations(); console.log(allTranslations); ### **getTranslationsFromSingleLanguage(language)** 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. #### **Example Usage:** import { getTranslationsFromSingleLanguage } from './index.js'; const englishTranslations \= await getTranslationsFromSingleLanguage('eng'); console.log(englishTranslations); ### **getTranslationBooks(translation)** 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. #### **Example Usage:** import { getTranslationBooks } from './index.js'; const kjvBooks \= await getTranslationBooks('kjv'); console.log(kjvBooks); ### **getBookChapters(translation, book)** 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. #### **Example Usage:** import { getBookChapters } from './index.js'; const genesisChapters \= await getBookChapters('kjv', 'GEN'); console.log(genesisChapters); // \[1, 2, 3, ..., 50\] ### **getChapterDetails(translation, book, chapter)** 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. #### **Example Usage:** import { getChapterDetails } from './index.js'; const genesisChapter1 \= await getChapterDetails('kjv', 'GEN', 1); console.log(genesisChapter1);