# 加密行情 代币历史价格 API (crypto_market.token_chart)

- Canonical page: https://everyinfra.com/crypto-market-api/token_chart
- Endpoint: POST /api/v1/social with {"platform": "crypto_market", "action": "token_chart", "params": {...}}
- Price: $0.001389 per call ($1.39 per 1,000 requests); failed and empty results are not charged
- Returns: list, default 30, max 500 per call
- Mode: sync; add "mode": "async" for slow tasks

加密行情代币历史价格按一个 `token` 返回一串按时间排列的美元价格点，从当前往前取，每个点带代币符号、价格 `price_usd`、时间 `price_at` 和可信度 `confidence`。用 `period` 选两个点之间的间隔，从 5 分钟到 1 周。它回答「这个代币过去一段时间价格怎么走」，适合画价格走势图、回测策略、计算波动率，或在报告里引用某个时间点的价格。

`token` 写「链:合约地址」或「coingecko:币的 id」，一次只收一个；`limit` 是价格点的个数。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| token | not declared | yes | not declared | 一个代币：「链:合约地址」或「coingecko:币的 id」；limit 是价格点个数（默认 30，最多 500），到当前为止往前取。 |
| period | enum: 12h / 15m / 1d / 1h / 1w / 4h / 5m | no | not declared | token_chart 两个价格点的间隔：5m、15m、1h、4h、12h、1d（默认）、1w。 |
| limit | integer (1–500) | no | 30 | 这次调用最多返回的条数，整数，1–500；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| token | 请求里的代币写法（链:合约地址 或 coingecko:id），和请求一致。 |
| symbol | 代币符号（如 BTC、USDT）。 |
| price_usd | 价格，美元。 |
| price_at | 这个价格的时间，ISO 8601 UTC。 |
| confidence | 价格可信度，0–1（数据源给的值；越低说明可参考的成交越少）。 |
| 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": "crypto_market",
  "action": "token_chart",
  "params": {
    "token": "coingecko:bitcoin"
  }
}'
```

```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": "crypto_market",
        "action": "token_chart",
        "params": {
            "token": "coingecko:bitcoin",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "crypto_market",
  "action": "token_chart",
  "results": [
    {
      "token": …,
      "symbol": …,
      "price_usd": …,
      "price_at": …,
      "confidence": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么拿最近 30 天的日线？

`period` 传 `1d`，`limit` 传 30，就能拿到到当前为止往前 30 个日价格点。要更细的走势，换成 `1h` 或 `4h`，并相应调大 `limit`。

### `confidence` 低说明什么？

`confidence` 在 0 到 1 之间，越低说明这个价格可参考的成交越少。画图或回测前，可以把可信度过低的点标出来或剔除，避免小币种的零星成交把结论带偏。

### 历史价格和代币价格怎么选？

只要现在的价格，用代币价格，一次可以查多个代币；要看一段时间的走势，用历史价格，一次一个代币，返回一串时间点。

## Also

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