Отправка запросов
Для доступа к API достаточно отправить HTTP GET-запрос к нужной конечной точке.
Например, для доступа к конечной точке available_translations.json можно использовать следующую команду JavaScript или cURL:
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 https://bible.helloao.org/api/available_translations.jsonНиже приведен список примеров. Более подробную информацию см. в разделе «Справочная документация» .
Примеры
Получить список доступных переводов
( ссылка )
GET https://bible.helloao.org/api/available_translations.json
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 https://bible.helloao.org/api/available_translations.jsonСписок книг в переводе
( ссылка )
GET https://bible.helloao.org/api/{translation}/books.json
// Получите список книг для перевода 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 https://bible.helloao.org/api/BSB/books.jsonПолучить главу из перевода
( ссылка )
GET https://bible.helloao.org/api/{translation}/{book}/{chapter}.json
// Получите первую главу Книги Бытия из перевода BSB.
fetch(`https://bible.helloao.org/api/BSB/GEN/1.json`)
.then(request => request.json())
.then(chapter => {
console.log('Genesis 1 (BSB):', chapter);
});curl https://bible.helloao.org/api/BSB/GEN/1.jsonПолучите упрощенную главу из перевода.
( ссылка )
GET https://bible.helloao.org/api/{translation}/{book}/{chapter}.simple.json
Используйте это, если вам нужен только текст главы. Каждый стих содержит одну строку с text значением вместо списка отформатированного содержимого, поэтому вам не нужно самостоятельно формировать текст.
// Получите текст первой главы Книги Бытия из перевода BSB.
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 https://bible.helloao.org/api/BSB/GEN/1.simple.jsonПолучить список доступных комментариев
( ссылка )
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 https://bible.helloao.org/api/available_commentaries.jsonСписок книг в комментарии
( ссылка )
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 https://bible.helloao.org/api/c/adam-clarke/books.jsonПолучить главу из комментария
( ссылка )
const commentary = 'adam-clarke';
const book = 'GEN';
const chapter = 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 https://bible.helloao.org/api/c/adam-clarke/GEN/1.jsonСписок биографий в комментарии
( ссылка )
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 https://bible.helloao.org/api/c/tyndale/profiles.jsonПолучите профиль в комментарии
( ссылка )
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 https://bible.helloao.org/api/c/tyndale/profiles/aaron.jsonПолучить список доступных наборов данных
( ссылка )
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 https://bible.helloao.org/api/available_datasets.jsonПолучить список книг в наборе данных
( ссылка )
const dataset = 'open-cross-ref';
// Получите список книг для набора данных 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 https://bible.helloao.org/api/d/open-cross-ref/books.jsonИзвлечь главу из набора данных
( ссылка )
const dataset = 'open-cross-ref';
const book = 'GEN';
const chapter = 1;
// Получите первую главу Книги Бытия из набора данных open-cross-ref.
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 https://bible.helloao.org/api/d/open-cross-ref/GEN/1.json