sifting/io
Commodities
4 min readSiftingIO Team

How to Get Gold and Oil Spot Prices via API

Gold and oil spot prices from one API call. How SiftingIO symbols commodities (XAUUSD, WTIUSD), how to read a last trade or quote, and how the published price is aggregated across venues.

How to Get Gold and Oil Spot Prices via API

The short answer#

A commodity spot price is the current price to buy or sell the underlying right now: gold per ounce, crude oil per barrel, and so on. SiftingIO exposes it through the same live snapshot endpoint used for every other asset class. One authenticated request returns the latest price for a symbol like XAUUSD or WTIUSD, in the same normalized JSON shape as equities, forex, and crypto. There is no separate commodities vendor to integrate and no per-source schema to normalize. This post covers how commodities are symboled, how to read a spot price and a quote, and how the published number is formed across venues.

How commodities are symboled#

Use the commodity symbol catalog for the exact identifier. These examples are quoted in USD, but not every symbol ends in USD:

  • XAUUSD, gold
  • XAGUSD, silver
  • WTIUSD, crude oil
  • NATGAS, natural gas
  • CORNUSD, corn

The catalog spans precious metals, industrial metals, energy benchmarks, and agricultural products. The symbol is all you pass to the price endpoints. There is no contract month or venue code to manage.

Reading a spot price#

A spot price is one request to the live snapshot endpoint. The venue segment is commodities and the last path segment is the symbol:

curl -H "X-API-Key: $SIFTING_KEY" \
     "https://api.sifting.io/v1/last/trade/commodities/XAUUSD"

The response carries the last trade price, its size, and a timestamp. For the two-sided market rather than the last print, request a quote instead:

curl -H "X-API-Key: $SIFTING_KEY" \
     "https://api.sifting.io/v1/last/quote/commodities/WTIUSD"

That returns bid and ask prices with their sizes and a timestamp. Calculate the spread in your client as a - b; it is not a separate response field. Both endpoints return the same fields used for the other asset classes, so code written for one reads the others with only the symbol changed.

One price from many venues#

A commodity does not have a single canonical price. The same ounce of gold or barrel of crude is quoted across multiple independent venues at slightly different numbers, and any one of them can lag, widen, or print an outlier. A snapshot that passes one source straight through inherits whatever that source reports at that instant.

SiftingIO publishes one fair price per symbol, formed across venues rather than taken from a single feed. The value is a robust median weighted by real traded volume and by each venue's reputation, not a simple average. A median has a 50% breakdown point, so a majority of venues have to move the same wrong way before the published number follows, which bounds the effect of one stale or mispriced source. The public response includes the timestamp t. It does not expose separate source, ingest, and publish timestamps or a quality flag, so your client should assess freshness from the returned timestamp. The output is a reference price, not an exchange-of-record print, and it is useful precisely because it does not depend on any one venue being right.

When a market is closed#

Commodities trade in sessions, and outside them the last print stops moving. Check the returned t against the current time and your application's freshness requirements. A successful response alone does not establish that the latest price is fresh. To gate a request on session state before making it, the market status endpoints under /v1/fnd/markets report which markets are currently open.

Historical bars#

For charts and backtests rather than a single value, OHLCV bars are available over the historical endpoints at intervals from one minute up. Heavy history responses require gzip, requested with Accept-Encoding: gzip; without it the endpoint returns 406. The documentation lists the exact commodity bar path and the interval parameters.

Summary#

A commodity spot price from SiftingIO is one request to the live snapshot endpoint with the venue set to commodities and a USD-pair symbol such as XAUUSD or WTIUSD, returning a last trade or a two-sided quote in the same JSON shape as every other asset class. The published reference price uses the aggregation approach described above. Your client should still check the timestamp and handle periods without fresh observations. The documentation lists the full commodity symbol set, the snapshot and history endpoints, and the market hours calls. The free plan needs no credit card, so you can create a free account and read a live gold or oil price in a few minutes.

Keep reading

Related posts