Get a commodity price in your currency

Gold is Rp 71,903,700 a troy ounce, or Rp 2,311,758 a gram. Ask the spot endpoint for the currency code you want after the commodity code. Gold accepts any supported FX currency directly; for other commodities, multiply the US dollar spot price by the exchange rate from dollars to your currency.

Do it with the API

Use the commodity code to choose the metal or oil, then the currency code to choose its quote currency. Gold supports a direct rupiah request. Silver, platinum, palladium, copper, WTI and Brent spot prices are quoted in US dollars, so their rupiah calculation also needs the USD/IDR exchange rate.

On Free, spot commodity and FX prices use the previous UTC day's close. This applies to both the direct gold request and the prices used for conversion. Keep that date with the resulting rupiah amount when you display it, along with whether the amount is per troy ounce or per gram.

  1. Get your API key Get a free key and keep it in the environment variable NARWHAL_API_KEY. Send it as Authorization: Bearer YOUR_KEY with requests to https://api.narwhalapi.com; the commodity and FX requests use the same account and key.
  2. Choose the quote currency For gold in rupiah, request GET /v1/commodities/spot/XAU/IDR; for silver, request its USD spot price and GET /v1/fx/rates/USD?currencies=IDR. The currency after the gold code sets the currency of the direct quote, while the FX request supplies the rate for converting silver.
  3. Calculate the rupiah prices Use the Python script to read gold directly in IDR and multiply silver's dollar price by the USD/IDR rate. It also divides the gold quote by the grams in a troy ounce to give a rounded price per gram.
    Python, gold and silver in Indonesian rupiah
    import os
    import requests
    
    H = {"Authorization": f"Bearer {os.environ['NARWHAL_API_KEY']}"}
    API = "https://api.narwhalapi.com/v1"
    GRAMS_PER_TROY_OUNCE = 31.1034768
    
    # Gold is quoted in every FX currency we serve, so ask for rupiah directly.
    gold = requests.get(f"{API}/commodities/spot/XAU/IDR", headers=H, timeout=10).json()
    print("gold IDR per oz  ", gold["price"], "->", round(float(gold["price"]) / GRAMS_PER_TROY_OUNCE), "per gram")
    
    # Silver is quoted in US dollars only: convert with the USD/IDR rate.
    silver = float(requests.get(f"{API}/commodities/spot/XAG/USD", headers=H, timeout=10).json()["price"])
    idr = float(requests.get(f"{API}/fx/rates/USD", params={"currencies": "IDR"}, headers=H, timeout=10).json()["rates"][0]["rate"])
    print("silver IDR per oz", round(silver * idr), "=", silver, "x", idr)
  4. Keep the unit with the price Read the gold output as rupiah per troy ounce and rupiah per gram, and the silver output as rupiah per ounce. Currency conversion changes the currency of the silver quote; the separate gold division changes its weight unit.

The script reads price from each commodity response and rate from the FX response's rates array. Gold's per-gram amount is rounded after division, while silver's rupiah amount is rounded after multiplication. The printed silver calculation includes the dollar price and the exchange rate used in that multiplication.

API errors use application/problem+json with status, code, detail and request_id. If a request returns an error, read its code and detail before using the response in a price calculation.

Get the price in a sheet or without code

For gold without code, open the Narwhal gold price pages, which show gold in many currencies. Use that route when you want to read a gold price in your currency without writing the commodity and FX requests yourself.

In a sheet, use =XAUUSD * USDIDR, with both cells populated from the API. XAUUSD holds the gold price in US dollars and USDIDR holds the dollar-to-rupiah rate. Their product is the gold price in rupiah for the same weight unit. This is the converted route for gold; the API also accepts a direct gold request in IDR.

Which option to use when

SituationBest optionWhy
Gold in a supported currencyAsk for the currency directlyGold spot supports every currency on the FX coverage list
Any other commodity in your currencyMultiply the USD spot price by the USD/currency rateOther commodity spot quotes are USD only
A price at one specific timeUse bars with the same timestamp for both legsThe commodity price and exchange rate need to refer to the same time

Why do direct and converted gold prices in rupiah differ?

The quotes carry different timestamps. In the 24 October 2026 example, the direct gold quote in rupiah is stamped 23 October 2026 at 20:59 UTC, while the FX rate is stamped 23 October 2026 at 00:00 UTC. Multiplying the dollar gold quote by that FX rate therefore uses a different timestamp from the direct rupiah quote.

For the 24 October 2026 example, gold at USD 3,996.00 multiplied by USD/IDR 18,107.8 gives Rp 72,358,769, which is 0.3% above the direct Rp 72,145,300 quote. Pick one method and stay with it. For a price at a specific time, use bars with the same timestamp for both legs.

Do I multiply or divide by the USD/IDR rate?

Multiply a dollar commodity price by the USD/IDR rate to get rupiah. In the 24 October 2026 example, USD/IDR 18,107.8 means one US dollar buys 18,107.8 rupiah. Read the rate as rupiah for each dollar, then multiply it by the number of dollars in the commodity quote.

Keep currency conversion separate from weight conversion. Multiplying by USD/IDR gives a rupiah price in the commodity quote's weight unit. To express a gold price per gram, divide its price per troy ounce by 31.1034768, the number of grams in a troy ounce.

Which currencies can I request directly for gold?

Gold supports the currencies on the FX coverage list. Use the listed currency code after XAU in the spot request. A 404 currency_not_supported means the commodity is not quoted in that currency.

The currency list applies to gold's direct quotes. Silver, platinum, palladium, copper, WTI and Brent spot remain USD only. For those commodities, use a USD quote and multiply by the USD exchange rate for the currency you want.

Worked example: gold and silver in rupiah

On 24 October 2026, the direct gold quote was Rp 72,145,300 per troy ounce. Start with that rupiah amount and divide by 31.1034768 grams per troy ounce. Round the result to the nearest rupiah to get Rp 2,319,525 per gram.

For silver on 24 October 2026, start with the USD 53.9171 spot price per ounce. Multiply it by the USD/IDR rate of 18,107.8, then round to the nearest rupiah. The result is Rp 976,320 per ounce.

Calculation for 24 October 2026FiguresRounded result
Gold per gramRp 72,145,300 / 31.1034768Rp 2,319,525 per gram
Silver per ounceUSD 53.9171 × 18,107.8 IDR per USDRp 976,320 per ounce

Published .