NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server →

Commodity Price API

The Commodity Price API provides access to commodity prices for dozens of commonly-traded commodities.

Available endpoints:

Premium members get live prices; free users get the last completed daily settlement for every commodity.

Online
(4.3)

From 9,027 users

4,300+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
224ms250ms293ms578ms1165ms

Didn't find what you were looking for? Suggest an improvement

7 endpoints

https://api.api-ninjas.com/v1/commodityprice

Returns the current price information for one or more commodities. Prices are based on rolling futures contracts and are quoted in the commodity's native unit and currency convention — see the unit and currency_unit fields below. Use the optional currency and unit parameters to convert into any supported currency or compatible mass/volume/energy unit. Premium members get live prices; free users get the last completed daily settlement for every commodity.

For all 30 commodities in one call, see /v1/commoditysnapshot. For historical prices, see /v1/commoditypricehistorical.

Parameters

Provide name or names, but not both.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

When name is used, the /v1/commodityprice endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful. When names (batch) is used, the response is a JSON array with one element per requested commodity, each identified by its name and value. Batch elements carry a reduced set of fields — name, value, exchange, unit, currency_unit, price, change_24h, and updated, plus futures_contract and futures_contract_month. The additional stats (previous_close, change_24h_percent, high_24h/low_24h, and high_52w/low_52w) are only returned by the single-commodity name form.

  • exchange

    The symbol of the exchange where the commodity is traded.

  • name

    The display name of the commodity (e.g. Gold Futures). Returned for both single and names batch requests.

  • price

    The current price of the commodity. See currency_unit and unit below for the quote convention.

  • currency_unit

    USD for US dollars per unit; USX for US cents per unit (corn, wheat, soybean, etc.). When currency is provided in the request, this reflects the requested currency code instead.

  • unit

    The quote unit (e.g., troy_ounce, barrel, bushel, lb, MMBtu, gallon, metric_ton, short_ton, hundredweight, board_feet). When unit is provided in the request, this reflects the requested unit.

  • previous_close

    Previous session's closing price in the same quote convention as price.

  • change_24h

    Absolute price change vs previous_close.

  • change_24h_percent

    Percent change vs previous_close.

  • high_24h

    Day's high price.

  • low_24h

    Day's low price.

  • high_52w

    52-week high price.

  • low_52w

    52-week low price.

  • updated

    The Unix timestamp of the price update.

  • futures_contract

    The futures contract price is quoted for (e.g. GCZ26).

  • futures_contract_month

    That contract's delivery month (YYYY-MM).

Live Demo

Live demo · no API key required
Query parameters
name

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/commodityprice?name=platinum
Sample response
{
"exchange": "NYMEX",
"name": "Platinum",
"currency_unit": "USD",
"unit": "troy_ounce",
"price": 995.05,
"previous_close": 988.3,
"change_24h": 6.75,
"change_24h_percent": 0.683,
"high_24h": 998.4,
"low_24h": 985.1,
"high_52w": 1118,
"low_52w": 832.4,
"updated": 1728677095,
"futures_contract": "PLF25",
"futures_contract_month": "2025-01"
}

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/commodityprice?name=gold" \ -H "X-Api-Key: YOUR_API_KEY"

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

Premium only

https://api.api-ninjas.com/v1/commodityspot

Returns the spot price, the price for immediate delivery, for commodities with a spot market:

  • Precious metals (gold, silver, platinum, palladium): the live spot price, with bid and ask.
  • Oil and energy (WTI, Brent, natural gas, gasoline, heating oil): the daily spot price at each benchmark's physical delivery hub.

Update frequency: precious metals refresh every minute on Developer plans and about every 10 seconds on Business plans and above. Oil and energy spot prices are published with a delay, so they trail by several days (see date).

Other commodities have no public spot market: use /v1/commodityprice for their futures price. For metals, see also the Metals Price API.

Parameters

  • name  required

    The commodity: gold, silver, platinum, palladium, crude_oil (or wti), brent_crude_oil (or brent), natural_gas, gasoline_rbob (or gasoline), or heating_oil (or diesel).

  • names  optional Business tier and above

    Comma-separated list of commodities for a batch request (e.g. gold,silver,natural_gas). Returns an array.

  • currency  optional

    ISO 4217 currency code to convert prices into (e.g. EUR, GBP). Defaults to USD.

  • unit  optional

    Target unit, in the same dimension as the commodity's native unit (mass for metals, volume for oil, gasoline, and heating oil, energy for natural gas). See /v1/commodityprice for the supported units.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/commodityspot endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful.

  • name

    The commodity's display name.

  • value

    The commodity's name parameter value.

  • price

    The spot price: the price for immediate delivery.

  • bid

    The spot bid price (composite spot only).

  • ask

    The spot ask price (composite spot only).

  • spot_type

    How the spot price is produced: composite (gold, silver, platinum, and palladium: a live spot price, with bid and ask) or assessed (oil and energy: the daily spot price at the benchmark's physical delivery hub).

  • date

    assessed spot only: the trading day the price is for (YYYY-MM-DD). Daily spot prices are published with a delay, so it trails by several days.

  • benchmark

    assessed spot only: the physical spot benchmark (e.g. WTI Cushing, Oklahoma).

  • previous_close

    The previous session's closing spot price.

  • change_24h

    The change versus the previous close.

  • change_24h_percent

    The percent change versus the previous close.

  • high_24h

    composite spot only: the session's high price.

  • low_24h

    composite spot only: the session's low price.

  • market_status

    composite spot only: open or closed. Metals trade from Sunday 6 PM to Friday 5 PM ET, with a daily break from 5 to 6 PM ET.

  • updated

    The Unix timestamp (in seconds) of the spot price.

  • unit

    The quote unit (changes when the unit parameter is used).

  • currency_unit

    The price currency (USD by default).

Live Demo

Live demo
Query parameters
name

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/commodityspot?name=gold
Sample response
{
"name": "Gold",
"value": "gold",
"price": 4140.25,
"bid": 4140,
"ask": 4140.5,
"spot_type": "composite",
"previous_close": 4118.23,
"change_24h": 22.02,
"change_24h_percent": 0.5347,
"high_24h": 4146.8,
"low_24h": 4121.15,
"market_status": "open",
"updated": 1791263228,
"unit": "troy_ounce",
"currency_unit": "USD"
}

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/commodityspot?name=gold" \ -H "X-Api-Key: YOUR_API_KEY"

Premium only

https://api.api-ninjas.com/v1/commoditypricehistorical

Returns historical commodity futures price data in OHLCV (Open, High, Low, Close, Volume) format. The data is returned in descending order (most recent first), and all prices are in USD. Each API call returns a maximum of 1,000 data points; narrow the time range or use a larger interval for queries that would otherwise exceed this limit.

Parameters

  • name  required

    Name of commodity. Use the same values as the name parameter in /v1/commodityprice.

  • period  optional

    Time interval between data points. Valid values are: 1m, 5m, 15m, 30m, 1h, 4h, 1d. Default is 1h.

  • start  optional

    Start timestamp in Unix format. If not provided, defaults to 24 hours ago.

  • end  optional

    End timestamp in Unix format. If not provided, defaults to current time.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/commoditypricehistorical endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful.

  • open

    The opening price of the commodity in USD.

  • low

    The lowest price of the commodity in USD.

  • high

    The highest price of the commodity in USD.

  • close

    The closing price of the commodity in USD.

  • volume

    The volume of the commodity.

  • time

    The Unix timestamp of the price update.

Live Demo

Live demo
Query parameters
name
period
start
end

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/commoditypricehistorical?name=gold&period=1h
Sample response
[
{
"open": 2757.2,
"low": 2745.4,
"high": 2758,
"close": 2751.2,
"volume": 29068,
"time": 1729674000
},
{
"open": 2763.9,
"low": 2754.5,
"high": 2764.5,
"close": 2757.3,
"volume": 16722,
"time": 1729670400
}
]

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/commoditypricehistorical?name=gold&period=1h" \ -H "X-Api-Key: YOUR_API_KEY"

https://api.api-ninjas.com/v1/commoditysnapshot

Returns price data for all 30 supported commodities in a single response, on every plan including the free tier. Useful for dashboards, watchlists, and any UI that needs the full set of commodities. Premium members get live prices; free users get the last completed daily settlement for every commodity.

Parameters

  • category  optional

    Filter to a single product category. One of precious_metals, base_metals, energy, grains, softs, livestock.

  • exchange  optional

    Filter to commodities listed on a single exchange. One of CME, NYMEX, COMEX, ICE.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/commoditysnapshot endpoint returns a JSON array of objects with the following fields, or an error if the request is unsuccessful.

  • exchange

    Listing exchange (e.g., CME).

  • name

    Display name of the commodity.

  • value

    The API ?name= slug (e.g., gold, crude_oil).

  • category

    One of precious_metals, base_metals, energy, grains, softs, livestock.

  • currency_unit

    Currency unit of the quote. See /v1/commodityprice for details on USD vs USX.

  • unit

    Unit the price is quoted in. See /v1/commodityprice for the supported units.

  • price

    Current price in the commodity's native unit and currency convention.

  • change_24h

    Absolute price change vs the previous close.

  • volume

    Trading volume for the session.

  • updated

    Unix timestamp when the snapshot was fetched.

Live Demo

Live demo · no API key required
Query parameters
category
exchange

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/commoditysnapshot
Sample response
[
{
"exchange": "CME",
"name": "Gold Futures",
"value": "gold",
"category": "precious_metals",
"currency_unit": "USD",
"unit": "troy_ounce",
"price": 2985.4,
"change_24h": 6.75,
"volume": 158420,
"updated": 1741046400
},
{
"exchange": "CME",
"name": "Silver Futures",
"value": "silver",
"category": "precious_metals",
"currency_unit": "USD",
"unit": "troy_ounce",
"price": 33.21,
"change_24h": 0.16,
"volume": 73210,
"updated": 1741046400
},
{
"exchange": "CME",
"name": "Crude Oil",
"value": "crude_oil",
"category": "energy",
"currency_unit": "USD",
"unit": "barrel",
"price": 67.82,
"change_24h": 0.37,
"volume": 412905,
"updated": 1741046400
}
]

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/commoditysnapshot" \ -H "X-Api-Key: YOUR_API_KEY"

Business tier and above, or any annual plan

https://api.api-ninjas.com/v1/commoditycontract

Returns price information for a specific commodity contract or all contracts matching a commodity root.

Provide symbol or symbol_root, but not both.

Parameters

  • symbol  optional

    Specific contract symbol to look up (e.g., GCK26).

  • symbol_root  optional

    Commodity root to filter contracts (e.g., GC returns all contracts starting with GC like GCK26, GCM26, etc.).

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/commoditycontract endpoint returns a JSON array of objects with the following fields, or an error if the request is unsuccessful. A single-contract symbol lookup returns an array with one element; a symbol_root lookup returns one element per matching contract.

  • symbol

    The full contract symbol.

  • last_price

    The last price of the commodity contract.

  • last_updated

    The Unix timestamp of when the price was last updated.

Live Demo

Live demo
Query parameters
symbol
symbol_root

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/commoditycontract?symbol=GCK26
Sample response
[
{
"symbol": "GCK26",
"last_price": 4890.9,
"last_updated": 1769036008
}
]

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/commoditycontract?symbol=GCK26" \ -H "X-Api-Key: YOUR_API_KEY"

Business tier and above, or any annual plan

https://api.api-ninjas.com/v1/commoditycontractlist

Returns a list of all available commodity contracts with their symbols and commodity names. This endpoint is useful for discovering which contracts are available for querying.

Parameters

None

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/commoditycontractlist endpoint returns a JSON array of objects with the following fields, or an error if the request is unsuccessful.

  • symbol

    The full contract symbol (e.g., "GCK26").

  • commodity

    The name of the commodity (e.g., "Gold", "Soybean Oil").

Live Demo

Live demo

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/commoditycontractlist
Sample response
[
{
"symbol": "ALF26",
"commodity": "Aluminum"
},
{
"symbol": "ALF27",
"commodity": "Aluminum"
},
{
"symbol": "ALG26",
"commodity": "Aluminum"
},
{
"symbol": "ALH26",
"commodity": "Aluminum"
},
{
"symbol": "BZF26",
"commodity": "Brent Crude Oil"
},
{
"symbol": "BZG26",
"commodity": "Brent Crude Oil"
},
{
"symbol": "CCH26",
"commodity": "Cocoa"
},
{
"symbol": "CCK26",
"commodity": "Cocoa"
}
]

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/commoditycontractlist" \ -H "X-Api-Key: YOUR_API_KEY"

Business tier and above, or any annual plan

https://api.api-ninjas.com/v1/commodityforwardcurve

Returns every active futures contract for the requested commodity, sorted by contract month, along with a curve-shape classification and 1-month and ~12-month percent slopes. This is the standard view for analyzing contango (upward-sloping curve) vs backwardation (downward-sloping). Reads from the same contracts feed as /v1/commoditycontract; for a single contract or unfiltered contract list, use that endpoint or /v1/commoditycontractlist.

Parameters

  • name  required

    Commodity value, using the same set as the /v1/commodityprice name parameter (e.g., crude_oil, gold, corn).

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

The /v1/commodityforwardcurve endpoint returns a JSON object with the following fields, or an error if the request is unsuccessful.

  • name

    Display name of the commodity.

  • value

    API ?name= slug for the commodity.

  • symbol_root

    Contract symbol root (e.g., CL for crude oil).

  • as_of

    Unix timestamp of the most recent contract update across the curve.

  • structure

    Curve-shape classification: contango (strictly upward), backwardation (strictly downward), mixed (both directions across the curve), or flat.

  • contango_slope_1m_pct

    Percent difference between the front-month price and the next month's contract price. Positive = contango; negative = backwardation.

  • contango_slope_12m_pct

    Percent difference between the front-month price and the contract approximately one year out. Positive = contango; negative = backwardation.

  • curve

    Array of contracts sorted by contract_month ascending. Each entry has contract_symbol, contract_month (YYYY-MM), month_offset (months between today and the contract month, 0 = current month), last_price, and last_updated.

Live Demo

Live demo
Query parameters
name

Get a free API key to get started — no credit card required.

Headers
X-Api-KeyLog in or sign up to get your API key
GET
https://api.api-ninjas.com/v1/commodityforwardcurve?name=crude_oil
Sample response
{
"name": "Crude Oil",
"value": "crude_oil",
"symbol_root": "CL",
"as_of": 1769040000,
"structure": "contango",
"contango_slope_1m_pct": 0.87,
"contango_slope_12m_pct": 4.62,
"curve": [
{
"contract_symbol": "CLM26",
"contract_month": "2026-06",
"month_offset": 0,
"last_price": 78.42,
"last_updated": 1769040000
},
{
"contract_symbol": "CLN26",
"contract_month": "2026-07",
"month_offset": 1,
"last_price": 79.1,
"last_updated": 1769040000
},
{
"contract_symbol": "CLQ26",
"contract_month": "2026-08",
"month_offset": 2,
"last_price": 79.7,
"last_updated": 1769040000
}
]
}

Code Examples

curl -X GET "https://api.api-ninjas.com/v1/commodityforwardcurve?name=crude_oil" \ -H "X-Api-Key: YOUR_API_KEY"

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the Commodity Price API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.
  • It provides real-time prices for dozens of commonly-traded commodities across categories like precious_metals, base_metals, energy, grains, softs, and livestock on exchanges including CME, NYMEX, COMEX, and ICE. Available endpoints include /v1/commodityprice for one or more commodities, /v1/commodityspot for spot prices, /v1/commoditysnapshot for every commodity at once, /v1/commoditypricehistorical for OHLCV history, plus /v1/commoditycontract, /v1/commoditycontractlist, and /v1/commodityforwardcurve; see the full list of finance APIs on our APIs page.
  • Call /v1/commodityprice with the name parameter (e.g., gold or platinum), or, on Business tier and above, pass a comma-separated names list of up to 30 commodities for a batch request. You can add the optional currency parameter (an ISO 4217 code like EUR or GBP) and the unit parameter (such as kg, barrel, or MMBtu) to convert the price; for a comparable single-commodity service see the Gold Price API.
  • Each result returns the exchange, name, price (the futures price), and the quote convention via currency_unit (USD or USX cents) and unit, along with previous_close, change_24h, change_24h_percent, high_24h/low_24h, high_52w/low_52w, and an updated Unix timestamp. It also returns the futures_contract the price is quoted for (e.g. GCZ26) and its futures_contract_month. Every commodity and every field is available on all plans, including the free tier; the plan determines recency, with free responses carrying the last completed daily settlement and premium plans returning the live price. Compare plans on the pricing page.
  • The spot price is what a commodity costs for immediate delivery; the futures price, returned by /v1/commodityprice, is agreed today for delivery in a later month. Spot prices come from /v1/commodityspot, available on premium plans: gold, silver, platinum, and palladium return a live spot price (spot_type composite, with bid and ask), and WTI, Brent, natural gas, gasoline, and heating oil return the daily spot price at each benchmark's physical delivery hub (spot_type assessed, dated by date). Other commodities have no public spot market, so their futures price is the reference price. For spot-first metal prices, see the Metals Price API.
  • Use the /v1/commodityforwardcurve endpoint with the name parameter (e.g., crude_oil) to get every active futures contract sorted by month plus a structure classification of contango, backwardation, mixed, or flat, along with contango_slope_1m_pct and contango_slope_12m_pct slopes and a full curve array. This endpoint requires a Business, Professional, or annual subscription, which you can sign up for here.