The JavaScript SDK (@youversion/platform-core) provides typed API clients for fetching Bible data in any JavaScript environment.
See the source on GitHub.
Installation
Install the package with your preferred package manager:
Configuration
Create an API client with your App Key:
Code
Types
BibleClient API
The BibleClient provides methods for fetching Bible versions, books, chapters, verses, and passages.
Version Methods
getVersions(language_ranges, license_id?)
Fetch available Bible versions filtered by language.
Code
Parameters:
language_ranges(string or string array): A language range or ordered preferences (e.g.,"en",["en", "es"]). Returns versions from the first range with available Bibles. See Language ranges.license_id(string | number, optional): License ID to filter versions
Response:
Code
getVersion(id)
Fetch a specific Bible version by ID.
Code
Parameters:
id(number): Bible version ID
Troubleshooting: If you get a "Version not found" error (404), verify the version ID exists:
Code
Book Methods
getBooks(versionId)
Fetch all books for a specific Bible version.
Code
Parameters:
versionId(number): Bible version ID
Response:
Code
getBook(versionId, book)
Fetch a specific book by its USFM identifier.
Code
Parameters:
versionId(number): Bible version IDbook(string): 3-character USFM book code (e.g.,"GEN","MAT","JHN")
Chapter Methods
getChapters(versionId, book)
Fetch all chapters for a specific book.
Code
Parameters:
versionId(number): Bible version IDbook(string): 3-character USFM book code
getChapter(versionId, book, chapter)
Fetch a specific chapter.
Code
Parameters:
versionId(number): Bible version IDbook(string): 3-character USFM book codechapter(number): Chapter number
Verse Methods
getVerses(versionId, book, chapter)
Fetch all verses for a specific chapter.
Code
Parameters:
versionId(number): Bible version IDbook(string): 3-character USFM book codechapter(number): Chapter number
Response:
Code
getVerse(versionId, book, chapter, verse)
Fetch a specific verse.
Code
Parameters:
versionId(number): Bible version IDbook(string): 3-character USFM book codechapter(number): Chapter numberverse(number): Verse number
Passage Methods
getPassageDisplay(options)
Fetch a display-ready passage with transformed HTML, current attribution, stylesheet descriptors, and scoped container attributes. This is the recommended method when you will render styled Bible HTML.
Code
The result is declarative. The SDK does not modify the DOM, inject stylesheets, or cache attribution. See Display Bible HTML for browser, server-rendered, and direct REST examples.
getPassage(versionId, usfm, format?, include_headings?, include_notes?, transform?)
Fetch a passage with formatted content. This is the recommended method for retrieving verse text to preserve proper formatting of paragraphs and tables.
Code
Parameters:
versionId(number): Bible version IDusfm(string): USFM reference format (e.g.,"JHN.3.16","GEN.1.1-5","MAT.1")format(string, optional):"html"or"text"(default:"html")include_headings(boolean, optional): Include section headings in outputinclude_notes(boolean, optional): Include footnotes/endnotes in outputtransform(boolean, optional, defaulttrue): Whenformatis"html", sanitize and transform the HTML automatically. Passfalsefor raw API HTML.
USFM format: References follow the pattern BOOK.CHAPTER.VERSE where BOOK is a 3-character code (e.g., GEN, JHN, PSA). You can specify:
- A single verse:
JHN.3.16 - A verse range:
GEN.1.1-5 - An entire chapter:
GEN.1
Use getBooks() to discover valid book codes for a version, or see the USFM Reference for all standard book identifiers.
Choosing a Format
"html"(default) — YouVersion CSS classes for verses, paragraphs, headings, poetry, and tables. Auto-transformed unless you passtransform: false. To style it, see Display Bible HTML."text"— Plain text with no markup.
Automatic HTML transformation
HTML from getPassage is transformed by default. The SDK uses DOMParser in the browser and jsdom on the server. Pass false as the sixth argument for raw API HTML, or when you do not have jsdom. usePassage forwards the same transform option. To show styled HTML, see Display Bible HTML.
Response:
format: text
format: html
When displaying Bible text, always display a Bible Version's copyright attribution in accordance with the license agreement
Index & VOTD Methods
getIndex(versionId)
Fetch the complete indexing structure for a Bible version.
Code
Parameters:
versionId(number): Bible version ID
Response:
Code
getAllVOTDs()
Fetch the Verse of the Day for the entire year.
Code
getVOTD(day)
Fetch the Verse of the Day for a specific day of the year.
Code
Parameters:
day(number): Day of the year (1-366)
LanguagesClient API
The LanguagesClient provides methods for accessing language information.
Code
Language Methods
getLanguages(options)
Fetch available languages supported in the platform.
Code
Parameters:
options(object):country(string, required): ISO 3166-1 alpha-2 country code (e.g.,"US","BR","MX")page_size(number, optional): Results per pagepage_token(string, optional): Pagination token from previous response
Response:
Code
getLanguage(languageId)
Fetch details about a specific language.
Code
Parameters:
languageId(string): BCP 47 language code (e.g.,"en","es","sr-Cyrl")
Troubleshooting: If you get "Language ID must match BCP 47 format" error, use proper language codes:
Code
SearchClient API
SearchClient searches verses and topics and retrieves suggested or trending queries. See the search guide for pagination and interface workflows.
Code
Unified search
searchUnified(query, versionId, languageRanges, options?)
Retrieve top results across content kinds, such as verse references and related topics, in one request. Returns Promise<SearchUnifiedResponse> with no pagination.
Parameters:
query(string): Search text, 1 through 100 grapheme clusters (user-perceived characters).versionId(number): Integer identifying a Bible version your app can access. Determines the language of verse results.languageRanges(string or string array): Nonempty language preferences for topic results;"*"matches all languages. See Language ranges.options(SearchUnifiedOptions, optional):userIntent(string, optional):"unknown","reference","text", or"topical". Leave unset unless you know the user's intent.fields(SearchUnifiedField[], optional): Nonempty selection of result kinds:"verses","topics", and"images". Omit to request all available kinds. Image selection requires backend support.
Response:
verses: Array of passage references, with the same shape as searchVerses hits.topics: Array of topics, with the same shape as searchTopics hits.images: Array of{ id: string; passageId: string }image hits, not image bytes.userIntent: Optional string describing the intent returned by the service.didYouMean: Array of alternative spellings.searchInsteadFor: Corrected query the results were returned for, ornull.
There is no nextPageToken or totalSize. To paginate verse results, start a separate searchVerses request. To fetch passage text, use BibleClient.getPassage.
The standalone searchUnified export takes an ApiClient as its first argument, followed by the same arguments as this method.
Verse search
searchVerses(query, versionId, options?)
Search one Bible version. Returns Promise<SearchVersesResponse>.
Parameters:
query(string): Search text, trimmed to remove surrounding whitespace. Accepts 1 through 100 grapheme clusters, or user-perceived characters. The SDK rejects longer input rather than truncating it. The same limit applies tosearchTopics.versionId(number): Integer identifying a Bible version your app can access.options(SearchVersesOptions, optional):userIntent(string, optional):"unknown","reference","text", or"topical". Leave unset unless you know the user's intent.pageSize(number, optional): Integer from 1 through 99. If omitted, the API determines the page size.pageToken(string, optional): OpaquenextPageTokenfrom a previous response.
Response:
verses: Array of{ id: string }hits. Eachidis a USFM passage identifier, not passage text. Malformed references are removed.nextPageToken: Continuation token, ornullor absent when there are no more pages.userIntent: Optional string describing the intent returned by the service.didYouMean: Array of alternative spellings.searchInsteadFor: Query string supplied by the API, ornullwhen omitted.
Topic search
searchTopics(query, languageRanges)
Find related topics without choosing a Bible version. Returns Promise<SearchTopicsResponse> with no pagination.
Parameters:
query(string): Search text with the same limit assearchVerses.languageRanges(string or string array): Nonempty language range or ordered preferences, such as"en","*"for all languages, or["en-US", "en"]. See Language ranges.
The SDK trims language ranges, converts them to lowercase, and replaces underscores with hyphens. This normalization also applies to suggested and trending query requests; it does not make an unsupported language available.
Response:
topics: Array of topics withtext(string),subtopics(string array), and optionalid(integer ornull).totalSize: Number of topics in this response.didYouMean: Array of alternative spellings.searchInsteadFor: Query string supplied by the API, ornullwhen omitted.
Suggested queries
getSuggestedQueries(query, languageRanges)
Retrieve suggestions for partial input. Returns Promise<SearchQueries>.
Parameters:
query(string): Partial input, nonempty after trimming.languageRanges(string or string array): Language preferences, as forsearchTopics.
Response: An object with a queries array. Each entry has text (string) and optional source (string). Treat source as an API-provided label, not a fixed set of values. A no-content response becomes { queries: [] }.
Trending queries
getTrendingQueries(languageRanges)
Retrieve popular queries without partial input. Accepts the same languageRanges as searchTopics and returns Promise<SearchQueries> with the same shape as getSuggestedQueries.
Fonts
Load Untitled Serif from the Fonts API stylesheet. Put this URL on a <link rel="stylesheet">. Do not host @font-face files yourself.
Code
That is GET /v1/fonts/{font_id}/stylesheet. See the Fonts API. For Bible CSS, passage HTML, and attribution, see Display Bible HTML.
Utilities
Parse a passage reference
parseUsfmReference(usfm) converts a USFM passage identifier into { book, chapter, verses }.
Code
book and chapter are strings. verses is an ascending array of numbers, empty for a chapter-only reference such as PSA.23. Invalid input returns null, including non-positive or unsafe numbers, reversed ranges, and spans longer than 250 verses. The helper checks structure, not whether the book, chapter, or verses exist in a Bible version.