浏览全部文档

贵金属现货价格 API 参考

贵金属现货价格 API 提供黄金、白银、铂金和钯金的现货价格,以及 WTI、布伦特原油和铜的参考价格,每项数据都附带单位和 UTC 时间戳。本页列出请求参数和响应字段。

身份验证和请求

在 Authorization 请求头中以 Bearer 方式发送你的 API 密钥。 产品概览 →

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_keycommodity_key 在现货、期货、预测和实物价格中以相同的方式命名商品,例如 gold 或 crude-oil。原油还带有 benchmark(wti、brent、urals 或 dubai),期货则带有 exchange_mic,即交易所的标准代码。
unit_keyunit_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.

现货价格对所有账户开放实时数据,包括仅使用免费额度的账户。价格数据流已结束;请改为轮询此路由。 价格流参考文档 →

错误格式与额度 →

错误

  • 路径值无效、开始或结束时间不在间隔边界、价格柱请求缺少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_pricecommodities_get_price_history

通过 MCP 连接 →

此页面对你有帮助吗?