# Yahoo Finance 历史行情 API (yahoo_finance.history)

- Canonical page: https://everyinfra.com/yahoo-finance-api/history
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "yahoo_finance", "action": "history", "params": {...}}
- Price: $0.001389 per call ($1.39 per 1,000 requests); failed calls and empty results are not charged
- Returns: list
- Mode: sync; add "mode": "async" for slow tasks

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=yahoo_finance&action=history

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | Yahoo Finance 标的代码，例如 AAPL；不是公司名全文搜索，市场后缀须保留。history 每次针对一个代码返回历史 OHLCV。 |
| interval | not declared | no | not declared | K 线粒度，默认 1d。1m/2m/5m/15m/30m/60m/90m 是分钟，1h 是小时，1d/5d 是天，1wk 是周，1mo/3mo 是月；1m 不是一个月。分钟粒度与长 period 的组合可能受历史窗口限制。 |
| period | not declared | no | not declared | 回看跨度：1d/5d 为一天/五天，1mo/3mo/6mo 为一/三/六个月，1y/2y/5y/10y 为一/二/五/十年，ytd 年初至今，max 可取得的最长历史；默认 1mo，max 不保证上市以来完整数据。 |
| limit | integer (1–) | no | not declared | 这次调用最多返回的条数，整数，至少为 1；不传按默认值，实际返回可能少于这个数。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| symbol | 股票代码。 |
| date | 该条数据的日期。 |
| open | 开盘价。 |
| high | 最高价。 |
| low | 最低价。 |
| close | 收盘价。 |
| volume | 成交量。 |
| dividends | 分红记录。 |
| stock_splits | 拆股记录。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "yahoo_finance",
  "action": "history",
  "params": {
    "keyword": "AAPL"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "yahoo_finance",
        "action": "history",
        "params": {
            "keyword": "AAPL",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-09-26T08:56:04Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 22. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "yahoo_finance",
  "action": "history",
  "results": [
    {
      "symbol": "AAPL",
      "date": "2026-08-26T00:00:00-04:00",
      "open": 310.3,
      "high": 315.43,
      "low": 308.8,
      "close": 313.45,
      "volume": 34024500,
      "stock_splits": 0,
      "platform": "yahoo_finance"
    },
    {
      "symbol": "AAPL",
      "date": "2026-08-27T00:00:00-04:00",
      "open": 310.55,
      "high": 315.4,
      "low": 309.4,
      "close": 314.58,
      "volume": 32419200,
      "stock_splits": 0,
      "platform": "yahoo_finance"
    }
  ],
  "count": 22,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=yahoo_finance
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
