# 加密行情 代币价格 API (crypto_market.token_price)

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

加密行情代币价格按 `token` 查当前的美元价格，一次可以用逗号分隔传多个代币，每个返回一行：代币符号、价格 `price_usd`、价格时间 `price_at`、可信度 `confidence`，按合约地址查的代币还带精度 `decimals`。它回答「这些代币现在值多少钱」，适合给钱包和投资组合估值、在应用里显示实时报价，或者定时记录价格做监控。

代币写「链:合约地址」，比如以太坊上的 USDT 合约，或「coingecko:币的 id」，比如 coingecko:bitcoin。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| token | not declared | yes | not declared | 代币：「链:合约地址」（如 ethereum:0xdac17f958d2ee523a2206206994597c13d831ec7）或「coingecko:币的 id」（如 coingecko:bitcoin）；token_price 可用逗号分隔一次最多 20 个，token_chart 只收一个。 |
| limit | integer (1–) | no | not declared | 这次调用最多返回的条数，整数，至少为 1；不传按默认值，实际返回可能少于这个数。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| token | 请求里的代币写法（链:合约地址 或 coingecko:id），和请求一致。 |
| symbol | 代币符号（如 BTC、USDT）。 |
| price_usd | 价格，美元。 |
| price_at | 这个价格的时间，ISO 8601 UTC。 |
| decimals | 代币精度（合约地址写法的代币才有，token_price）。 |
| 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_price",
  "params": {
    "token": "coingecko:bitcoin,ethereum:0xdac17f958d2ee523a2206206994597c13d831ec7"
  }
}'
```

```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_price",
        "params": {
            "token": "coingecko:bitcoin,ethereum:0xdac17f958d2ee523a2206206994597c13d831ec7",
        },
    },
    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_price",
  "results": [
    {
      "token": …,
      "symbol": …,
      "price_usd": …,
      "price_at": …,
      "decimals": …,
      "confidence": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### `decimals` 什么时候有？

只有用「链:合约地址」写法查的代币才返回 `decimals`，它是代币合约的精度。把链上读到的原始余额除以 10 的 `decimals` 次方，再乘以 `price_usd`，就是这笔持仓的美元价值。

### 返回的 `token` 和请求里的写法一样吗？

一样，`token` 原样回显你请求时的写法。一次查多个代币时，用它把每一行和请求里的代币对上，不用依赖返回顺序。

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

要当前价格，尤其是同时查一篮子代币，用代币价格；要看一个代币在一段时间里的走势，用历史价格，它按固定间隔返回一串价格点。

## 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
