# Macrotrends API

> Macrotrends returns company metric histories and long-term commodity and stock index prices as a workflow and API.

Macrotrends returns annual or quarterly company metrics and year-over-year changes; provide a metric and company, and optionally a period. Get long term price history returns yearly commodity or stock index prices; provide an asset and optionally start and end years.

- Page: https://fous.com/workflows/macrotrends
- Handle: `@macrotrends`
- Category: [Finance](https://fous.com/workflows/category/finance)
- Source website: https://macrotrends.net
- Last verified: Sep 29, 2026
- Fous is not affiliated with Macrotrends.

## Methods

### Get company metric history

Operation `get_company_metric_history`, version 1. 1 credit per call.

Get annual or quarterly company metric history, newest first, with full values and year-over-year change. Dividend values are trailing twelve-month payouts per share; quarterly employee counts and histories before a company began reporting or paying dividends may be unavailable.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `metric` | string | yes | `"net_income"` | Metric to retrieve, for example revenue. |
| `period` | string | no | `"quarterly"` | Annual or quarterly history, for example annual. |
| `company` | string | yes | `"MSFT"` | Company name or ticker, for example Apple or AAPL. |

**Input schema**

```json
{
  "type": "object",
  "required": [
    "company",
    "metric"
  ],
  "properties": {
    "metric": {
      "enum": [
        "revenue",
        "net_income",
        "earnings_per_share",
        "shares_outstanding",
        "employees",
        "price_to_earnings_ratio",
        "dividend"
      ],
      "type": "string",
      "description": "Metric to retrieve, for example revenue.",
      "examples": [
        "net_income",
        "earnings_per_share",
        "shares_outstanding"
      ]
    },
    "period": {
      "enum": [
        "annual",
        "quarterly"
      ],
      "type": "string",
      "default": "annual",
      "description": "Annual or quarterly history, for example annual.",
      "examples": [
        "quarterly",
        "annual"
      ]
    },
    "company": {
      "type": "string",
      "description": "Company name or ticker, for example Apple or AAPL.",
      "examples": [
        "MSFT",
        "Apple"
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "metric": "net_income",
      "period": "quarterly",
      "company": "MSFT"
    },
    {
      "metric": "earnings_per_share",
      "period": "annual",
      "company": "Apple"
    },
    {
      "metric": "shares_outstanding",
      "period": "annual",
      "company": "Apple"
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `rows` | array |  |  |
| `rows[].value` | number | `7.46` | Full numeric value in the stated unit. |
| `rows[].page_url` | string | `"https://www.macrotrends.net/stocks/charts/AAPL/apple/eps-earnings-per-share-diluted"` | Company metric history page. |
| `rows[].fiscal_year` | integer or null | `2025` | Fiscal year for annual values; null for quarterly values. |
| `rows[].quarter_end_date` | string or null |  | Quarter ending date (YYYY-MM-DD); null for annual values. |
| `rows[].change_vs_prior_year_percent` | number or null | `22.7` | Percentage change from the previous year or the same quarter a year before, when available. |
| `unit` | string | `"US dollars per share"` |  |
| `metric` | string | `"Earnings Per Share"` |  |
| `ticker` | string | `"AAPL"` |  |
| `company` | string | `"Apple"` |  |

**Example input**

```json
{
  "metric": "earnings_per_share",
  "period": "annual",
  "company": "Apple"
}
```

**Example output**

```json
{
  "rows": [
    {
      "value": 7.46,
      "page_url": "https://www.macrotrends.net/stocks/charts/AAPL/apple/eps-earnings-per-share-diluted",
      "fiscal_year": 2025,
      "quarter_end_date": null,
      "change_vs_prior_year_percent": 22.7
    },
    {
      "value": 6.08,
      "page_url": "https://www.macrotrends.net/stocks/charts/AAPL/apple/eps-earnings-per-share-diluted",
      "fiscal_year": 2024,
      "quarter_end_date": null,
      "change_vs_prior_year_percent": -0.82
    },
    {
      "value": 6.13,
      "page_url": "https://www.macrotrends.net/stocks/charts/AAPL/apple/eps-earnings-per-share-diluted",
      "fiscal_year": 2023,
      "quarter_end_date": null,
      "change_vs_prior_year_percent": 0.33
    }
  ],
  "unit": "US dollars per share",
  "metric": "Earnings Per Share",
  "ticker": "AAPL",
  "company": "Apple"
}
```

### Get long term price history

Operation `get_long_term_price_history`, version 1. 1 credit per call.

Get decades of yearly commodity or stock-index price history from Macrotrends. Yearly open, high, low and close use daily closing prices for Dow Jones, S&P 500, Nasdaq and copper; gold, silver, crude oil and natural gas use monthly closing prices. Inflation-adjusted value is the final adjusted monthly close for each year where published. The current year may be incomplete.

**Input**

| Field | Type | Required | Example | Description |
|---|---|---|---|---|
| `asset` | string | yes | `"gold"` | Commodity or stock index name, for example gold, crude oil, or S&P 500. |
| `end_year` | integer | no | `1973` | Last calendar year to include, for example 2024. Defaults to the last available year. |
| `start_year` | integer | no | `1970` | First calendar year to include, for example 2000. Defaults to the first available year. |

**Input schema**

```json
{
  "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.",
      "examples": [
        1973,
        2024,
        1981
      ]
    },
    "start_year": {
      "type": "integer",
      "default": 1900,
      "description": "First calendar year to include, for example 2000. Defaults to the first available year.",
      "examples": [
        1970,
        2000,
        1980
      ]
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "asset": "copper",
      "end_year": 1973,
      "start_year": 1970
    },
    {
      "asset": "gold",
      "end_year": 2024,
      "start_year": 2000
    },
    {
      "asset": "crude oil",
      "end_year": 1981,
      "start_year": 1980
    }
  ]
}
```

**Output**

| Field | Type | Example | Description |
|---|---|---|---|
| `unit` | string | `"US dollars per pound"` |  |
| `asset` | string | `"Copper"` |  |
| `price_history` | array |  |  |
| `price_history[].year` | integer | `1973` |  |
| `price_history[].page_url` | string | `"https://www.macrotrends.net/1476/copper-prices-historical-chart-data"` |  |
| `price_history[].year_low` | number or null | `0.5062` |  |
| `price_history[].year_high` | number or null | `0.6875` |  |
| `price_history[].year_open` | number or null | `0.5062` |  |
| `price_history[].year_close` | number or null | `0.6875` |  |
| `price_history[].annual_change_percent` | number or null | `35.82` |  |
| `price_history[].average_closing_price` | number or null | `0.6` |  |
| `price_history[].inflation_adjusted_value` | number or null | `2792.81` |  |

**Example input**

```json
{
  "asset": "copper",
  "end_year": 1973,
  "start_year": 1970
}
```

**Example output**

```json
{
  "unit": "US dollars per pound",
  "asset": "Copper",
  "price_history": [
    {
      "year": 1973,
      "page_url": "https://www.macrotrends.net/1476/copper-prices-historical-chart-data",
      "year_low": 0.5062,
      "year_high": 0.6875,
      "year_open": 0.5062,
      "year_close": 0.6875,
      "annual_change_percent": 35.82,
      "average_closing_price": 0.6,
      "inflation_adjusted_value": null
    },
    {
      "year": 1972,
      "page_url": "https://www.macrotrends.net/1476/copper-prices-historical-chart-data",
      "year_low": 0.5,
      "year_high": 0.5265,
      "year_open": 0.5037,
      "year_close": 0.5062,
      "annual_change_percent": 0.5,
      "average_closing_price": 0.51,
      "inflation_adjusted_value": null
    },
    {
      "year": 1971,
      "page_url": "https://www.macrotrends.net/1476/copper-prices-historical-chart-data",
      "year_low": 0.5037,
      "year_high": 0.5325,
      "year_open": 0.5325,
      "year_close": 0.5037,
      "annual_change_percent": 8.42,
      "average_closing_price": 0.52,
      "inflation_adjusted_value": null
    }
  ]
}
```

## Quick start

Call the API with a Fous API key (`FOUS_API_KEY`). To create one, turn on Developer mode in Fous Studio, then open Keys & connections → API keys (https://app.fous.com/keys).

```bash
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
: "${FOUS_API_KEY:?Set FOUS_API_KEY before running this example}"

curl 'https://api.fous.com/v1/query' \
  --fail-with-body --silent --show-error --max-time 120 \
  -H "Authorization: Bearer $FOUS_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "api": "@macrotrends",
  "visibility": "public",
  "operation": "get_company_metric_history",
  "version": 1,
  "input": {
    "metric": "net_income",
    "period": "quarterly",
    "company": "MSFT"
  },
  "response": {
    "format": "json"
  }
}'
```

```python
# Save as fous.py and run with python3 fous.py. No packages needed.
# First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
import json
import os
import urllib.error
import urllib.request

api_key = os.environ.get("FOUS_API_KEY")
if not api_key:
    raise RuntimeError("Set FOUS_API_KEY before running this example")

body = json.loads("{\n  \"api\": \"@macrotrends\",\n  \"visibility\": \"public\",\n  \"operation\": \"get_company_metric_history\",\n  \"version\": 1,\n  \"input\": {\n    \"metric\": \"net_income\",\n    \"period\": \"quarterly\",\n    \"company\": \"MSFT\"\n  },\n  \"response\": {\n    \"format\": \"json\"\n  }\n}")
request = urllib.request.Request(
    "https://api.fous.com/v1/query",
    data=json.dumps(body).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    method="POST",
)
try:
    with urllib.request.urlopen(request, timeout=120) as response:
        result = json.load(response)
except urllib.error.HTTPError as error:
    raise RuntimeError(f"HTTP {error.code}: {error.read().decode('utf-8', errors='replace')}") from error
if result.get("success") is False:
    raise RuntimeError(result.get("error", {}).get("message", "Request failed"))
print(json.dumps(result["data"]["output"], indent=2))
```

```typescript
// Save as fous.mts and run with npx tsx fous.mts.
// First set your key: export FOUS_API_KEY='YOUR_FOUS_API_KEY'
const apiKey = process.env.FOUS_API_KEY;
if (!apiKey) throw new Error("Set FOUS_API_KEY before running this example");

const response = await fetch("https://api.fous.com/v1/query", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  signal: AbortSignal.timeout(120_000),
  body: JSON.stringify({
  "api": "@macrotrends",
  "visibility": "public",
  "operation": "get_company_metric_history",
  "version": 1,
  "input": {
    "metric": "net_income",
    "period": "quarterly",
    "company": "MSFT"
  },
  "response": {
    "format": "json"
  }
}),
});
type ApiResult = { success: boolean; data?: { output: unknown }; error?: { message: string } };
const result: ApiResult = await response.json();
if (!response.ok || result.success === false) {
  throw new Error(result.error?.message ?? `HTTP ${response.status}`);
}
if (!result.data) throw new Error("Missing API response data");
console.log(result.data.output);
```

Or describe the data in plain language: send `{"api":"@macrotrends","prompt":"Describe the data you need, with every detail"}` to the same URL. Fous fills in the input, runs the method that fits and returns only the fields you asked for; `data.route.calls[].request` is the exact call it made. Routing is free; the run costs the same.

## Use cases

- Compare a company’s annual revenue over time
- Track quarterly company metrics and year-over-year changes
- Review long-term commodity price movements
- Compare yearly stock index highs, lows, opens, and closes
- Examine inflation-adjusted commodity values

## FAQ

### Is Fous affiliated with Macrotrends?

No. Fous is not affiliated with Macrotrends. This workflow reads the public macrotrends.net website and returns its data.

### How much does it cost?

Each run costs 1 credit. With pay-as-you-go, a credit costs 1¢; monthly plans cost less per credit.

### Do I need a Macrotrends account?

No. You only need a Fous account.

### How current is the data?

Fous gets the data from macrotrends.net when you run it; repeating the same request within a day may return the saved result. Fous checks this workflow automatically; it last passed a check on Sep 29, 2026.

### What was a company’s revenue in prior years?

Get company metric history returns annual or quarterly values for a selected metric and company.

### How have commodity prices changed over time?

Get long term price history returns yearly price data, including annual change percentages, for a selected asset.

### What were a stock index’s yearly highs and lows?

Get long term price history returns yearly highs and lows for a selected stock index.

## Related

- [Yahoo Finance API](https://fous.com/workflows/yahoo-finance.md): Yahoo Finance provides quotes, movers, company financials, analyst ratings, earnings, news, and up to 5,000 price rows with adjusted returns; prices may be delayed.
- [CompaniesMarketCap API](https://fous.com/workflows/companiesmarketcap.md): CompaniesMarketCap ranks public companies worldwide or by country and industry across size and financial measures, and provides company figures with market-cap history for completed years.
- [Trading Economics API](https://fous.com/workflows/trading-economics.md): Trading Economics provides economic indicators, market data and country statistics, including country overviews, latest reported country comparisons and current commodity prices reflecting reported trading days.
- [Stock Analysis API](https://fous.com/workflows/stock-analysis.md): Stock Analysis returns free-period company statements, statistics current as of its displayed date, typically top-25 ETF holdings, and US IPOs since 2019 with potentially missing prices or returns.
- [Investing.com API](https://fous.com/workflows/investing-com.md): Investing.com provides financial markets data and news, economic releases up to 31 days, and current commodity prices and government bond yields, which may be delayed or indicative.
- [Google Finance API](https://fous.com/workflows/google-finance.md): Google Finance returns possibly delayed prices and figures, indexes, up to four movers timed by oldest quote, currency conversions, and up to five financial periods.
- [SEC EDGAR API](https://fous.com/workflows/sec-edgar.md): SEC EDGAR provides filings, annual and quarterly financials, exact-phrase matches, up to 200 insider trades, and quarterly 13F manager holdings; older filings appear when available.
- [MSN Money API](https://fous.com/workflows/msn-money.md): MSN Money provides stock quotes, key facts, financial news, and market data, including current market movers; quotes and prices may be delayed.
- [All Finance workflows](https://fous.com/workflows/category/finance)
