---
title: "假日 API 列出各國年度假日 | Narwhal API"
description: "假日 API 可讀取指定國家與年份已發布的國定假日年度行事曆。本頁完整列出請求參數、回應欄位與 MCP 呼叫範例，並說明當涵蓋範圍缺失時，API 實際會有什麼樣的行為。"
url: "https://narwhalapi.com/zh-tw/docs/api/calendars/holidays"
---

# 假日 API：列出各國年度國定假日

取得一個國家和年份的完整已發布行事曆。

## 請求

使用 Narwhal 金鑰即可存取已發布的國家與年份資料。 [檢查資料涵蓋範圍與適用範圍](https://narwhalapi.com/zh-tw/docs/api/calendars.md#coverage) 後，再查詢指定日期。

```
GET /v1/calendars/holidays/{country}/{year}
```

```
curl "https://api.narwhalapi.com/v1/calendars/holidays/IDN/2026" \
  -H "Authorization: Bearer $NARWHAL_API_KEY"
```

## 參數

| 名稱 | 類型 | 規則 |
| --- | --- | --- |
| `country` | 字串 | 必填路徑值。一個受支援的大寫 ISO 三字母代碼，例如 IDN。 |
| `year` | 整數 | 必填路徑值，範圍為 1900–2200（含首尾）。此範圍不保證提供相應的歷史資料。 |
| `version_id` | UUID 字串 | 選用查詢值，取自假日事件的resource_version。在來源使用權仍有效時讀取該國家和年份的不可變日曆。省略時讀取目前的日曆。未知版本回傳404 calendar_not_published；讀取失敗回傳503。 |
| `scope` | 字串 | 選用查詢篩選條件：national_public、regional_public、bank、federal_government、central_government、collective_leave、public_sector或private_sector。省略時回傳所有已發布的類別。如果該國家和年份未發布所選範圍的資料，則回傳404 calendar_not_published；回應中的coverage只列出該範圍。 |

不提供行政區篩選或分頁功能。MCP 輸入物件不接受額外欄位。

## 示意回應

```
{
  "country": "IDN",
  "coverage": [
    {
      "scope": "collective_leave",
      "subdivision_codes": []
    },
    {
      "scope": "national_public",
      "subdivision_codes": []
    }
  ],
  "holidays": [
    {
      "date": "2026-08-17",
      "name": "Independence Day",
      "holiday_key": "independence_day",
      "local_name": "Proklamasi Kemerdekaan",
      "subdivision_codes": [],
      "scope": "national_public"
    }
  ]
}
```

回傳已發布年份的完整資料，依日期與名稱排序，排序值相同時以固定規則決定順序。同一天的不同假日仍分開列出。不提供分頁。範例僅顯示一個事件，並非完整行事曆。

[共享假日欄位](https://narwhalapi.com/zh-tw/docs/api/calendars.md#fields)。每個事件都會明確標示適用於全國或特定地區。

## 對應的 MCP 呼叫

傳送經過身分驗證的請求，端點與標頭如下： `POST /mcp` 與 `Accept: application/json, text/event-stream`。

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "calendars_list_holidays",
    "arguments": {
      "country": "IDN",
      "year": 2026
    }
  }
}
```

成功的結果包含 `isError: false`，相同的回應位於 `structuredContent`，序列化後的 JSON 則位於 `content[0].text`。領域錯誤包含 `isError: true`。

## API 錯誤 處理：錯誤碼、額度與重試

Invalid inputs return 400; missing or invalid keys return 401. Unmounted routes return 404. The per-minute limit returns 429, and a balance that cannot pay for the call returns 402. 請求的國家與年份的行事曆尚未發布時回傳 `404 calendar_not_published`；目前無法安全提供的行事曆回傳 `503 calendar_coverage_unavailable`。

一次成功的請求，無論讀取多少個事件或年份，都計為一次呼叫。錯誤不收費。 [共享錯誤詳情](https://narwhalapi.com/zh-tw/docs/errors.md)。

[所有行事曆操作](https://narwhalapi.com/zh-tw/docs/api/calendars.md) · [涵蓋範圍與解讀](https://narwhalapi.com/zh-tw/methodology/calendars.md) · [國定假日 API](https://narwhalapi.com/zh-tw/api/calendars/holidays.md)

此頁面對你有幫助嗎?
