NewConnect Claude, Cursor, 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 have access to live prices, while free users only have access to 15-minute delayed data.

(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
258ms272ms334ms485ms918ms

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


/v1/commodityprice GET

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 have access to live prices, while free users only have access to 15-minute delayed data.

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

Parameters

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON object with the following fields, or an array of such objects when names is used, or an error if the request is unsuccessful.

  • exchange

    The symbol of the exchange where the commodity is traded.

  • name

    The name of the commodity.

  • 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 / low_24h

    Day's high and low prices.

  • high_52w / low_52w  Developer tier and above

    52-week high and low prices.

  • updated

    The Unix timestamp of the price update.

Sample Request Live Demo!

name

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/commodityprice?name=platinum

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
{
    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
}

Code Examples

1 2 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.


/v1/commoditypricehistorical GET 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.

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

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.

Sample Request Live Demo!

name
period
start
end

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/commoditypricehistorical?name=gold&period=1h

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      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
    }
]

/v1/commoditysnapshot GET

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

Returns current price data for every supported commodity in a single response. Useful for dashboards, watchlists, and any UI that needs the full set of commodities. Premium members have access to live prices, while free users only have access to 15-minute delayed data.

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

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 / unit

    Quote convention. See /v1/commodityprice for details on USD vs USX and 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.

Sample Request Live Demo!

category
exchange

Try this API endpoint with all available parameters in our API playground

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

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      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

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

/v1/commoditycontract GET Business, Professional, or annual subscriptions only

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

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

Either symbol or symbol_root must be provided, 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

A JSON object with the following fields or an error if the request is unsuccessful.

  • 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.

Sample Request Live Demo!

symbol
symbol_root

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/commoditycontract?symbol=GCK26

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      symbol:"GCK26",
      last_price:4890.9,
      last_updated:1769036008
    }
]

Code Examples

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

/v1/commoditycontractlist GET Business, Professional, or annual subscriptions only

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

A JSON object 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").

Sample Request Live Demo!

Try this API endpoint with all available parameters in our API playground

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

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      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

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

/v1/commodityforwardcurve GET Business, Professional, or annual subscriptions only

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

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 / contango_slope_12m_pct

    Percent difference between the front-month price and the next month (1m) and approximately one-year-out (12m) contract prices. 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.

Sample Request Live Demo!

name

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/commodityforwardcurve?name=crude_oil

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
{
    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

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