Taiwan INFOTaiwan INFO中華民國歷史館 · 1912–2026

開發者 · v1

Taiwan INFO 新聞 API

Taiwan INFO News API

每 10 分鐘更新的台灣即時新聞與科技新聞 JSON。每則都由 Taiwan INFO 依公開報導(中央社、公視、自由時報、科技新報、iThome 等)以中立語氣重新改寫成中英文章,事實、數字、人名照原報導,並附上每一篇原始報導的連結。IG Reels 與 YouTube Shorts 影片另外由 /reels 提供。

你會拿到什麼

欄位內容
title.zh / title.en中英文標題
article.zh / article.en改寫後的完整文章(中文至少 200 字;英文約 180–320 字)
sources原始報導:媒體、標題、連結與時間
urltwinfo.huhm.cc 上的文章頁
/reels我們的影片(IG Reels/YouTube Shorts)與影片文章,格式與之前相同

新聞怎麼來:開源機器人(github.com/huhm-cc/twinfo-newsbot)每 10 分鐘讀取公開新聞 RSS,把同一事件的多家報導合併,挑幾則新新聞用自己的話改寫。不逐句抄寫、不大段引用、不加評論,事實、數字與人名照原報導;完整細節請以原始報導為準。

快速開始

  1. 右上角用 Google 登入,第一次登入要設定 ID 與暱稱。
  2. 到個人檔案 → API 金鑰,輸入名稱後按「產生金鑰」。
  3. 複製金鑰(開頭是 twk_)。金鑰只會顯示這一次,弄丟了就撤銷再產生一把新的。
  4. 每次請求都帶上金鑰:
curl -H "Authorization: Bearer twk_你的金鑰" \
  "https://twinfo.huhm.cc/api/v1/news?category=news&limit=5"

驗證方式

除了 /live 以外,所有端點都需要金鑰,用以下任一個標頭帶入:

Authorization: Bearer twk_xxxxxxxx
X-API-Key: twk_xxxxxxxx

速率限制

每個帳號每分鐘最多 300 次請求,所有金鑰合計。每分鐘整點重新計算。每個回應都有以下標頭:

標頭意思
X-RateLimit-Limit每分鐘上限(300)
X-RateLimit-Remaining這一分鐘還剩幾次
X-RateLimit-Reset重新計算的時間(Unix 秒)
Retry-After只在 429 時出現:要等幾秒

超過上限會回 HTTP 429,等 Retry-After 秒後再試。新聞每 10 分鐘更新一次,每 5–10 分鐘查一次就很夠了。

端點

基本網址: https://twinfo.huhm.cc/api/v1

GET /news

即時新聞(改寫文章),最新的在前面。

參數值說明
categoryall · news · tech預設 all。可用逗號合併,例如 news,tech
languagezh · entitle、summary、article 只回該語言(en 會略過沒有英文版的新聞)
dateYYYY-MM-DD指定某一天(台北時間)
from / toYYYY-MM-DD日期區間(含頭尾)
q文字,最多 50 字標題、摘要、文章或標籤包含的關鍵字
limit1–100每頁幾則,預設 20
offset0–100000跳過幾則。下一頁用 meta.next_offset
GET https://twinfo.huhm.cc/api/v1/news?category=news,tech&from=2026-11-01&limit=20

GET /news/{id}

用 id 取得單一則,可加 language=zh|en。

GET /reels · GET /reels/{id}

我們的影片:每支 IG Reels/YouTube Shorts 與影片文章、字幕、來源,格式和 2026 年 11 月 22 日以前的 /news 完全相同(video、article、transcript、sources…)。同一把金鑰、同樣參數(category = all | news | tech | history | other、language = 影片語言)、同樣速率限制。原本用 /news 拿影片的,把路徑改成 /reels 即可。

GET /live

我們在 YouTube 的 24 小時直播:頻道連結、目前與下一個節目、流程表與目前播放標題。公開、不需金鑰。詳細說明

GET /me

確認金鑰可用,並查看這一分鐘還剩多少額度。本身也算一次。

回應格式

{
  "data": [
    {
      "id": "20261122-c28f8339",
      "slug": "taiwan-banks-overseas-profit-record",
      "category": "news",
      "category_name": {
        "zh": "新聞",
        "en": "news"
      },
      "title": {
        "zh": "台灣的銀行前三季海外獲利達新高 逾八百億元",
        "en": "Taiwanese Banks' Overseas Profits Hit Record High Over NT$81.18 Billion in First Three Quarters"
      },
      "summary": {
        "zh": "金管會統計顯示,台灣的銀行今年前三季海外分支機構獲利達新台幣811.8億元,創歷年同期新高,主要受惠於放款成長及呆帳費用減少。",
        "en": "Financial Supervisory Commission data show that Taiwanese banks' overseas branch profits reached NT$81.18 billion in the first three quarters, marking a record for the period."
      },
      "article": {
        "zh": "金管會統計資料顯示,台灣的銀行今年前三季海外分支機構(含分、子行)的獲利總額為新台幣811.8億元,較去年同期增加98.5億元,創下歷年同期新高。\n\n…",
        "en": "According to data from the Financial Supervisory Commission, Taiwanese banks' overseas branch profits reached NT$81.18 billion in the first three quarters of 2026, up NT$9.85 billion from a year earlier and a record for the period.\n\n…"
      },
      "tags": [
        "台灣銀行業",
        "海外獲利",
        "金管會統計",
        "新南向政策國家",
        "金融業"
      ],
      "sources": [
        {
          "name": "中央社",
          "title": "國銀海外據點前3季獲利811億 美國新加坡日本寫同期新高",
          "url": "https://www.cna.com.tw/news/afe/202611220110.aspx",
          "published_at": "2026-11-22T16:04:37+08:00"
        },
        {
          "name": "自由時報",
          "title": "國銀海外很會賺!前3季獲利811.8億 創歷年新高",
          "url": "https://ec.ltn.com.tw/article/breakingnews/5649507",
          "published_at": "2026-11-22T14:18:40+08:00"
        }
      ],
      "published_at": "2026-11-22T17:50:12+08:00",
      "url": "https://twinfo.huhm.cc/articles/20261122-c28f8339",
      "attribution": "Taiwan INFO 台灣資訊 (https://twinfo.huhm.cc). Rewritten summary of the original reports listed in sources."
    }
  ],
  "meta": {
    "total": 2,
    "count": 1,
    "limit": 1,
    "offset": 0,
    "next_offset": 1,
    "updated_every": "10m"
  }
}
欄位說明
id這則的唯一 id
slug英文短網址字串
categorynews · tech
title{ zh, en } 標題
summary{ zh, en } 一句話摘要
article{ zh, en } 完整文章,段落以空行分隔
tags關鍵字(中文)
sources[]原始報導:name、title、url、published_at
published_atTaiwan INFO 發布時間,ISO 8601(+08:00)
urltwinfo.huhm.cc 文章頁
attribution使用內容時要標註的出處
meta.total符合條件的總數
meta.next_offset下一頁的 offset,最後一頁為 null

date、from、to 以 published_at 的台北日期計算。

錯誤

{
  "error": {
    "code": "rate_limited",
    "status": 429,
    "message": "超過速率限制:每個帳號每分鐘最多 300 次。"
  }
}
HTTPcode意思
400bad_request參數錯誤,看 detail
401missing_api_key沒有帶金鑰
401invalid_api_key金鑰錯誤或已撤銷
404not_found沒有這個 id
429rate_limited這一分鐘超過 300 次
500server_error我們這邊出錯,稍後再試

錯誤訊息語言依 Accept-Language 標頭(中文或英文)。

範例

JavaScript (Node 18+)

const KEY = process.env.TWINFO_API_KEY; // 不要把金鑰寫在前端網頁裡
const res = await fetch("https://twinfo.huhm.cc/api/v1/news?category=tech&limit=10", {
  headers: { Authorization: `Bearer ${KEY}` },
});
if (res.status === 429) {
  const wait = Number(res.headers.get("Retry-After") ?? 60);
  console.log(`超過限制,${wait} 秒後再試`);
} else {
  const { data, meta } = await res.json();
  for (const n of data) {
    console.log(n.title.zh, n.title.en, n.url);
    console.log(n.article.zh); // 改寫後的完整文章
    console.log(n.sources.map((s) => s.url)); // 原始報導
  }
  console.log("本分鐘剩餘:", res.headers.get("X-RateLimit-Remaining"));
}

Python:抓完所有分頁

import os, time, requests

KEY = os.environ["TWINFO_API_KEY"]
URL = "https://twinfo.huhm.cc/api/v1/news"

def fetch_all(category="news"):
    offset, items = 0, []
    while offset is not None:
        r = requests.get(URL, params={"category": category, "limit": 100, "offset": offset},
                         headers={"Authorization": f"Bearer {KEY}"}, timeout=10)
        if r.status_code == 429:
            time.sleep(int(r.headers.get("Retry-After", 60)))
            continue
        r.raise_for_status()
        body = r.json()
        items += body["data"]
        offset = body["meta"]["next_offset"]
    return items

for n in fetch_all()[:5]:
    print(n["title"]["zh"], "/", n["title"]["en"])
    print(n["article"]["zh"])
    print("Sources:", [s["url"] for s in n["sources"]])

# 影片(IG Reels/YouTube Shorts)請改用 /reels
reels = requests.get("https://twinfo.huhm.cc/api/v1/reels", params={"limit": 5}, headers={"Authorization": f"Bearer {KEY}"}).json()["data"]

瀏覽器可以直接呼叫(已開 CORS),但會讓金鑰外露,建議從你自己的伺服器呼叫。

24 小時直播(YouTube)

GET /live

Taiwan INFO 24 小時直播只在 YouTube 播出。這個端點回傳 YouTube 直播連結、目前與下一個節目、全天流程表(台北時間)與目前播放標題。公開、不需金鑰,已開 CORS,快取 15 秒。 到 YouTube 觀看

curl "https://twinfo.huhm.cc/api/v1/live"
{
  "data": {
    "status": "live",
    "youtube_channel_url": "https://www.youtube.com/@taiwaninfo.huhmcc/live",
    "youtube_channel_id": "UCi8vNt0kJHtlJyZDxSeFJug",
    "timezone": "Asia/Taipei",
    "program": { "id": "morning_news", "name": { "zh": "新聞時間", "en": "News Hour" },
                 "start": "2026-11-30T00:00:00+08:00", "end": "2026-11-30T11:00:00+08:00" },
    "next_program": { "id": "funfact", "name": { "zh": "台灣 FunFact", "en": "Taiwan FunFact" },
                      "start": "2026-11-30T11:00:00+08:00" },
    "now_playing": { "title": "…", "type": "news", "started_at": "2026-11-30T06:41:12+08:00" },
    "schedule": [
      { "id": "morning_news", "name": { "zh": "新聞時間", "en": "News Hour" }, "start": "00:00", "end": "11:00" },
      { "id": "funfact", "name": { "zh": "台灣 FunFact", "en": "Taiwan FunFact" }, "start": "11:00", "end": "14:00" },
      { "id": "global_tech", "name": { "zh": "國際 AI・電子・股市", "en": "Global AI, Tech & Markets" }, "start": "14:00", "end": "17:00" },
      { "id": "evening_news", "name": { "zh": "晚間新聞", "en": "Evening News" }, "start": "17:00", "end": "24:00" }
    ],
    "updated_at": "2026-11-30T06:41:12+08:00"
  },
  "attribution": "Taiwan INFO 台灣資訊 (https://twinfo.huhm.cc)"
}

status:播出主機超過 15 分鐘沒有回報時為 offline。now_playing.type:news(新聞)、funfact(冷知識)、program_intro(節目開場)、interlude(兩則之間的插播或待機畫面)。schedule 的 start、end 為台北時間 HH:MM(不含 end)。

使用規範

有問題請寫信到 hi@mail.huhm.cc