A Node interface to access the APIs provided by API.Bible
SignUp on API.Bible and generate your api token
npm install scripture-api --save
const ScriptureApi = require('scripture-api');
const scriptureApi = new ScriptureApi('YOUR_API_TOKEN_HERE');
Gets an array of Bible objects authorized for current API Key
const params = {
// ISO 639-3 three digit langage code used to filter results, (optional)
language: 'eng',
// Bible abbreviation to search for (optional)
abbreviation: 'kjv',
// Bible name to search for (optional)
name: 'king james version',
// Comma separated list of Bible Ids to return (optional)
ids: 'de4e12af7f28f599-01,...'
}
scriptureApi.getBibles(params)
.then((data) => {
console.log(data);
})
.catch((error) => {
console.log(error);
});
Gets a single Bible for a given bibleId
// Id of Bible to be fetched(required)
const bibleId = 'de4e12af7f28f599-01'
scriptureApi.getBible(bibleId)
.then((data) => {
console.log(data);
})
.catch((error) => {
console.log(error);
});
Gets an array of Book objects for a given bibleId
// Id of Bible to be fetched(required)
const bibleId = 'de4e12af7f28f599-01'
const params = {
// Boolean indicating if an array of chapter summaries should be included in the results. Defaults to false
includeChapters: false,
// Boolean indicating if an array of chapter summaries and an array of sections should be included in the results. Defaults to false.
includeChaptersAndSections: false
};
scriptureApi.getBibleBooks(bibleId, params)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets a single Book object for a given bibleId and bookId
// Id of Bible whose Book to fetch
const bibleId = '';
// Id of the Book to fetch
const bookId = '';
const params = {
// Boolean indicating if an array of chapter summaries should be included in the results. Defaults to false.
includeChapters: false
};
scriptureApi.getBibleBook(bibleId, bookId, params)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets an array of Chapter objects for a given bibleId and bookId
// Id of Bible whose Book to fetch
const bibleId = '';
// Id of the Book to fetch
const bookId = '';
scriptureApi.getBibleBookChapters(bibleId, bookId)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets a single Chapter object for a given bibleId and chapterId. This Chapter object also includes an content property with all verses for the Chapter.
// Id of Bible whose Chapter to fetch
const bibleId = '';
// Id of the Chapter to fetch
const chapterId = '';
const params = {
// Content type to be returned in the content property. Supported values are html (default), json (beta), and text (beta)
contentType: 'json',
// Include footnotes in content
includeNotes: false,
// Include section titles in content
includeTitles: false,
// Include chapter numbers in content
includeChapterNumbers: false,
// Include verse numbers in content.
includeVerseNumbers: false,
// Include spans that wrap verse numbers and verse text for bible content.
includeVerseSpans: false,
// Comma delimited list of bibleIds to include
parallels: ''
};
scriptureApi.getBibleBookChapter(bibleId, chapterId, params)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets a Passage object for a given bibleId and passageId. This Passage object also includes an content property with all verses corresponding to the passageId. The passageId parameter can represent a chapter, verse, or range of verses.
// Id of Bible whose Chapter to fetch
const bibleId = 'de4e12af7f28f599-01';
// String reference id for the requested passage.
const passageId = 'REV.22.3';
const params = {
// Content type to be returned in the content property. Supported values are html (default), json (beta), and text (beta)
contentType: 'json',
// Include footnotes in content
includeNotes: false,
// Include section titles in content
includeTitles: false,
// Include chapter numbers in content
includeChapterNumbers: false,
// Include verse numbers in content.
includeVerseNumbers: false,
// Include spans that wrap verse numbers and verse text for bible content.
includeVerseSpans: false,
// Comma delimited list of bibleIds to include
parallels: ''
};
scriptureApi.getBiblePassage(bibleId, passageId, params)
.then((data) => {
console.log(JSON.stringify(data))
})
.catch((error) => {
console.log(error);
})
};
Gets search results for a given bibleId and query string. Searches will match all verses with the list of keywords provided in the query string. Order of the keywords does not matter. However all keywords must be present in a verse for it to be considered a match. The total number of results returned from a search can be limited by populating the limit attribute in the query string with a non-negative integer value. If no limit value is provide a default of 10 is used. offset can be used to traverse paginated results. So for example if you are using the default limit of 10, using an offset of 10 will return the second page of results, namely results 11-20. The text property of each verse object contains only the verse text. It does not contain footnote references. However, those can be queried directly using the /bibles/{bibleId}/verses/{verseId} endpoint.
// Id of Bible whose Chapter to fetch
const bibleId = 'de4e12af7f28f599-01';
const params = {
// Search keywords or passage reference.
query: '',
// Integer limit for how many matching results to return. Default is 10.
limit: 10,
// Offset for search results. Used to paginate results
offset: 0
};
scriptureApi.search(bibleId, params)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets an array of Section objects for a given bibleId and bookId
// Id of Bible whose Chapter to fetch
const bibleId = 'de4e12af7f28f599-01';
// Id of the Book whose Sections to fetch
const bookId = 'REV.22.3';
const params = {
// Content type to be returned in the content property. Supported values are html (default), json (beta), and text (beta)
contentType: 'json',
// Include footnotes in content
includeNotes: false,
// Include section titles in content
includeTitles: false,
// Include chapter numbers in content
includeChapterNumbers: false,
// Include verse numbers in content.
includeVerseNumbers: false,
// Include spans that wrap verse numbers and verse text for bible content.
includeVerseSpans: false,
// Comma delimited list of bibleIds to include
parallels: ''
};
scriptureApi.getBibleBookSections(bibleId, bookId, params)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets an array of Section objects for a given bibleId and chapterId
// Id of Bible whose Sections to fetch
const bibleId = '';
// Id of the Chapter whose Sections to fetch
const chapterId = '';
scriptureApi.getBibleChapterSections(bibleId, chapterId)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets a single Section object for a given bibleId and sectionId. This Section object also includes an content property with all verses for the Section.
// Id of Bible whose Section to fetch
const bibleId = '';
// Id of the Section to fetch
const sectionId = '';
const params = {
// Content type to be returned in the content property. Supported values are html (default), json (beta), and text (beta)
contentType: 'json',
// Include footnotes in content
includeNotes: false,
// Include section titles in content
includeTitles: false,
// Include chapter numbers in content
includeChapterNumbers: false,
// Include verse numbers in content.
includeVerseNumbers: false,
// Include spans that wrap verse numbers and verse text for bible content.
includeVerseSpans: false,
// Comma delimited list of bibleIds to include
parallels: ''
};
scriptureApi.getBibleSections(bibleId, sectionId)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets an array of Verse objects for a given bibleId and chapterId
// Id of Bible whose Verses to fetch
const bibleId = '';
// Id of the Chapter whose Verses to fetch
const chapterId = '';
scriptureApi.getBibleChapterVerses(bibleId, chapterId)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
Gets a Verse object for a given bibleId and verseId. This Verse object also includes an content property with the verse corresponding to the verseId.
// Id of Bible for passage
const bibleId = '';
// String reference id for the requested verse.
const verseId = '';
const params = {
// Content type to be returned in the content property. Supported values are html (default), json (beta), and text (beta)
contentType: 'json',
// Include footnotes in content
includeNotes: false,
// Include section titles in content
includeTitles: false,
// Include chapter numbers in content
includeChapterNumbers: false,
// Include verse numbers in content.
includeVerseNumbers: false,
// Include spans that wrap verse numbers and verse text for bible content.
includeVerseSpans: false,
// Comma delimited list of bibleIds to include
parallels: ''
};
scriptureApi.getBibleVerses(bibleId, chapterId)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.log(error);
})
The author of this code has no formal relationship with https://scripture.api.bible/ and does not claim to have created any of the facilities provided by https://scripture.api.bible/
(c) @olawalejarvis