Macrotrends API: Get long-term price history
Gets decades of yearly commodity or stock-index price history from Macrotrends: yearly average, open, high, low, close, annual change and inflation-adjusted value for gold, silver, crude oil, natural gas, copper, Dow Jones, S&P 500 and Nasdaq. The current year may be incomplete.
Unofficial. Not affiliated with or endorsed by Macrotrends.
Inputs
Values from the run on Oct 31, 2026, shown under Output.
- Asset, required
asset Commodity or stock index name, for example gold, crude oil, or S&P 500.
gold
- End Year optional
end_year Last calendar year to include, for example 2024. Defaults to the last available year.
2024
Whole number. Default
9999.- Start Year optional
start_year First calendar year to include, for example 2000. Defaults to the first available year.
2000
Whole number. Default
1900.
Input as JSON
{ "asset": "gold", "end_year": 2024, "start_year": 2000}Output
{ "unit": "US dollars per troy ounce", "asset": "Gold", "price_history": [ { "year": 2024, "page_url": "https://www.macrotrends.net/1333/historical-gold-prices-100-year-chart" , "year_low": 2039.1538, "year_high": 2746.7019, "year_open": 2039.1538, "year_close": 2624.603, "annual_change_percent": 27.23, "average_closing_price": 2404.58, "inflation_adjusted_value": 2792.81 }, { "year": 2023, "page_url": "https://www.macrotrends.net/1333/historical-gold-prices-100-year-chart" , "year_low": 1826.7404, "year_high": 2062.9233, "year_open": 1928.1201, "year_close": 2062.9233, "annual_change_percent": 13.08, "average_closing_price": 1953.69, "inflation_adjusted_value": 2258.53 }, { "year": 2022, "page_url": "https://www.macrotrends.net/1333/historical-gold-prices-100-year-chart" , "year_low": 1632.38, "year_high": 1953.04, "year_open": 1796.12, "year_close": 1824.3233, "annual_change_percent": -0.23, "average_closing_price": 1798.96, "inflation_adjusted_value": 2064.26 } ]}Code
curl https://api.fous.com/v1/runs \ -H "Authorization: Bearer $FOUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"method":"macrotrends.net/get_long_term_price_history","input":{"asset":"gold","end_year":2024,"start_year":2000}}' # Save as fous.py, then run: python3 fous.pyimport json, os, timefrom urllib.error import HTTPErrorfrom urllib.request import Request, urlopenAPI = "https://api.fous.com/v1/runs" KEY = os.environ["FOUS_API_KEY"]HEADERS = { "Authorization": f"Bearer {KEY}", "Content-Type": "application/json" ,}def call(url, body=None): data = json.dumps(body).encode() if body else None request = Request(url, data, HEADERS) try: with urlopen(request, timeout=120) as r: return r.status, json.load(r) except HTTPError as error: message = json.load(error)["error"]["message"] raise RuntimeError(message) from errorstatus, run = call(API, { "method": "macrotrends.net/get_long_term_price_history" , "input": { "asset": "gold", "end_year": 2024, "start_year": 2000 }})# 202: still going after 30 s. Ask again until it ends.while status == 202: time.sleep(2) status, run = call(f"{API}/{run['id']}")print(json.dumps(run["data"], indent=2))// Save as fous.mjs, then run: node fous.mjsconst api = "https://api.fous.com/v1/runs" ;const headers = { Authorization: `Bearer ${process.env.FOUS_API_KEY}`, "Content-Type": "application/json" ,};let response = await fetch(api, { method: "POST", headers, body: JSON.stringify({ "method": "macrotrends.net/get_long_term_price_history" , "input": { "asset": "gold", "end_year": 2024, "start_year": 2000 } }), signal: AbortSignal.timeout(120_000),});let run = await response.json();// 202: still going after 30 s. Ask again until it ends.while (response.status === 202) { await new Promise((done) => setTimeout(done, 2_000)); response = await fetch(`${api}/${run.id}`, { headers }); run = await response.json();}if (!response.ok) throw new Error(run.error.message);console.log(run.data);# Connect your agent to Fous once, over MCP (Streamable HTTP):# https://api.fous.com/mcp# Set FOUS_API_KEY first: create a key at https://app.fous.com/keys.# Claude Codeclaude mcp add \ --scope user \ --transport http fous https://api.fous.com/mcp \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Codexcodex mcp add fous \ --url https://api.fous.com/mcp \ --bearer-token-env-var FOUS_API_KEY# Cursor, VS Code, Windsurf, Cline and morenpx -y add-mcp https://api.fous.com/mcp -g -n fous \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Then ask your agent:# "Use Fous to run macrotrends.net/get_long_term_price_history# with {"asset":"gold","end_year":2024,"start_year":2000}"Over HTTP, the answer’s data holds the output. A run still going after 30 seconds answers 202 with its id: ask GET /v1/runs/{id} until it ends.
Schema
Input schema
{ "type": "object", "required": [ "asset" ], "properties": { "asset": { "type": "string", "examples": [ "gold" ], "description": "Commodity or stock index name, for example gold, crude oil, or S&P 500." }, "end_year": { "type": "integer", "default": 9999, "description": "Last calendar year to include, for example 2024. Defaults to the last available year." }, "start_year": { "type": "integer", "default": 1900, "description": "First calendar year to include, for example 2000. Defaults to the first available year." } }}Output schema
{ "type": "object", "required": [ "asset", "unit", "price_history" ], "properties": { "unit": { "type": "string" }, "asset": { "type": "string" }, "price_history": { "type": "array", "items": { "type": "object", "required": [ "year", "average_closing_price", "year_open", "year_high", "year_low", "year_close", "annual_change_percent", "inflation_adjusted_value", "page_url" ], "properties": { "year": { "type": "integer" }, "page_url": { "type": "string" }, "year_low": { "type": [ "number", "null" ] }, "year_high": { "type": [ "number", "null" ] }, "year_open": { "type": [ "number", "null" ] }, "year_close": { "type": [ "number", "null" ] }, "annual_change_percent": { "type": [ "number", "null" ] }, "average_closing_price": { "type": [ "number", "null" ] }, "inflation_adjusted_value": { "type": [ "number", "null" ] } }, "additionalProperties": false } } }, "additionalProperties": false}- Price
- 1 credit per completed run (1¢ with pay as you go); failed runs are free.
- Method
macrotrends.net/get_long_term_price_history- Returns
- asset, unit, yearly average, open, high, low, close, annual change percent, inflation-adjusted value
Use it from your agent
Give your agent this line. It reads SKILL.md, gets a Fous API key and connects the Fous MCP server. Its run then takes the method macrotrends.net/get_long_term_price_history with the inputs above.
Ask your agent
- Show me yearly gold prices from 1970 to 2024 with the open, high, low, close and annual percent change for each year
- I need the inflation-adjusted average price of crude oil for every year since 1980 from macrotrends.net
- What were the Dow Jones annual closing values and year-over-year changes between 1929 and 1950?
- Pull the full yearly price history of silver, including average price and inflation-adjusted value, using Macrotrends data
- Give me copper's annual high and low prices per pound from 2000 through 2023
See more
Returns Yahoo Finance daily, weekly or monthly price history and total adjusted-close return for a stock, fund, index or cryptocurrency.
finance.yahoo.com/get_price_historyGets current commodity prices and price movements from the Trading Economics commodities page, in the page's group order; filter by a commodity name, slug, symbol or group (e.g. copper, energy), or leave blank for all groups including Electricity.
tradingeconomics.com/get_commodity_pricesGets current quoted prices for energy, metals, and agricultural commodities from Investing.com's real-time futures page, optionally for one commodity. Some quotes may be delayed or indicative; units are null when the contract specification is missing.
investing.com/get_commodity_pricesGets the current quoted price and key figures for a stock, fund, index, or cryptocurrency on Google Finance, by name or ticker. Prices may be delayed, and figures Google does not show are null.
google.com/get_quoteGets Kitco spot bid, ask, daily change and range for gold, silver, platinum or palladium. Non-USD prices use Kitco's current exchange rate, so converted daily changes are not adjusted for exchange-rate moves since the prior close.
kitco.com/get_precious_metal_pricesLooks up a stock, fund, index, or cryptocurrency by name or ticker and returns its latest displayed price and key statistics. Unavailable figures are null; quotes may be delayed.
finance.yahoo.com/get_quoteGets a coin's daily prices and price change over the last 7, 30, 90 or 365 days, with UTC dates. Today's price may change.
coingecko.com/get_coin_price_historyGets Binance spot price candles for a coin and quote currency, newest by default or within a UTC date range, up to 1,000 candles.
binance.com/get_price_history