基于 bible-data 数据集的类型化 API,以 @midvash/bible-data 发布在 npm 上。可在 Node 18+(使用原生 fetch)、浏览器和边缘运行时(Cloudflare Workers、Vercel Edge)中运行。提供 getVerse(slug, book, chapter, verse)、getChapter、getBook、getBible 和 getVersionMetadata 等函数,以及 ALL_VERSION_SLUGS、VERSIONS_BY_LANGUAGE、KNOWN_LANGUAGES 和 BOOK_IDS 等常量。支持通过 configure({ baseUrl, fetch }) 自定义配置,可用于锁定数据集的特定版本,或注入带缓存、重试或模拟的 fetch。书卷用 OSIS 代码标识(Gen、Exod……Rev)。MIT 许可。库所提供的文本遵循各译本各自的许可(在 bible-data 中声明)。
- getVerse / getChapter / getBook / getBible
- 常量 ALL_VERSION_SLUGS、VERSIONS_BY_LANGUAGE、BOOK_IDS
- 可配置:自定义 baseUrl、自定义 fetch
- 支持 Node、浏览器和边缘运行时
- 完整的 TypeScript 类型
- 零依赖
npm install @midvash/bible-data
import { getVerse, getChapter, getBook } from '@midvash/bible-data';
// John 3:16 in the King James Version
const verse = await getVerse('kjv', 'John', 3, 16);
console.log(verse.text);
// "For God so loved the world, that he gave his only begotten Son..."
// All of John 3 in the World English Bible
const chapter = await getChapter('web', 'John', 3);
// The whole book of Genesis in Latin (Vulgate)
const genesis = await getBook('vulg', 'Gen');
发现了错误、缺失的数据,或想添加内容?欢迎提交 pull request 和 issue: github.com/midvash/bible-data-js .