Unlock Real-timeCommodity Prices  with our Powerful Json API

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

Get a 7 day free trial.

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 70+ 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.

title

IP based Custom Quote Currency

Automatically get your commodity prices to the currency of the your location. 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, 1999.


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 timestamp DATE


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


The code String


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


The message String


API responses contain an message field of type String. It is used to identify the error message.


The error String


API responses contain an error field of type String. It is used to denote the error type.


The path String


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


HTTP Status Codes


The API also returns success and error status via the HTTP status codes below.



CodeStatusDescription
200SuccessSuccessfully processed the request
400Bad RequestSomething is wrong with request and it cannot be processed. This can be invalid JSON or invalid parameters options.
402Usage errorThe API key has reached the maximum allowed requests.
403ForbiddenInvalid API key or the API key doesn't have permissions to perform the request.
404Not FoundThe requested resource doesn't exist.
429Too Many RequestsToo many requests, please try again in a minute
500Internal Server 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



GET /usage




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.




quota integer

Your current quota.




used integer

Your usage since start of month.




Response JSON



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


Symbols Endpoint


Api will return a list of all available symbols.

mdx filename="Endpoint" GET /symbols


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 Endpoint


Api will return the latest rates for the given symbols, depending on the subscription plan latest rates may be delayed by up to 10 minutes.
The default quote currency will also change based on user's subscription as by default the quote currency for the premuim users will be given based on their IP address and the rates will be calculated as such.
The quote currency can be set for the premium and plus users by passing the quote currency in the qurery parameter. Moreover, premium users can also pass the IP address in the query parameter to get the rates based on that IP address.

Endpoint



GET rates/latest




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

ip string OPTIONAL
If not provided by the user then their ip will be used. 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. .




metaData object

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




rates object

object containing the requested rates.







Response JSON



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


HTTP Status Codes



CodeStatusDescription
400Bad RequestInvalid Symbols Found (A symbol in the symbols array is invalid).
400Bad RequestSymbols is required in query params (symbols array is missing).
402Payment RequiredMaximum symbols per request exceeded.

Historical Rates Endpoint


Api will return Historical rates for the specified date.

Endpoint



GET rates/historical




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.





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.





date string

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





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 Status Codes



CodeStatusDescription
400Bad RequestInvalid Symbols Found (A symbol in the symbols array is invalid).
400Bad RequestDate is required in query params.
400Bad RequestInvalid Date Format (YYYY-MM-DD).
400Bad RequestSymbols is required in query params (symbols array is missing).

Timeseries Endpoint


with this endpoint you can get the historical rates for a time period.

EndPoint



GET rates/time-series




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 Status Codes



CodeStatusDescription
400Bad RequestInvalid Symbols Found (A symbol in the symbols array is invalid).
400Bad RequeststartDate is required in query params.
400Bad RequestendDate is required in query params.
400Bad RequestInvalid date format specified for start or end date.
400Bad RequestSymbols is required in query params (symbols array is missing).

Fluctuation Endpoint


with this endpoint you can get the commodity's fluctuation on a day-to-day basis.

EndPoint



GET rates/time-series




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.





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": {
    "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 Status Codes



CodeStatusDescription
400Bad RequestInvalid Symbols Found (A symbol in the symbols array is invalid).
400Bad RequeststartDate is required in query params.
400Bad RequestendDate is required in query params.
400Bad RequestInvalid date format specified for start or end date.
400Bad RequestSymbols is required in query params (symbols array is missing).
PRICING PLANS

Simple Pricing

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

Dotted

Frequently AskedQuestions

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