Spot prices and bars per gram, kilogram, pound or metric ton
GET /v1/commodities/spot/{commodity}/{currency} and its /bars route take an optional unit, so gold, silver and copper can be priced in the unit you trade.
GET /v1/commodities/spot/{commodity}/{currency} and its /bars route take an optional unit, so gold, silver and copper can be priced in the unit you trade.
What changed
- unit is one of troy_ounce, gram, kilogram, pound or metric_ton. unit and unit_key in the answer name the unit you asked for (unit_key is tonne for metric_ton). Without unit the answer is exactly as before. The MCP tools commodities_get_spot_price and commodities_get_price_history take the same input.
- Gold, silver, platinum, palladium and copper take all five units. WTI and BRENT are quoted per barrel and take only barrel. Any other value returns 400 unit_not_supported, and its detail lists the allowed units.
- The factors are exact: 1 troy ounce is 31.1034768 g and 1 pound is 453.59237 g. The price is worked out in exact decimals from the price shown without unit. It keeps as many significant figures as that price, a price under 10 keeps at least 4 decimals, halves round up and zeros after the decimal point are dropped. Silver at 41.0018 per troy ounce is 1.31824 per gram.
- Bars convert open, high, low and close the same way. Gold in a currency other than USD still has close only.
Was this page helpful?