> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Solana 巨鲸和 KOL 交易追踪

> 查询 Solana 巨鲸和 KOL 交易，按美元金额或代币筛选，并通过 Datastream 订阅带钱包身份的实时交易流。

先用 REST 加载近期的巨鲸或 KOL 交易，再订阅 Datastream 接收新活动。巨鲸筛选使用固定的美元阈值；基础 KOL 流也包含低于 \$1,000 的交易。

> [!NOTE]
>
> REST API 返回最新已索引的交易。Datastream 通过 WebSocket 实时推送新交易。两者都使用 Solana Tracker Data API 密钥。

## REST API

### 最新巨鲸交易

请求达到指定美元阈值的巨鲸交易：

```bash theme={null}
curl "https://data.solanatracker.io/trades/whales?minVolume=10000&limit=50&hideArb=true" \
  -H "x-api-key: YOUR_API_KEY"
```

`minVolume` 可选 `1000`、`2500`、`5000` 或 `10000`。结果按时间从新到旧排序。

### 最新 KOL 交易

获取共享 KOL 名单内钱包的交易：

```bash theme={null}
curl "https://data.solanatracker.io/trades/kols?minVolume=2500&limit=100" \
  -H "x-api-key: YOUR_API_KEY"
```

如需所有符合条件的 KOL 交易，使用 `minVolume=0` 或直接省略 `minVolume`：

```bash theme={null}
curl "https://data.solanatracker.io/trades/kols?limit=100" \
  -H "x-api-key: YOUR_API_KEY"
```

有身份数据时，每笔交易都包含：

```json theme={null}
{
  "wallet": "9jyqFiLnruggWnN4EQwBNFXwpbLM9hrA4hV59ytyAVVz",
  "type": "buy",
  "volume": 1517.82,
  "identity": {
    "name": "Example KOL",
    "twitter": "@example"
  }
}
```

### 单个代币的 KOL 交易

把 KOL 交易限定到某个 mint，用于代币页面或提醒：

```bash theme={null}
curl "https://data.solanatracker.io/trades/kols/TOKEN_MINT?minVolume=1000&hideArb=true" \
  -H "x-api-key: YOUR_API_KEY"
```

单代币 KOL 端点同样默认 `minVolume=0`；如果想让这一行为更明确，可以显式传入 `minVolume=0`。

使用 `hideArb=true` 时，响应只保留请求的 mint 作为交易一方的记录。

### 分页读取历史数据

响应包含 `nextCursor` 和 `hasNextPage`。把不透明游标原样传回：

```javascript theme={null}
const base = "https://data.solanatracker.io/trades/whales";
const params = new URLSearchParams({
  minVolume: "5000",
  limit: "250",
  showMeta: "true",
});

let cursor;
do {
  if (cursor) params.set("cursor", cursor);

  const response = await fetch(`${base}?${params}`, {
    headers: { "x-api-key": process.env.SOLANA_TRACKER_API_KEY },
  });
  const page = await response.json();

  for (const trade of page.trades) {
    console.log(trade.time, trade.type, trade.volume, trade.wallet);
  }

  cursor = page.hasNextPage ? page.nextCursor : null;
} while (cursor);
```

界面需要显示 `from` 和 `to` 两侧的代币名称、符号、图片、精度或历史价格时，使用 `showMeta=true`。

> [!WARNING]
>
> 把 `nextCursor` 视为不透明值。不要在应用代码中解码、修改或自行构造游标。

## 实时 Datastream

连接到：

```text theme={null}
wss://datastream.solanatracker.io/{YOUR_API_KEY}
```

### 巨鲸监控

加入某个档位房间，接收符合条件的新交易：

```javascript theme={null}
const ws = new WebSocket(
  "wss://datastream.solanatracker.io/YOUR_API_KEY"
);

ws.addEventListener("open", () => {
  ws.send(JSON.stringify({
    type: "join",
    room: "transaction:whale:10000",
  }));
});

ws.addEventListener("message", (event) => {
  const message = JSON.parse(event.data);
  if (message.type !== "message") return;

  for (const trade of message.data) {
    const label = trade.type === "buy" ? "WHALE BUY" : "WHALE SELL";
    console.log(
      `${label} $${trade.volume.toLocaleString()} ` +
      `${trade.token?.to?.symbol ?? "token"} by ${trade.wallet}`
    );
  }
});
```

可用的巨鲸房间：

```text theme={null}
transaction:whale:1000
transaction:whale:2500
transaction:whale:5000
transaction:whale:10000
```

房间是累积式的。一笔 \$12,000 的交易会发送到 `1000`、`2500`、`5000` 和 `10000` 房间。只加入应用需要的档位。

### KOL 追踪器

`transaction:kol` 接收所有符合条件的 KOL 交易，包括低于 \$1,000 档位阈值的交易：

```javascript theme={null}
ws.send(JSON.stringify({
  type: "join",
  room: "transaction:kol",
}));

ws.addEventListener("message", (event) => {
  const message = JSON.parse(event.data);
  if (message.type !== "message" || message.room !== "transaction:kol") {
    return;
  }

  const trade = message.data[0];
  const identity = trade.identity?.twitter || trade.identity?.name || trade.wallet;
  console.log(
    `${identity}: ${trade.type} $${trade.volume.toLocaleString()} ` +
    `on ${trade.token?.to?.symbol ?? trade.token?.from?.symbol ?? "token"}`
  );
});
```

如需高价值 KOL 提醒，使用累积式档位房间：

```javascript theme={null}
ws.send(JSON.stringify({
  type: "join",
  room: "transaction:kol:5000",
}));
```

### KOL 信号管道

在发送提醒前，先按金额过滤收到的 KOL 交易：

```javascript theme={null}
function handleKolTrade(message) {
  if (message.type !== "message") return;

  for (const trade of message.data) {
    const identity = trade.identity;
    const token = trade.token?.to?.symbol || trade.token?.from?.symbol;

    if (trade.type === "buy" && trade.volume >= 5000) {
      console.log({
        event: "kol_buy_signal",
        wallet: trade.wallet,
        name: identity?.name,
        twitter: identity?.twitter,
        token,
        volumeUsd: trade.volume,
        signature: trade.tx,
      });
    }
  }
}

ws.addEventListener("message", (event) => {
  handleKolTrade(JSON.parse(event.data));
});
```

把原始交易和由其生成的提醒分开保存。提醒只是应用内事件，不会提交兑换。

## 消息结构

巨鲸和 KOL 的 Datastream 消息在单元素 `data` 数组中包含一笔增强后的交易：

```json theme={null}
{
  "type": "message",
  "room": "transaction:whale:10000",
  "data": [
    {
      "tx": "TRANSACTION_SIGNATURE",
      "amount": 125000.5,
      "priceUsd": 0.00012,
      "solVolume": 12.5,
      "volume": 12500,
      "type": "buy",
      "wallet": "WALLET_ADDRESS",
      "time": 1786470000000,
      "program": "raydium",
      "token": {
        "from": { "symbol": "SOL", "amount": 12.5 },
        "to": { "symbol": "MEME", "amount": 125000.5 }
      },
      "identity": {
        "name": "Example KOL",
        "twitter": "@example"
      }
    }
  ]
}
```

交易钱包在共享 KOL 名单内时才有 `identity`。`time` 是 Unix 毫秒时间戳。`volume` 是美元成交量的绝对值，买卖方向看 `type`。

## 上线检查清单

1. 如果消费端会重连，按交易签名加钱包、代币和方向去重。
2. 回填数据时持久化最后一个 REST `nextCursor`。
3. WebSocket 客户端用指数退避重连。
4. 只加入需要的房间，避免累积式事件重复。
5. 分开存储原始交易和派生提醒。
6. 跟单前先做好自己的风险和执行检查。

> [card] [巨鲸与 KOL REST API](https://docs.solanatracker.io/cn/data-api/whale-trades/latest-high-volume-whale-spot-trades.md)
>
> 查看端点参数、响应结构和分页。

> [card] [巨鲸与 KOL Datastream](https://docs.solanatracker.io/cn/datastream/websockets/whaletrades.md)
>
> 查看房间、加入消息和实时交易消息体。

> [card] [实时兑换](https://docs.solanatracker.io/cn/guides/live-transactions.md)
>
> 订阅某个代币的每一笔兑换。

> [card] [KOL 表现](https://docs.solanatracker.io/cn/guides/kol-tracking.md)
>
> 分析钱包表现和 KOL 活动。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.