Skip to content

BibleService

Paceaux edited this page Aug 3, 2021 · 3 revisions

Creating a new Bible Service

You may want multiple services if you plan on using different versions of the api, or fetching text and audio.

Basic Example

const {BibleService} = require('berea');

const service = new BibleService('someLongToken');

Setting a Version

As the API itself is version controlled, the library is too. This is an optional second parameter:

const {BibleService} = require('berea');

const service = new BibleService('someLongToken', 1);

Setting the medium

The Bible API itself offers text and audio. As you may want one over the other, this is an optional third parameter. The options are text or audio.

const {BibleService} = require('berea');

const service = new BibleService('someLongToken', 1, 'audio');

BibleService

Kind: global class

new BibleService(apikey, [version], [medium], [dependencies])

Param Type Default Description
apikey string api key needed
[version] number | string 1 version of api
[medium] BibleTypes 'text' audio or text bible
[dependencies] object {Axios} axios library

bibleService.version : string

Kind: instance property of BibleService Access: public

bibleService.dependencies : object

Kind: instance property of BibleService Access: public

bibleService.apikey : string

Kind: instance property of BibleService Access: public

bibleService.axios : object

Kind: instance property of BibleService Access: public

bibleService.BibleTypes : enum

enum for kinds of media for the bible (text or audio)

Kind: instance enum of BibleService Read only: true

bibleService.RequestParameters : enum

enum for all the parameters that can be submitted through any of the service methods

Kind: instance enum of BibleService Read only: true

bibleService.getBibles([request]) ⇒ Promise.<Array.<BibleResponse>>

Kind: instance method of BibleService Returns: Promise.<Array.<BibleResponse>> - An array of bibles

Param Type Description
[request] BiblesRequestParam options to send

bibleService.getBible(id) ⇒ Promise.<BibleResponse>

Kind: instance method of BibleService Returns: Promise.<BibleResponse> - Bible data

Param Type Description
id string Gets Bible by Id

bibleService.getBooks(request) ⇒ Promise.<Array.<BookResponse>>

Kind: instance method of BibleService Returns: Promise.<Array.<BookResponse>> - an array of bookdata

Param Type Description
request BooksRequestParam | string id of the bible or object containing id and parameters

bibleService.getBook(request, [bookIdStr]) ⇒ Promise.<BookResponse>

Kind: instance method of BibleService Returns: Promise.<BookResponse> - book data

Param Type Description
request string | BookRequestParam id of the bible or object containing id, bookId, and parameters
[bookIdStr] string id of the book to fetch. Not required if the request is an object.

bibleService.getChaptersFromBook(request, [bookIdStr]) ⇒ Promise.<Array.<ChapterSummaryResponse>>

Gets chapters from a single book

Kind: instance method of BibleService Returns: Promise.<Array.<ChapterSummaryResponse>> - Chapterdata

Param Type Default Description
request ChaptersRequestParam | string id of the bible or object containing id, bookId, and parameters
[bookIdStr] string "''" id for the book. Not needed if request is an object and has bookId

bibleService.getChapter(request, chapterIdStr) ⇒ Promise.<ChapterResponse>

Kind: instance method of BibleService
Returns: Promise.<ChapterResponse> - The chapter

Param Type Description
request ChapterRequestParam | string options object
chapterIdStr string chapter id. not needed if request has chapterId

bibleService.getPassage(request, passageIdStr) ⇒ Promise.<PassageResponse>

Kind: instance method of BibleService Returns: Promise.<PassageResponse> - passageData

Param Type Description
request PassageRequestParam | string options or string with bible id
passageIdStr string id of passage (e.g. GEN.1.1-GEN.2.2)

bibleService.getVersesFromChapter(request, [chapterIdStr]) ⇒ Promise.<Array.<ChapterResponse>>

Gets verses from a single chapter

Kind: instance method of BibleService Returns: Promise.<Array.<ChapterResponse>> - chapterdata

Param Type Description
request ChaptersRequestParam | string id of the bible or object containing id, bookId, and parameters
[chapterIdStr] string chapterId (e.g. GEN.1)

bibleService.getVerse(request, [verseIdStr]) ⇒ Promise.<Array.<VerseResponse>>

Get a verse

Kind: instance method of BibleService Returns: Promise.<Array.<VerseResponse>> - versedata

Param Type Description
request VerseRequestParam | string id of the bible or object containing id, bookId, and parameters
[verseIdStr] string verseId (e.g. GEN.1.1) not needed if the request parameter has verseId

BibleService.getAxiosInstance(dependencies, apiKey, version) ⇒ object

Kind: static method of BibleService Returns: object - Axios instance

Param Type Description
dependencies object the dependencies object passed it, containing an Axios
apiKey string apikey needed for.. the api
version number version of the api