Commodity Prices
Historical and current annual average prices for 16 major commodities β precious metals, energy, and agricultural goods. Prices are annual averages sourced from FRED (Federal Reserve Economic Data).
Overview
Use Cases
- Financial dashboards and portfolio trackers
- Commodity price trend analysis
- Inflation-adjusted cost modelling
- Economic research and education
- Supply chain cost forecasting
Features
16 commodities covered (metals, energy, agricultural)
Annual average prices sourced from FRED (Federal Reserve)
Up to 10 years of historical data per commodity
Year-over-year change percentage included
Data going back to the 1960s for major commodities
API Endpoints
Get Commodity Price
Returns the latest annual average price and up to 10 years of historical data for the requested commodity slug.
GET
https://api.requiems.xyz/v1/finance/commodities/{commodity}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| commodity | string |
Required | Commodity slug (e.g. gold, silver, oil). See supported slugs below. |
Try it out
Live DemoRequest
Commodity slug (e.g. gold, silver, oil). See supported slugs below.
Sending request...
Response Fields
| Field | Type | Description |
|---|---|---|
| commodity | string |
The commodity slug as provided in the request path |
| name | string |
Human-readable commodity name |
| price | number |
Latest annual average price in the commodity's display unit |
| unit | string |
Price unit (oz, barrel, mmbtu, lb, or metric_ton) |
| currency | string |
Currency code β always USD |
| change_24h | number |
Year-over-year percentage change from the prior year's annual average (positive = price increased) |
| historical | array |
Up to 10 prior years of annual average prices, ordered newest to oldest |
| historical[].period | string |
Year of the historical data point |
| historical[].price | number |
Annual average price for that year |
Code Examples
curl "https://api.requiems.xyz/v1/finance/commodities/gold" \
-H "requiems-api-key: YOUR_API_KEY"
import requests
url = "https://api.requiems.xyz/v1/finance/commodities/gold"
headers = {"requiems-api-key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers)
data = response.json()["data"]
print(data["price"]) # 2386.33
print(data["change_24h"]) # 23.01
print(data["historical"][0]["period"]) # "2023"
const response = await fetch(
'https://api.requiems.xyz/v1/finance/commodities/gold',
{ headers: { 'requiems-api-key': 'YOUR_API_KEY' } }
);
const { data } = await response.json();
console.log(data.price); // 2386.33
console.log(data.change_24h); // 23.01
console.log(data.historical.length); // up to 10
require 'net/http'
require 'json'
uri = URI('https://api.requiems.xyz/v1/finance/commodities/gold')
request = Net::HTTP::Get.new(uri)
request['requiems-api-key'] = 'YOUR_API_KEY'
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
data = JSON.parse(response.body)['data']
puts data['price'] # 2386.33
puts data['change_24h'] # 23.01
Error Responses
not_found
No data found for the given commodity slug. Check the supported slugs list.
internal_error
Unexpected server error.
Frequently Asked Questions
gold, silver, platinum, palladium, oil (WTI), brent, natural-gas, copper, aluminum, wheat, corn, soybeans, coffee, sugar, cotton, cocoa.
Despite the field name, change_24h is the year-over-year percentage change between the latest annual average and the prior year's annual average. The API stores annual data, not intraday prices.
Precious metals (gold, silver, platinum, palladium) are priced per troy ounce. Oil and brent are per barrel. Natural gas is per mmBtu. Copper and coffee are per pound (lb). Aluminum, wheat, corn, soybeans, and cocoa are per metric ton. Sugar and cotton are per pound (lb).
Data is sourced from FRED and updated annually. Re-run the seed CLI (cmd/seed-commodities) to pull the latest annual averages when new data is published.
No. Prices are annual averages, not real-time spot prices. For the most recent year, the price reflects the full-year average once the year has closed. Use a dedicated market data provider for live quotes.
The database must be seeded before queries work. Run docker exec requiem-dev-api-1 go run ./cmd/seed-commodities --db-url ... to populate the table.