请求说明
查询指定年份、月份或单日的工作日/节假日信息。需先在管理后台录入该年国务院放假通知。
扣费:1 点/次。
调用地址:请登录控制台,在「我的密钥」页查看完整 API 调用地址。公开文档仅展示接口路径 /open/v1/{slug}。示例中的 <调用地址> 请替换为控制台中的实际地址。
请求体 (JSON)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
year | integer | 否 | 年份,如 2026;与 date 二选一 |
month | integer | 否 | 月份 1-12,与 year 配合使用 |
date | string | 否 | 单日,格式 YYYY-MM-DD;与 year 二选一 |
dayType 说明
workday— 普通工作日holiday— 法定节假日放假adjusted_workday— 调休上班(周末需上班)
holidayType 枚举
new_year— 元旦spring_festival— 春节qingming— 清明节labor_day— 劳动节dragon_boat— 端午节mid_autumn— 中秋节national_day— 国庆节
days[] 元素字段
date— 日期 YYYY-MM-DDweekdayName— 中文星期isWorkday— 是否工作日dayType— 日类型holidayType— 节假日类型holidayName— 节假日名称
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
days | CalendarDay[] | 日历明细列表 |
count | integer | 返回天数 |
year | integer | 按年查询时返回 |
month | integer | 按月查询时返回 |
date | string | 按日查询时返回 |
调用示例
curl -X POST -H "Content-Type: application/json" -H "X-API-Key: sk-your-key" -d '{"year":2026,"month":1}' "<调用地址>/workday"package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest(http.MethodPost, "<调用地址>/workday", bytes.NewBufferString(`{"year":2026,"month":1}`))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "sk-your-key")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}<?php
$ch = curl_init('<调用地址>/workday');
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-API-Key: sk-your-key'],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => '{"year":2026,"month":1}',
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("<调用地址>/workday"))
.header("Content-Type", "application/json")
.header("X-API-Key", "sk-your-key")
.POST(HttpRequest.BodyPublishers.ofString("{"year":2026,"month":1}"))
.build();
HttpResponse<String> response = client.send(
request,
HttpResponse.BodyHandlers.ofString()
);
System.out.println(response.body());const response = await fetch('<调用地址>/workday', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'sk-your-key',
},
body: JSON.stringify({"year":2026,"month":1}),
});
const data = await response.json();
console.log(data);响应示例
{
"year": 2026,
"month": 1,
"count": 31,
"days": [
{
"date": "2026-01-01",
"weekdayName": "星期四",
"isWorkday": false,
"dayType": "holiday",
"holidayType": "new_year",
"holidayName": "元旦"
}
]
}补充说明
- year 与 date 至少提供一个;仅 date 时可不依赖节假日年度配置。
- 响应头 Cache-Control: public, max-age=3600。