接入教程
1. 访问 https://runyankole-bible-api.vercel.app 获取API端点
2. 使用GET请求调用所需书籍或章节
3. 解析返回的JSON数据,提取经文内容
Python 获取圣经经文示例
python
import requests
base_url = 'https://api.example.com'
api_key = 'YOUR_API_KEY'
# 获取约翰福音3:16的经文
endpoint = f'{base_url}/verses'
params = {
'book': 'John',
'chapter': 3,
'verse': 16,
'api_key': api_key
}
response = requests.get(endpoint, params=params)
if response.status_code ==对一个:
data = response.json()
print(f"经文内容: {data.get('text')}")
else:
print(f"请求失败: {response.status_code}")
PHP 查询圣经书籍示例
php
<?php
$baseUrl = 'https://api.example.com';
$apiKey = 'YOUR_API_KEY';
// 获取所有圣经书籍列表
$endpoint = $baseUrl . '/books';
$params = [
'api_key' => $apiKey
];
$url = $endpoint . '?' . http_build_query($params);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 200) {
$data = json_decode($response, true);
echo "书籍数量: " . count($data['books']) . "\n";
} else {
echo "请求失败,状态码: " . $httpCode . "\n";
}
?>
JavaScript 搜索经文示例
javascript
const baseUrl = 'https://api.example.com';
const apiKey = 'YOUR_API_KEY';
// 搜索包含特定关键词的经文
async function searchVerses(keyword) {
const endpoint = `${baseUrl}/search`;
const params = new URLSearchParams({
'q': keyword,
'api_key': apiKey
});
try {
const response = await fetch(`${endpoint}?${params}`);
if (response.ok) {
const data = await response.json();
console.log(`找到 ${data.results.length} 条结果`);
return data.results;
} else {
console.error(`请求失败: ${response.status}`);
return [];
}
} catch (error) {
console.error('网络错误:', error);
return [];
}
}
// 使用示例
searchVerses('love');
常见问题
这个API是免费的吗?
是的,Runyankole Bible API 完全免费提供使用,无需付费订阅。
API的请求频率有限制吗?
为了保护服务器资源,API设有合理的速率限制,具体限制请参考官方文档。
API支持哪些数据格式?
API默认返回JSON格式的数据,这是最常用的数据交换格式。
Aitishiku.com