提出请求
要访问 API,您只需向正确的端点发出 HTTP GET 请求即可。
例如,要访问端点available_translations.json ,可以使用以下 JavaScript 或 cURL 命令:
JavaScript
fetch(`https://bible.helloao.org/api/available_translations.json`)
.then(request => request.json())
.then(availableTranslations => {
console.log('The API has the following translations:', availableTranslations);
});cURL
curl https://bible.helloao.org/api/available_translations.json下面列出了一些示例。如需更完整的文档,请参阅参考文档。
示例
获取可用译文列表
(参考)
GET https://bible.helloao.org/api/available_translations.json
JavaScript
fetch(`https://bible.helloao.org/api/available_translations.json`)
.then(request => request.json())
.then(availableTranslations => {
console.log('The API has the following translations:', availableTranslations);
});cURL
curl https://bible.helloao.org/api/available_translations.json列出翻译书籍
(参考)
GET https://bible.helloao.org/api/{translation}/books.json
JavaScript
// 获取 BSB 翻译所需的书籍列表
fetch(`https://bible.helloao.org/api/BSB/books.json`)
.then(request => request.json())
.then(books => {
console.log('The BSB has the following books:', books);
});cURL
curl https://bible.helloao.org/api/BSB/books.json从翻译中获取章节
(参考)
GET https://bible.helloao.org/api/{translation}/{book}/{chapter}.json
JavaScript
// 从 BSB 译本中获取创世记 1 章
fetch(`https://bible.helloao.org/api/BSB/GEN/1.json`)
.then(request => request.json())
.then(chapter => {
console.log('Genesis 1 (BSB):', chapter);
});cURL
curl https://bible.helloao.org/api/BSB/GEN/1.json从翻译中获取简体章节
(参考)
GET https://bible.helloao.org/api/{translation}/{book}/{chapter}.simple.json
如果您只需要章节文本,请使用此功能。每节经文都包含一个单独的text字符串,而不是格式化的内容列表,因此您无需自己构建文本。
JavaScript
// 请从BSB译本中获取创世记1章的文本。
fetch(`https://bible.helloao.org/api/BSB/GEN/1.simple.json`)
.then(request => request.json())
.then(chapter => {
for (let content of chapter.chapter.content) {
if (content.type === 'verse') {
console.log(`${content.number}. ${content.text}`);
}
}
});cURL
curl https://bible.helloao.org/api/BSB/GEN/1.simple.json获取可用评论列表
(参考)
JavaScript
fetch(`https://bible.helloao.org/api/available_commentaries.json`)
.then(request => request.json())
.then(availableCommentaries => {
console.log('The API has the following commentaries:', availableCommentaries);
});cURL
curl https://bible.helloao.org/api/available_commentaries.json评论中的书目列表
(参考)
JavaScript
const commentary = 'adam-clarke';
// 获取亚当·克拉克评论的书籍清单
fetch(`https://bible.helloao.org/api/c/${commentary}/books.json`)
.then(request => request.json())
.then(books => {
console.log('The adam-clarke commentary has the following books:', books);
});cURL
curl https://bible.helloao.org/api/c/adam-clarke/books.json从评论中获取章节
(参考)
JavaScript
const commentary = 'adam-clarke';
const book = 'GEN';
const chapter = 1;
// 从亚当·克拉克注释中获取《创世记》第1章
fetch(`https://bible.helloao.org/api/c/${commentary}/${book}/${chapter}.json`)
.then(request => request.json())
.then(chapter => {
console.log('Genesis 1 (adam-clarke):', chapter);
});cURL
curl https://bible.helloao.org/api/c/adam-clarke/GEN/1.json评论中的人物简介列表
(参考)
JavaScript
const commentary = 'tyndale';
// 获取廷代尔评论的个人资料列表
fetch(`https://bible.helloao.org/api/c/${commentary}/profiles.json`)
.then(request => request.json())
.then(profiles => {
console.log('The tyndale commentary has the following profiles:', profiles);
});cURL
curl https://bible.helloao.org/api/c/tyndale/profiles.json在评论中获得个人简介
(参考)
JavaScript
const commentary = 'tyndale';
const profile = 'aaron';
// 从廷代尔评论中获取亚伦的个人资料
fetch(`https://bible.helloao.org/api/c/${commentary}/profiles/${profile}.json`)
.then(request => request.json())
.then(profile => {
console.log('The Aaron tyndale commentary profile:', profile);
});cURL
curl https://bible.helloao.org/api/c/tyndale/profiles/aaron.json获取可用数据集列表
(参考)
JavaScript
fetch(`https://bible.helloao.org/api/available_datasets.json`)
.then(request => request.json())
.then(availableDatasets => {
console.log('The API has the following datasets:', availableDatasets);
});cURL
curl https://bible.helloao.org/api/available_datasets.json获取数据集中的书籍列表
(参考)
JavaScript
const dataset = 'open-cross-ref';
// 获取开放交叉引用数据集的书籍列表
fetch(`https://bible.helloao.org/api/d/${dataset}/books.json`)
.then(request => request.json())
.then(books => {
console.log('The open-cross-ref dataset has the following books:', books);
});cURL
curl https://bible.helloao.org/api/d/open-cross-ref/books.json从数据集中获取章节
(参考)
JavaScript
const dataset = 'open-cross-ref';
const book = 'GEN';
const chapter = 1;
// 从开放交叉引用数据集获取创世记1章
fetch(`https://bible.helloao.org/api/d/${dataset}/${book}/${chapter}.json`)
.then(request => request.json())
.then(chapter => {
console.log('Genesis 1 (open-cross-ref):', chapter);
});cURL
curl https://bible.helloao.org/api/d/open-cross-ref/GEN/1.json