Twinkle HubTwinkle Hub

進出口貿易統計 (財政部 · 國家 × 貨品)

tw_lookup_trade_stats

驗證小工具 · 同一族🇹🇼 台灣唯讀

關鍵字 / Keywords: 進出口 貿易統計 貿易值 出口值 進口值 對美出口 出超 入超 貿易順差 貿易逆差 HS 類 章 SITC 財政部 海關 trade statistics exports imports trade balance HS SITC Taiwan

台灣進出口貿易值(財政部統計資料庫,一般貿易制度):依 國家 / 地區 × 出口 / 進口 × 貨品分類 × 期間 × 幣別 即時查詢,回長表 rows(每列 period, country, direction, commodity_code, commodity_name, value, unit)。

value 只有貿易值(千美元 / 百萬元新臺幣),沒有數量、重量。

上游有的切片(不在下列範圍的組合會回 unsupported_combination 並說明可以怎麼改):

  • 不給 partner(全球):HS 類(S01–S21)、HS 章(HS01–HS97)、SITC(SITC0 / SITC75 / SITC752 …)、總值;美元或新臺幣
  • 給 partner、不給 commodity:205 個國家 / 洲別的總值,可查 direction="balance"(出(入)超);美元或新臺幣
  • 給 partner + HS 類:只有 18 個主要國家 / 地區(美國、日本、南韓、中國大陸、香港、中國大陸與香港、東協與東協各國), 第 1–18 類 + OTHER(其他);只有美元(千美元)
  • 沒有「國家 × HS 章 / SITC」

Args: partner: 國家 / 地區 / 洲別,例 "美國" "US" "日本" "東協" "歐洲"。None = 全球。不確定寫法先用 codes="partners". direction: "export" 出口 · "import" 進口 · "both" 兩者(預設)· "balance" 出(入)超(只有總值). commodity: 貨品,可給多個(list 或逗號分隔,最多 30 項)。"S16" / "第十六類" = HS 第十六類;"HS85" / "85章" = HS 第 85 章; "SITC75";"TOTAL" 總計;也可給名稱關鍵字(例 "機械")。None = 總計. classification: 只給數字時怎麼解讀:"hs_section"(預設,"16" = 第十六類)· "hs_chapter"("85" = 第 85 章)· "sitc". freq: "month"(預設)或 "year"。年資料的當年度若未滿 12 個月會列在 partial_periods. period_start / period_end: 期間,例 "2025-11" "114-11" "2025"(民國或西元皆可)。都不給 = 最近 last 期. last: 最近幾期(月資料預設 12、年資料預設 5;period_start / period_end 都不給時用). currency: "USD"(千美元,預設)或 "TWD"(百萬元新臺幣). codes: 只列代碼不查資料:"partners" / "hs_section" / "hs_chapter" / "sitc".

Returns: rows(長表)、n_rows、unit、latest_period(上游最新一期)、query(解讀後的條件)、table(用到的上游表)、 partial_periods(年資料)、notes、source / source_url。value 為 null = 上游以「-」表示該期無數值.

Source: 財政部統計資料庫 進出口貿易統計(data.gov.tw 8382 / 8383 / 28573 / 15392 / 8379 的同一組上游表). License: OGDL v1(財政部). 相同查詢 6 小時快取.

參數

參數型別說明
partnerstring—
directionstring | array—
commoditystring | array—
classificationstring—
freqstring—
period_startstring—
period_endstring—
lastinteger—
currencystring—
codesstring—
原始 JSON schema
{
  "properties": {
    "partner": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Partner"
    },
    "direction": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      ],
      "default": "both",
      "title": "Direction"
    },
    "commodity": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Commodity"
    },
    "classification": {
      "default": "hs_section",
      "title": "Classification",
      "type": "string"
    },
    "freq": {
      "default": "month",
      "title": "Freq",
      "type": "string"
    },
    "period_start": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Period Start"
    },
    "period_end": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Period End"
    },
    "last": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Last"
    },
    "currency": {
      "default": "USD",
      "title": "Currency",
      "type": "string"
    },
    "codes": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Codes"
    }
  },
  "title": "tw_lookup_trade_statsArguments",
  "type": "object",
  "additionalProperties": false
}

呼叫​方式

起手式——參數見上表
tw_lookup_trade_stats({ partner: "…" })