金価格APIでスポット金属価格を取得
金価格APIで、金、銀、プラチナ、パラジウムのスポット価格と、WTI、ブレント、銅の参照価格を、単位とUTCタイムスタンプ付きで取得できます。リクエスト例も掲載しています。
認証とリクエスト
APIキーを Authorization ヘッダーに Bearer スキームで指定して送信します。 製品概要→
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_、gram、kilogram、pound、metric_のいずれかを指定できます。価格は指定した単位あたりになり、レスポンスのunitとunit_にその単位が入ります。金、銀、プラチナ、パラジウム、銅(XCU)は5つすべてに対応します。WTIとBRENTはバレル単位で提供され、barrelのみ指定できます。それ以外の値は400 unit_を返します。unitを指定しない場合は、これまでと同じレスポンスです。 |
interval | バーのみ。1m、5m、15m、1h、4h、1d(デフォルト)のいずれか。 |
start / | バーのみ。両方とも必須。UTC時刻をインターバルの境界に合わせます(4hは00、04、08時など、1dは午前0時)。開始を含み、終了を含みません。 |
limit / | バーのみ。デフォルトは100、最大500です。同じクエリでnext_cursorを再利用してください。 |
気配値のフィールド
| フィールド | 意味 |
|---|---|
symbol, currency, unit | シンボルと建値通貨。unitは貴金属ではtroy_ounce、WTIとBRENTではbarrel、XCUではpoundです。 |
commodity_ | commodity_ は、現物価格、先物価格、予測市場、実物価格のどれでも同じ名前で商品を示します(例: gold、crude-oil)。原油には benchmark(wti、brent、urals、dubai)も付き、先物には取引所の標準コードである exchange_ も付きます。 |
unit_ | unit_ は単位を標準の綴りで示します(例: troy_ounce、barrel、tonne)。unit はソースの表記のままです。価格がセント単位で提示されている場合、price_ は 0.01 です。価格にこの値を掛けると currency での金額になります。 |
price | 正の参考価格を1つ、十進数の文字列で表します。 |
timestamp, stale | 気配値の UTC タイムスタンプと、鮮度を明示するフラグ。 |
bars | バーのみ。確定済みのバーを古い順に返します。各バーにはtimestamp(バーの開始時刻)と、10進文字列のopen、high、low、closeが含まれます。USD以外の金にはcloseだけが含まれます。 |
start, end | start と end は、Narwhal がリクエストされた範囲を変更した場合のみ返されます。 |
next_ | バーのみ。続きの取得用カーソル。残りのバーがない場合は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
}{
"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 /. 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_. 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_. A known commodity with an unsupported currency returns 404 currency_. 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 - 1分あたりの上限に達した場合は
429 rate_、残高が呼び出しに足りない場合はlimit_ exceeded 402 insufficient_を返します。credits - 価格データを読み取れない場合は
503 upstream_を返します。unavailable
MCPツール
commodities_get_spot_pricecommodities_get_price_historyこのページは役に立ちましたか?