其他

非工作日日历数据库

提供ICS格式的非工作日日历数据库,用户可订阅或下载节假日安排。该API整合了多个地区的法定节假日信息,适用于日程管理和应用程序集成。

查看官方文档 ↗

接入教程

1. 访问GitHub仓库查看可用日历列表
2. 复制所需地区的ICS文件URL
3. 在日历应用中添加URL订阅
4. 或直接下载ICS文件到本地使用
5. 根据需求定期更新订阅链接

使用Python获取节假日日历

python
import requests

url = 'https://api.example.com/v1/calendars/region/cn'
headers = {'Authorization': 'Bearer YOUR_API_KEY'}
params = {'year': 2024, 'format': 'ics'}

response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
    calendar_data = response.text
    print('Calendar retrieved successfully')
else:
    print(f'Error: {response.status_code}')
    print(response.text)

使用PHP订阅节假日日历

php
<?php
$apiUrl = 'https://api.example.com/v1/subscriptions';
$apiKey = 'YOUR_API_KEY';

$data = [
    'region' => 'us',
    'callback_url' => 'https://your-domain.com/webhook'
];

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $apiKey,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 201) {
    echo 'Subscription created successfully';
} else {
    echo 'Error: ' . $httpCode;
    echo $response;
}
?>

使用JavaScript获取日历数据

javascript
const apiUrl = 'https://api.example.com/v1/calendars';
const apiKey = 'YOUR_API_KEY';

async function fetchCalendar(regionCode) {
    try {
        const response = await fetch(`${apiUrl}/region/${regionCode}?format=json`, {
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            }
        });
        
        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }
        
        const data = await response.json();
        console.log('Calendar data:', data);
        return data;
    } catch (error) {
        console.error('Error fetching calendar:', error);
    }
}

// 示例用法
fetchCalendar('jp');

常见问题

如何获取特定地区的节假日日历?

通过向 /v1/calendars/region/{region_code} 端点发送GET请求,其中region_code为地区代码(如cn、us、jp)。您可以选择返回格式(ics或json),并指定年份参数。

API是否支持日历订阅功能?

是的,API提供订阅功能。您可以创建订阅以自动接收特定地区的日历更新。当节假日信息变更时,系统将通过您提供的回调URL发送通知。

请求频率是否有限制?

是的,免费API有请求频率限制。具体限制取决于您的API密钥类型。建议合理缓存日历数据,避免频繁请求相同信息。详细限制请查阅API文档。

相似接口推荐

AWS SSO Identity Store

AWS SSO Identity Store是AWS IAM Identity Center(原AWS单点登录)使用的身份存储服务,提供一个统一的位置检索所有身份信息(用户和群组)。该服务简化了身份管理流程,帮助集中管理

待确认
Amazon Honeycode

Amazon Honeycode是一项全托管服务,让您无需编程即可快速为团队构建移动和Web应用。可用于管理项目、客户、运营、审批、资源乃至团队协作等各类事务。

待确认
AWS Glue

AWS Glue 是一项完全托管的提取、转换和加载(ETL)服务,可简化数据准备和集成工作。它自动发现、编目数据,并支持在数据湖和数据仓库之间进行ETL操作。

待确认
亚马逊Glacier

亚马逊S3 Glacier(简称Glacier)是一款针对“冷数据”的存储解决方案。这项超低成本的存储服务为数据备份和归档提供安全、持久且易于使用的存储方案。用户可经济高效地存储数据数月、数年甚至数十年。

待确认