接入教程
1. 访问官网查看文档
2. 选择需要的年份参数
3. 调用API接口获取数据
4. 解析返回的JSON格式
5. 集成到您的应用中
获取2024年礼仪日历
import requests
url = "http://calapi.inadiutorium.cz/api/v0/calendars/general-en/2024"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
calendar_data = response.json()
print(f"Fetched {len(calendar_data)} liturgical events for 2024")
else:
print(f"Error: {response.status_code}")
查询特定日期礼仪信息
<?php
$url = "http://calapi.inadiutorium.cz/api/v0/calendars/general-en/2024/12/25";
$options = [
'http' => [
'header' => "Authorization: Bearer YOUR_API_KEY\r\n"
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$liturgical_day = json_decode($response, true);
echo "Liturgical celebration: " . $liturgical_day['celebrations'][0]['title'] . "\n";
} else {
echo "Failed to fetch liturgical data\n";
}
?>
在浏览器中获取礼仪季节
const fetchLiturgicalSeason = async (year, month, day) => {
const url = `http://calapi.inadiutorium.cz/api/v0/calendars/general-en/${year}/${month}/${day}`;
try {
const response = await fetch(url, {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const data = await response.json();
console.log('Liturgical season:', data.season);
return data;
} catch (error) {
console.error('Failed to fetch liturgical data:', error);
}
};
// Example usage
fetchLiturgicalSeason(2024, -1, -1); // Gets entire year
常见问题
该API是否需要认证?
是的,该API需要Bearer Token认证。请在请求头中添加Authorization: Bearer YOUR_API_KEY。部分公开数据可能允许匿名访问,但建议始终使用认证以确保服务稳定性。
返回数据支持哪些格式?
API默认返回JSON格式数据。您可以通过设置Accept请求头来指定其他格式(如XML),具体支持格式请参考官方文档。日期格式遵循ISO 8601标准。
如何获取特定年份的完整日历?
向/calendars/{calendar}/{year}端点发送GET请求即可获取指定年份的完整礼仪日历。{calendar}参数指定日历类型(如general-en),{year}为四位数年份。
Aitishiku.com