---
title: "貴金屬 現貨 API 參考 | Narwhal API"
description: "貴金屬 現貨 API 參考提供黃金、白銀、鉑金和鈀金的現貨價格，另有 WTI、布蘭特原油與銅的參考價格，每筆資料都附上單位和 UTC 時間戳記，方便你核對報價的對應單位與時間。"
url: "https://narwhalapi.com/zh-tw/docs/api/commodities/spot"
---

# 貴金屬 現貨 API 參考文件

貴金屬 現貨 API 參考提供黃金、白銀、鉑金和鈀金的現貨價格，另有 WTI、布蘭特原油與銅的參考價格，每筆資料都附上單位和 UTC 時間戳記，方便你核對報價的對應單位與時間。

## 身分驗證與請求

請以 Bearer 驗證方式，在 Authorization 標頭中傳送你的 API 金鑰。 [產品概覽 →](https://narwhalapi.com/zh-tw/api/commodities/spot.md)

```
curl "https://api.narwhalapi.com/v1/commodities/spot/XAU/USD" \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

## 操作

| 端點 | 操作 |
| --- | --- |
| `GET /v1/commodities/spot/{commodity}/{currency}` | 取得現貨價格或基於期貨的參考價格。 |
| `GET /v1/commodities/spot/{commodity}/{currency}/bars` | 取得黃金、白銀、鉑金、鈀金、銅、WTI 和 BRENT 的開盤價、最高價、最低價和收盤價價格柱。銅的歷史資料也可用。 |

## 參數

| 欄位 | 含義 |
| --- | --- |
| `commodity` | 路徑參數。XAU、XAG、XPT、XPD、WTI（WTI 原油）、BRENT（布蘭特原油）或 XCU（銅）。 |
| `currency` | 路徑參數，使用大寫。黃金：USD, AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HKD, HUF, IDR, ILS, INR, ISK, JPY, KRW, MXN, MYR, NOK, NZD, PHP, PLN, RON, SEK, SGD, THB, TRY 或 ZAR。白銀、鉑金、鈀金、WTI、BRENT 和 XCU：僅支援 USD。 |
| `unit` | 現貨與價格柱請求均可使用。選填，可填`troy_ounce`、`gram`、`kilogram`、`pound`或`metric_ton`。價格以該單位計價，回應中的`unit`和`unit_key`會標明該單位。黃金、白銀、鉑、鈀和銅（XCU）可使用全部五種單位；WTI與BRENT以桶報價，只能使用`barrel`。其他值會回傳`400 unit_not_supported`。未傳`unit`時，回應與先前相同。 |
| `interval` | 僅適用於價格柱。1m、5m、15m、1h、4h或1d（預設值）。 |
| `start / end` | 僅適用於價格柱。兩項均必填。使用位於間隔邊界的UTC時間（4h為00、04、08時等；1d為午夜）。包含開始時間，不包含結束時間。 |
| `limit / cursor` | 僅適用於價格柱。預設100，最多500。使用相同查詢重複使用next_cursor。 |

## 報價欄位

| 欄位 | 含義 |
| --- | --- |
| `symbol, currency, unit` | 代碼和報價貨幣。貴金屬的 unit 為 troy_ounce，WTI 和 BRENT 為 barrel，XCU 為 pound。 |
| `commodity_key` | `commodity_key` 在現貨、期貨、預測與實物價格中以相同方式命名商品，例如 gold 或 crude-oil。原油另有 `benchmark`（wti、brent、urals 或 dubai），期貨則有 `exchange_mic`，也就是交易所的標準代碼。 |
| `unit_key` | `unit_key` 以單一標準寫法表示單位，例如 troy_ounce、barrel 或 tonne；`unit` 保留來源的原始寫法。當價格以分報價時，`price_scale` 為 0.01：將價格乘以它，即可得到以 `currency` 計價的金額。 |
| `price` | 一個正數參考價格，以十進位字串表示。 |
| `timestamp, stale` | 報價的 UTC 時間戳記與明確的資料時效旗標。 |
| `bars` | 僅適用於價格柱。依從舊到新的順序回傳已收盤的價格柱。每個價格柱都有timestamp（柱的開始時間），以及十進位字串形式的open、high、low和close。非USD貨幣的黃金僅有close。 |
| `start, end` | 僅在 Narwhal 變更了請求的範圍時，才回傳 `start` 和 `end`。 |
| `next_cursor` | 僅適用於價格柱。用於繼續查詢的游標；沒有更多價格柱時為null。 |

範例回應： `GET /v1/commodities/spot/{commodity}/{currency}`。

報價回應

```
{
  "symbol": "XAU-USD",
  "commodity_key": "gold",
  "price": "3550.6320",
  "currency": "USD",
  "unit": "troy_ounce",
  "unit_key": "troy_ounce",
  "timestamp": "2026-11-20T05:54:00Z",
  "stale": false
}
```

WTI 報價回應

```
{
  "symbol": "WTI-USD",
  "commodity_key": "crude-oil",
  "benchmark": "wti",
  "price": "82.5990",
  "currency": "USD",
  "unit": "barrel",
  "unit_key": "barrel",
  "timestamp": "2026-11-20T05:52:00Z",
  "stale": false
}
```

With `unit=gram`, a silver quote is priced per gram.

以公克計價的報價請求

```
curl "https://api.narwhalapi.com/v1/commodities/spot/XAG/USD?unit=gram" \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

以公克計價的報價回應

```
{
  "symbol": "XAG-USD",
  "commodity_key": "silver",
  "price": "1.31824",
  "currency": "USD",
  "unit": "gram",
  "unit_key": "gram",
  "timestamp": "2026-11-21T18:11:00Z",
  "stale": false
}
```

A converted price is worked out in exact decimals from the price shown without `unit`, with 1 troy ounce = 31.1034768 g and 1 pound = 453.59237 g. It keeps as many significant figures as that price (trailing zeros of a whole number do not count), and a price under 10 keeps at least 4 decimals. Halves round up and zeros after the decimal point are dropped. Bars convert `open`, `high`, `low` and `close` the same way.

Bars response for `GET /v1/commodities/spot/{commodity}/{currency}/bars`. `start` and `end` are returned only when Narwhal changes the requested range.

價格柱回應

```
{
  "symbol": "XAU-USD",
  "commodity_key": "gold",
  "currency": "USD",
  "unit": "troy_ounce",
  "unit_key": "troy_ounce",
  "bars": [
    {
      "timestamp": "2026-10-01T00:00:00Z",
      "open": "4156.8352",
      "high": "4192.5215",
      "low": "4139.7787",
      "close": "4177.4458"
    },
    {
      "timestamp": "2026-10-02T00:00:00Z",
      "open": "4177.2183",
      "high": "4225.6497",
      "low": "4125.9232",
      "close": "4141.5280"
    }
  ],
  "next_cursor": null
}
```

Gold in a currency other than USD has `close` only.

換算貨幣後的價格柱回應

```
{
  "symbol": "XAU-EUR",
  "commodity_key": "gold",
  "currency": "EUR",
  "unit": "troy_ounce",
  "unit_key": "troy_ounce",
  "bars": [
    {
      "timestamp": "2026-10-01T00:00:00Z",
      "close": "3715.66"
    },
    {
      "timestamp": "2026-10-02T00:00:00Z",
      "close": "3680.67"
    }
  ],
  "next_cursor": null
}
```

A request may span at most 3 days of `1m` bars, 14 days of `5m` bars, 60 days of `15m` bars; a longer range returns `400 invalid_query`. Wider intervals have no cap.

## 解讀資料

WTI, BRENT and XCU are reference prices derived from futures markets, not physical spot cargo prices. Display the unit and timestamp with the price. The timestamp is the start of the minute the price belongs to; during the daily 17:00 New York metals pause (21:00 UTC in summer, 22:00 UTC in winter), which is not a market closure, a quote can carry stale: true. A closed market never makes a quote stale: from Friday 17:00 to Sunday 17:00 New York time you get the last price with stale: false. A quote is stale when its price is more than 10 minutes old, counting only open-market time; do not present a stale quote as a fresh market price. An unknown commodity returns 404 `commodity_not_supported`. A known commodity with an unsupported currency returns 404 `currency_not_supported`. Price history is available for gold, silver, platinum, palladium, copper (XCU), WTI and BRENT. We never fill gaps: missing bars stay missing. We keep `1m` and `5m` bars for 30 days and `15m`, `1h`, `4h` and `1d` bars indefinitely. A range outside retention returns an empty `bars` list, not an error. WTI and BRENT have 15-minute and hourly history from 2020.

現貨價格對所有帳戶即時開放，包括僅使用免費額度的帳戶。價格串流已結束；請改為輪詢此路由。 [價格串流參考文件 →](https://narwhalapi.com/zh-tw/docs/api/prices-stream.md)
[錯誤格式與額度 →](https://narwhalapi.com/zh-tw/docs/errors.md)

## 錯誤

- 路徑值無效、開始或結束時間不在間隔邊界、價格柱請求缺少`start`或`end`，或價格柱範圍超過該間隔允許的長度時，回傳`400 invalid_query`。
- Bearer金鑰缺少或無效時回傳`401 invalid_api_key`。
- `400 unit_not_supported`：所指定的`unit`不適用於該商品。錯誤詳情會列出該商品允許使用的單位。
- Narwhal不提供的商品回傳`404 commodity_not_supported`；該商品不支援的貨幣回傳`404 currency_not_supported`。
- 達到每分鐘上限時回傳 `429 rate_limit_exceeded`，餘額不足以支付呼叫時回傳 `402 insufficient_credits`。
- 無法讀取價格資料時回傳`503 upstream_unavailable`。

## MCP 工具

`commodities_get_spot_price` `commodities_get_price_history`

[透過 MCP 連線 →](https://narwhalapi.com/zh-tw/docs/mcp.md)

此頁面對你有幫助嗎?
