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

# Stream Solana Holder Counts and Concentration

> Subscribe to Solana token holder counts and top-10 concentration updates. Combine live events with holder snapshots from the Data API.

Use `holders:{token}` for holder-count changes and `top10:{token}` for concentration updates. Load the initial holder snapshot from REST, then use these rooms to keep the display current.

> [!NOTE]
>
> **URL:** `wss://datastream.solanatracker.io/{apiKey}`\
> Available on Premium, Business, and Enterprise plans.

## Live holder count

Subscribe to `holders:{tokenAddress}` to receive a message every time the total number of unique holders changes.

Use this value for the holder-count display or a count-change alert.

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

ws.onopen = () => {
  ws.send(JSON.stringify({ type: "join", room: `holders:${token}` }));
};

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

  console.log(`Holders: ${msg.data.total}`);
};
```

**Payload:**

```json theme={null}
{
  "type": "message",
  "room": "holders:6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
  "data": {
    "total": 14823
  }
}
```

## Top 10 holder concentration

Subscribe to `top10:{tokenAddress}` for updates to top-10 holder concentration.

Use the percentage for concentration alerts. Query holder snapshots when you need the underlying wallet rows.

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

ws.onopen = () => {
  ws.send(JSON.stringify({ type: "join", room: `top10:${token}` }));
};

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

  const { holders } = msg.data;
  const totalConcentration = holders.reduce((sum, h) => sum + h.percentage, 0);

  console.log(`Top 10 hold ${totalConcentration.toFixed(1)}% of supply`);
  holders.forEach((h, i) => {
    console.log(`  #${i + 1} ${h.address}: ${h.percentage.toFixed(2)}%`);
  });

  // Risk warning: top 10 suddenly hold a much larger share
  if (totalConcentration > 50) {
    console.log("🚨 Top 10 concentration above 50% — high risk");
  }
};
```

**Payload:**

```json theme={null}
{
  "type": "message",
  "room": "top10:6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
  "data": {
    "holders": [
      { "address": "4Rz5xqikxtZ2s7wE9uQ6n2oLXQi6K65XGoYpKxf24Hqo", "percentage": 12.5 },
      { "address": "FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1", "percentage": 8.3 }
    ]
  }
}
```

## Watch both signals together

Join both rooms on the same connection to track count and concentration together:

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

let holderCount = 0;
let top10Pct = 0;

ws.onopen = () => {
  ws.send(JSON.stringify({ type: "join", room: `holders:${token}` }));
  ws.send(JSON.stringify({ type: "join", room: `top10:${token}` }));
};

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

  const room = msg.room ?? "";

  if (room.startsWith("holders:")) {
    holderCount = msg.data.total;
    console.log(`[HOLDERS] Total: ${holderCount}`);
  }

  if (room.startsWith("top10:")) {
    top10Pct = msg.data.holders.reduce((sum, h) => sum + h.percentage, 0);
    console.log(`[TOP10] Concentration: ${top10Pct.toFixed(1)}%`);
  }
};
```

## Auto-reconnect pattern

Reconnect after an interrupted connection and rejoin the rooms. Refresh the REST snapshot if the disconnect may have left a gap:

```javascript theme={null}
function connectHolderStream(token, onHolderUpdate, onTop10Update) {
  let ws;
  let reconnectTimeout;

  function connect() {
    ws = new WebSocket("wss://datastream.solanatracker.io/YOUR_API_KEY");

    ws.onopen = () => {
      console.log("Connected — subscribing to holder streams");
      ws.send(JSON.stringify({ type: "join", room: `holders:${token}` }));
      ws.send(JSON.stringify({ type: "join", room: `top10:${token}` }));
    };

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

      if (msg.room?.startsWith("holders:")) onHolderUpdate(msg.data);
      if (msg.room?.startsWith("top10:"))   onTop10Update(msg.data);
    };

    ws.onclose = () => {
      console.log("Disconnected — reconnecting in 3s");
      reconnectTimeout = setTimeout(connect, 3000);
    };

    ws.onerror = (err) => {
      console.error("WebSocket error:", err);
      ws.close();
    };
  }

  connect();

  return () => {
    clearTimeout(reconnectTimeout);
    ws?.close();
  };
}

// Usage
const stopWatching = connectHolderStream(
  "6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN",
  (data) => console.log("Holders:", data.total),
  (data) => {
    const pct = data.holders.reduce((s, h) => s + h.percentage, 0);
    if (pct > 50) console.log("🚨 Risk warning: top 10 hold", pct.toFixed(1) + "%");
  }
);
```

## Room reference

| Room | Updates when |
| - | - |
| `holders:{token}` | Total holder count changes |
| `top10:{token}` | Any top 10 wallet buys, sells, or exits |

## Related guides

* [Get All Holders (REST)](https://docs.solanatracker.io/guides/token-holders.md) — fetch a full snapshot of the holder list
* [Safety Streams](https://docs.solanatracker.io/guides/datastream-safety.md) — also covers sniper, bundler, insider, and dev holding changes
* [Token Safety & Rugcheck](https://docs.solanatracker.io/guides/token-safety.md) — use the risk score API for a point-in-time safety check


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