The JavaScript SDK (@youversion/platform-core) provides typed API clients for fetching Bible data in any JavaScript environment.
See the source on GitHub.
import { ApiClient, BibleClient } from "@youversion/platform-core";const apiClient = new ApiClient({ appKey: "YOUR_APP_KEY",});const bibleClient = new BibleClient(apiClient);const passage = await bibleClient.getPassage(3034, "JHN.3.16", "text");console.log(passage.content); // "For God so loved the world that He gave His one and only Son, that everyone who believes in Him shall not perish but have eternal life."
Display the Bible Version Copyright
When displaying Bible text, always display a Bible Version's copyright attribution in accordance with the license agreement
Code
import { ApiClient, BibleClient } from "@youversion/platform-core";const apiClient = new ApiClient({ appKey: "YOUR_APP_KEY",});const bibleClient = new BibleClient(apiClient);const passage = await bibleClient.getPassage(3034, "JHN.3.16", "text");console.log(passage.content); // "For God so loved the world that He gave His one and only Son, that everyone who believes in Him shall not perish but have eternal life."const version = await bibleClient.getVersion(3034);console.log(version.copyright); // "Public Domain"
That's it! You now have fetched a Bible verse and have given it proper Bible Version attribution.