Unlock Real-timeCommodity Prices  with our Powerful Json API

CommodityPriceAPI is a simple JSON API that provides real-time and historical commodity prices for 110+ commodities including Crude Oil, Gold, Silver, Natural Gas, Wheat, Corn and many more.

Unlimited free trial for integrations. No credit card required.

https://api.commoditypriceapi.com/v2 
API Key:

Enter you API Key to Test the Results.

Core Features

Our API is easy to use and can be integrated into your application in minutes

title

Simple fast and reliable

Access an extensive list of 110+ commodities, from precious metals to energy resources. Our API provides comprehensive coverage, ensuring you have all the information you need in one place.

title

Easy to integrate

Our API is easy to integrate into your application and can be integrated in minutes. We provide comprehensive documentation and support to help you get started.

title

No complex contracts

We offer a simple, flexible pricing structure. You can choose between a monthly or annual subscription, and you can cancel at any time. We also offer a 7-day free trial

title

Trusted Data Sources

Our data is sourced from trusted exchanges and financial institutions.

title

Custom Quote Currency

Get commodity prices to any currency of your choice. Our API supports 175+ currencies.

Get your API key today

CommodityPriceAPI is the easiest way to get real-time and historical prices for a diverse range of commodities. Our API is easy to use and can be integrated into your application in minutes.

Documentation

CommodityPriceAPI


CommodityPriceAPI provides a simple REST API for live and historical rates for 110+ commodities in a simple JSON format. Rates are available historically for all days going back up to 1st January, 1990.


This documentation provides complete details of the features and options available in this API.



Authentication


The CommodityPriceAPI uses API keys to authenticate requests. Each request must contain your API key via an apiKey query parameter or x-api-key in request header.


In order to use the API, you need to sign up. It does not require a credit card. Once you've created your account successfully, you need to get your API key from your dashboard. You can use this dashboard to extend your trial, buy subscription, monitor your API usage and more. We strongly discourage the use of API key in client-side JavaScript, as it will expose your API key to the public.


Get Your API key


You can get your API key from the Dashboard page.


Do not share your API key in publicly accessible areas such as GitHub, client-side code, and so forth.


Send Your API key


The Api Key may be sent in 2 ways


  • Request Parameters - Include an apiKey parameter in your request's query string.
  • Request Header - Include an x-api-key request header with each request.


Track Usage


You can track your API usage in the Dashboard page and also via the Usage endpoint.


Errors And Codes


The CommodityPriceAPI returns error status using both conventional HTTP codes and error messages within the JSON response body. The error body will have the following attributes:

The timestamp DATE


API responses contain an timestamp field of type DATE. It is used to identify the time of the request.


path (String)


API responses contain an path field of type String. It is used to identify the request path.


code (String)


API responses contain a code field of type String. This denotes the status code for the error.


error (String)


API response contain a error field of type string which is a short, standardized error code indicating the type of error. Common values include VALIDATION_ERROR, BAD_REQUEST, UNAUTHORIZED, etc. This is useful for programmatic error handling.


message (String)


API response contain a message field of type string which is a human-readable description providing details about the error. It explains what went wrong and may offer guidance on how to resolve the issue.


HTTP Status Codes


The API returns 200 HTTP status in case of a successful request and error status via the HTTP status codes below. The error object has the attributes as mentioned above. Following table contains the common errors.



CodeErrorMessage
400VALIDATION_ERRORSymbols are required in the query parameters
401API_KEY_NOT_FOUNDAPI key is missing from the request. Please include your API key in the request headers
402PAYMENT_REQUIREDPlease extend your trial or subscribe to a plan to continue using the API
402PAYMENT_REQUIREDUser does not have an active subscription.
402PAYMENT_REQUIREDMaximum symbols per request exceeded
403LIMIT_REACHEDAPI key usage limit reached, Please upgrade your plan.
404USER_NOT_FOUNDThe user with the specified API key was not found (Invalid API key)
404SYMBOL_NOT_FOUNDThe symbol is not supported, please visit the documentation for a list of supported symbols
429TOO_MANY_REQUESTSToo many requests, please try again in a minute
500SERVER_ERRORA server error occurred and the request was not able to be processed.

Supported Symbols


See the Supported Symbols

Quoted Currencies


See the Quoted Currencies

Usage Endpoint


Api will return usage information for your account.

Endpoint

$ curl https://api.commoditypriceapi.com/v2/usage -H "x-api-key: YOUR_API_KEY"


Request Object

Parameters

apiKey is REQUIRED


Your unique API key. Note This may also be passed via x-api-key header.



Response Object


plan string

Your current plan name.




quota integer

Your current alloted quota.




used integer

Your usage since start of month, subscription or trial.




Response JSON

{
  "plan": "lite",
  "quota": 2000,
  "used": 0
}

Symbols Endpoint


This endpoint returns the complete information of all supported commodities by CommodityPriceAPI such as commodity symbol, category, information about their currency code, currency name, currency symbol, measuring unit and their names.

Endpoint

$ curl https://api.commoditypriceapi.com/v2/symbols -H "x-api-key: YOUR_API_KEY"


Request Object

Parameters

apiKey string REQUIRED
Your unique API key. Note This may also be passed via x-api-key header.



Response Object


success boolean

true if the request was successful, false if there was an error.





symbols object

object containing list of available symbols.





Response JSON

{
  "success": true,
  "symbols": [
    {
      "symbol": "WTIOIL",
      "category": "Energy",
      "currency": {
        "code": "USD",
        "name": "US Dollar",
        "symbol": "$"
      },
      "unit": {
        "symbol": "Bbl",
        "name": "Barrel"
      },
      "name": "Crude Oil WTI"
    },
    {
      "symbol": "NG",
      "category": "Energy",
      "currency": {
        "code": "USD",
        "name": "US Dollar",
        "symbol": "$"
      },
      "unit": {
        "symbol": "MMBtu",
        "name": "Million British Thermal Units"
      },
      "name": "Natural Gas"
    },
    {
      "symbol": "XAG",
      "category": "Metals",
      "currency": {
        "code": "USD",
        "name": "US Dollar",
        "symbol": "$"
      },
      "unit": {
        "symbol": "T.oz",
        "name": "Troy Ounce"
      },
      "name": "Silver"
    },
    {
      "symbol": "BRENTOIL",
      "category": "Energy",
      "currency": {
        "code": "USD",
        "name": "US Dollar",
        "symbol": "$"
      },
      "unit": {
        "symbol": "Bbl",
        "name": "Barrel"
      },
      "name": "Crude Oil Brent"
    },
    {
      "symbol": "XAU",
      "category": "Metals",
      "currency": {
        "code": "USD",
        "name": "US Dollar",
        "symbol": "$"
      },
      "unit": {
        "symbol": "T.oz",
        "name": "Troy Ounce"
      },
      "name": "Gold"
    },
    {
      "symbol": "HG",
      "category": "Metals",
      "currency": {
        "code": "USD",
        "name": "US Dollar",
        "symbol": "$"
      },
      "unit": {
        "symbol": "Lb",
        "name": "Pound"
      },
      "name": "Copper"
    }
  ]
}

Latest Rates


The API will return the latest rates for the specified symbols. Depending on your subscription plan, the latest rates may be delayed by up to 10 minutes.
The lite users will receive the rates in the default quote currency of a commodity by default.
Both premium and plus users can customize the quote currency by passing it as a query parameter.

Endpoint

$ curl https://api.commoditypriceapi.com/v2/rates/latest?symbols=xau,wtioil \-H "x-api-key: YOUR_API_KEY"


Request Object

Parameters

apiKey string REQUIRED
Your unique API key. Note This may also be passed via x-api-key header.

symbols string array REQUIRED
list of comma separated commodity symbols.

quote string OPTIONAL
"Default" for default quote currency otherwise a string symbol for the supported quote currencies. View the supported Quote currencies



Response Object


success boolean

true if the request was successful, false if there was an error.




timestamp number

timestamp of the response in seconds since UNIX epoch.




rates object

object containing the requested rates.




metaData object

Contains the metaData for the symbols, such as their unit and quote currency.






Response JSON

{
  "success": true,
  "timestamp": 1703866777,
  "rates": {
    "WTIOIL": 72.29,
    "XAU": 2066.98
  },
  "metaData": {
    "XAU": {
      "unit": "T.oz",
      "quote": "USD"
    },
    "WTIOIL": {
      "unit": "Bbl",
      "quote": "USD"
    }
  }
}

HTTP Error Codes



CodeErrorMessage
404QUOTE_NOT_FOUNDThe quote currency is invalid, please visit the documentation for a list of valid quote currencies


Historical Rates


Historical rates are available for most of the commodities since 1990-01-01. You can query the CommodityPriceAPI for historical rates by passing a date (format YYYY-MM-DD) as a URL Parameter.

Endpoint

$ curl https://api.commoditypriceapi.com/v2/rates/historical?symbols=xau,wtioil&date=2019-01-04 \ -H "x-api-key: YOUR_API_KEY"


Request Object

Parameters

apiKey string REQUIRED
Your unique API key. Note This may also be passed via x-api-key header.

symbols string array REQUIRED
list of comma separated commodity symbols.

date string REQUIRED
date for which the rates are requested. Format: YYYY-MM-DD



Response Object


success boolean

true if the request was successful, false if there was an error.





date string

date for which the rates are requested. Format: YYYY-MM-DD





rates object

object containing the requested rates.





Response JSON

{
  "success": true,
  "date": "2019-01-04",
  "rates": {
    "XAU": {
      "open": 1295.17,
      "high": 1298.49,
      "low": 1276.6,
      "close": 1284.81
    },
    "WTIOIL": {
      "open": 46.9,
      "high": 49.22,
      "low": 46.65,
      "close": 47.96
    }
  }
}

HTTP Error Codes



CodeErrorMessage
400VALIDATION_ERRORDate is required in query params.
400VALIDATION_ERRORInvalid Date Format (YYYY-MM-DD).
400VALIDATION_ERRORInvalid Date: The provided date does not exist.
404RATE_NOT_FOUNDno rate found for the specified date


Timeseries


Time series endpoint lets you query the API for daily historical rates between two dates of your choice. The difference between the start and end date should not exceed 30 days
You can see an example response of the time series endpoint in the code snippet below.


Endpoint

$ curl https://api.commoditypriceapi.com/v2/rates/time-series?symbols=xau,wtioil&startDate=2023-12-08&endDate=2023-12-13 \ -H "x-api-key: YOUR_API_KEY"


Request Object

Parameters

apiKey string REQUIRED
Your unique API key. Note This may also be passed via x-api-key header.

symbols string array REQUIRED
list of comma separated commodity symbols.

startDate string REQUIRED
start date for the fluctuation. Format: YYYY-MM-DD

endDate string REQUIRED
end date for the fluctuation. Format: YYYY-MM-DD


The maximum difference between the start and end date is 30 days.


Response Object


success boolean

true if the request was successful, false if there was an error.





message string OPTIONAL

error message if the request was unsuccessful.





statusCode string OPTIONAL

HTTP status code of the response, if the request was unsuccessful.





rates object

object containing the requested rates.





startDate string

start date for the fluctuation. Format: YYYY-MM-DD





endDate string

end date for the fluctuation. Format: YYYY-MM-DD





Response JSON

{
  "success": true,
  "startDate": "2023-12-08",
  "endDate": "2023-12-13",
  "rates": {
    "2023-12-08": {
      "XAU": {
        "open": 2027.93,
        "high": 2033.89,
        "low": 1994.49,
        "close": 2004.35
      },
      "WTIOIL": {
        "open": 69.34,
        "high": 71.63,
        "low": 69.5,
        "close": 71.23
      }
    },
    "2023-12-10": {
      "XAU": {
        "open": 2005.5,
        "high": 2007.44,
        "low": 2004.43,
        "close": 2006.93
      },
      "WTIOIL": {
        "open": 71.25,
        "high": 71.66,
        "low": 70.92,
        "close": 71.47
      }
    },
    "2023-12-11": {
      "XAU": {
        "open": 2006.92,
        "high": 2007.62,
        "low": 1975.76,
        "close": 1982.79
      },
      "WTIOIL": {
        "open": 71.4,
        "high": 71.92,
        "low": 71.36,
        "close": 71.92
      }
    },
    "2023-12-12": {
      "XAU": {
        "open": 1982.79,
        "high": 1996.48,
        "low": 1977.09,
        "close": 1982.44
      },
      "WTIOIL": {
        "open": 68.72,
        "high": 68.88,
        "low": 68.26,
        "close": 68.43
      }
    },
    "2023-12-13": {
      "XAU": {
        "open": 1982.44,
        "high": 2033.06,
        "low": 1972.91,
        "close": 2032.68
      },
      "WTIOIL": {
        "open": 69.91,
        "high": 70.17,
        "low": 69.67,
        "close": 69.83
      }
    }
  }
}

HTTP Error Codes



CodeErrorMessage
400VALIDATION_ERRORstartDate is required in query params
400VALIDATION_ERRORendDate is required in query params
400VALIDATION_ERRORinvalid date format specified for start or end date
400VALIDATION_ERRORstart date cannot be after end date
400VALIDATION_ERRORDifference between start and end date cannot be greater than 30 days
400VALIDATION_ERRORInvalid Date: The provided date does not exist.
404DATA_NOT_FOUNDNo data found for the specified date range


Fluctuation


Fluctuation endpoint provides information about how rates of different commodities fluctuate on a day-to-day basis. To use this feature, provide a “startDate” and “endDate” as the query parameter and choose which commodity (symbol) you would like to query.

Endpoint

$ curl https://api.commoditypriceapi.com/v2/rates/fluctuation?symbols=xau,wtioil&startDate=2023-12-08&endDate=2023-12-13 \ -H "x-api-key: YOUR_API_KEY"


Request Object

Parameters

apiKey string REQUIRED
Your unique API key. Note This may also be passed via x-api-key header.

symbols string array REQUIRED
list of comma separated commodity symbols.

startDate string REQUIRED
start date for the fluctuation. Format: YYYY-MM-DD

endDate string REQUIRED
end date for the fluctuation. Format: YYYY-MM-DD




Response Object


success boolean

true if the request was successful, false if there was an error.





startDate string

start date for the fluctuation. Format: YYYY-MM-DD





endDate string

end date for the fluctuation. Format: YYYY-MM-DD





rates object

object containing the requested rates.





Response JSON

{
  "success": true,
  "startDate": "2023-12-08",
  "endDate": "2023-12-13",
  "rates": {
    "WTIOIL": {
      "startRate": 71.23,
      "endRate": 69.83,
      "change": -1.4,
      "changePercent": -1.97
    },
    "XAU": {
      "startRate": 2004.35,
      "endRate": 2032.68,
      "change": 28.33,
      "changePercent": 1.41
    }
  }
}

HTTP Error Codes



CodeErrorMessage
400VALIDATION_ERRORstartDate is required in query params.
400VALIDATION_ERRORendDate is required in query params.
400VALIDATION_ERRORinvalid date format specified for start or end date.
400VALIDATION_ERRORstart date cannot be after end date
400VALIDATION_ERRORInvalid Date: The provided date does not exist.
404DATA_NOT_FOUNDNo data found for the specified date range
PRICING PLANS

Simple Pricing

Choose your plan and get started. Upgrade, downgrade or cancel anytime

Dotted

Frequently AskedQuestions

We have over 110+ commodities available on our platform. Please take a look at the full list of available in our documentation.