import { ApiClient, BibleClient } from '@youversion/platform-core'const apiClient = new ApiClient({ appKey: "YOUR_APP_KEY"})const bibleClient = new BibleClient(apiClient)// Fetch John 3:16const passage = await bibleClient.getPassage(111, 'JHN.3.16')console.log(passage.content) // "<p>For God so loved the world...</p>"
4. Display with Copyright
Legal requirement: Always display copyright attribution with Bible content.
Code
const version = await bibleClient.getVersion(111)// In your HTMLdocument.innerHTML = ` <div>${passage.content}</div> <p class="copyright">${version.copyright_short}</p>`
Installation
Install the package with your preferred package manager:
Code
npm install @youversion/platform-core
Code
yarn add @youversion/platform-core
Code
pnpm add @youversion/platform-core
Configuration
Create an API client with your App Key:
Code
import { ApiClient, BibleClient } from '@youversion/platform-core'const apiClient = new ApiClient({ appKey: "YOUR_APP_KEY",})const bibleClient = new BibleClient(apiClient)
Types
type ApiClientOptions = { /** * Your App Key for API authentication * Get from https://platform.youversion.com/ */ appKey: string; /** * Base URL for the API * @default "https://api.youversion.com" */ baseUrl?: string; /** * Request timeout in milliseconds * @default 10_000 */ timeout?: number;}
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
// Get all English versionsconst englishVersions = await bibleClient.getVersions('en*')// Get multiple languagesconst multiLangVersions = await bibleClient.getVersions('en*,es*,fr*')// Filter by licenseconst licenseVersions = await bibleClient.getVersions('en*', 123)
Parameters:
language_ranges (string): Comma-separated language codes or ranges (e.g., "en*", "es-ES")
license_id (string | number, optional): License ID to filter versions
Fetch a passage with formatted content. This is the recommended method for retrieving verse text to preserve proper formatting of paragraphs and tables.
Code
// Single verseconst verse = await bibleClient.getPassage(111, 'JHN.3.16')console.log(verse.content) // "<p>For God so loved the world...</p>"// Verse rangeconst passage = await bibleClient.getPassage(111, 'GEN.1.1-5')// Entire chapterconst chapter = await bibleClient.getPassage(111, 'GEN.1')// With formatting optionsconst formatted = await bibleClient.getPassage(111, 'JHN.3.16', 'html', true, true)
Parameters:
versionId (number): Bible version ID
usfm (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 output
include_notes (boolean, optional): Include footnotes/endnotes in output
Response:
Code
{ id: "JHN.3.16", bible_id: 111, human_reference: "John 3:16", content: "<p><span class=\"verse-num\">16</span> For God so loved the world...</p>"}
Index & VOTD Methods
getIndex(versionId)
Fetch the complete indexing structure for a Bible version.
Code
const index = await bibleClient.getIndex(111)console.log(index.books[0].chapters.length)
The LanguagesClient provides methods for accessing language information.
Code
import { LanguagesClient } from '@youversion/platform-core'const languagesClient = new LanguagesClient(apiClient)
Language Methods
getLanguages(options)
Fetch available languages supported in the platform.
Code
// Get languages available in United Statesconst usLanguages = await languagesClient.getLanguages({ country: 'US',})// Get with paginationconst page2 = await languagesClient.getLanguages({ country: 'US', page_size: 10, page_token: 'next_page_token_from_previous_response',})
Parameters:
options (object):
country (string, required): ISO 3166-1 alpha-2 country code (e.g., "US", "BR", "MX")
page_size (number, optional): Results per page
page_token (string, optional): Pagination token from previous response
const english = await languagesClient.getLanguage('en')console.log(english.display_names?.en) // "English"// With script specificationconst serbianCyrillic = await languagesClient.getLanguage('sr-Cyrl')
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
await languagesClient.getLanguage('en') // ✓ Englishawait languagesClient.getLanguage('es') // ✓ Spanishawait languagesClient.getLanguage('sr-Cyrl') // ✓ Serbian Cyrillicawait languagesClient.getLanguage('zh-Hans') // ✓ Chinese Simplified
Referenced Types
These types are imported from @youversion/platform-core and represent the data structures used throughout the TypeScript SDK.
BibleVersion
Represents a Bible translation with metadata including language, copyright, and available books.
Types
type BibleVersion = { id: number; abbreviation: string; /** Long copyright text */ copyright_long: string; /** Short copyright text */ copyright_short: string; /** Bible information text */ info?: string | null; publisher_url?: URL | null; language_tag: string; /** Localized abbreviation */ local_abbreviation: string; /** Localized title */ local_title: string; title: string; /** Array of books in this version */ books: string[]; /** YouVersion deep link URL */ youversion_deep_link: URL;};
BibleBook
Represents a book of the Bible with its chapters and canonical section.
Types
type BibleBook = { /** Book identifier (e.g., "MAT") */ id: string; /** Book title (e.g., "Matthew") */ title: string; /** Book abbreviation (e.g., "Matt") */ abbreviation?: string; /** Canonical section "Old Testament", "New Testament", or "Deuterocanonical" */ canon: 'ot' | 'nt' | 'dc'; /** Array of chapter identifiers (e.g., ["MAT.1", "MAT.2"]) */ chapters?: string[];};
BibleChapter
Represents a chapter within a book with its verses.
type BiblePassage = { /** Passage identifier (e.g., "MAT.1.1") */ id: string; /** Passage content text (HTML or plain text) */ content: string; /** Bible version identifier */ bible_id: number; /** Human-readable reference (e.g., "Matthew 1:1") */ human_reference: string;};
VOTD (Verse of the Day)
Represents the Verse of the Day for a specific day of the year.
Types
type VOTD = { /** Day of the year (1-366), with 1 being January 1st */ day: number; /** USFM passage identifier for this day's verse */ passage_id: string;};
Collection
Generic wrapper type for paginated API responses used across multiple endpoints.
Types
type Collection<T> = { /** Array of items in this page */ data: T[]; /** Token for fetching the next page, or null if this is the last page */ next_page_token: string | null; /** Total number of items across all pages (optional) */ total_size?: number;};
Note:T is replaced with the specific item type in actual usage (e.g., Collection<BibleVersion>, Collection<BibleBook>, Collection<Language>).
Language
Represents a language supported by the YouVersion Platform with metadata.
Types
type Language = { /** BCP 47 language identifier (e.g., "en", "sr-Latn") */ id: string; /** ISO 639 language code */ language: string; /** ISO 15924 script code (e.g., "Latn") */ script?: string | null; /** Script name (e.g., "Latin") */ script_name?: string | null; /** Language aliases */ aliases?: string[]; /** Display names for different locales (e.g., { en: "English", fr: "Anglais" }) */ display_names?: Record<string, string>; /** Available scripts for this language (e.g., ["Cyrl", "Latn"]) */ scripts?: string[]; /** Language variants (e.g., ["1996", "fonipa"]) */ variants?: string[]; /** ISO 3166-1 alpha-2 country codes where this language is spoken */ countries?: string[]; /** Text direction: "ltr" (left-to-right) or "rtl" (right-to-left) */ text_direction?: 'ltr' | 'rtl'; /** Writing population count */ writing_population?: number; /** Speaking population count */ speaking_population?: number; /** Default Bible version ID for this language */ default_bible_version_id?: number | null;};
Copyright & Attribution
Legal requirement: You must display copyright attribution when showing Bible content. Most Bible translations are copyrighted works.
Always fetch the version's copyright information and display it alongside Bible text:
Code
const passage = await bibleClient.getPassage(111, 'JHN.3.16')const version = await bibleClient.getVersion(111)// Display both content and copyrightconsole.log(passage.content)console.log(version.copyright_short) // Required attribution