Two numbers, two sources
Before any code, know which number you want, because the two sources answer slightly different questions.
If your badge says how many KOLs are in this token, you want the stream and its kol_count. If it says how active has this token been lately, you want the REST count.
Option A, a number on demand over REST
The REST counter is one call. You give it a chain, a wallet type and a time window built from seconds, minutes and hours, up to 24 hours back, and it returns just the count. No transactions, so it is fast and cheap.Step 1, the fetch
src/count-rest.ts
Step 2, show it, and refresh on an interval
Since REST gives you a snapshot, poll it on a timer if you want it to stay current. A 30 second interval is plenty for an activity badge.src/badge-rest.ts
Option B, a live badge over WebSocket
The stream is better when you want the badge to update the moment a KOL buys. You subscribe once, and every time the KOL wallet count for a token changes, you get the new number pushed to you.Step 1, connect and subscribe
Subscribe with the wildcard to watch every token, or pass a single mint to watch one. The stream always reports the KOL wallet count, it is not split by wallet type.src/count-stream.ts
Step 2, keep a count per token and render
Hold the latest count per mint in a Map, and update the matching badge whenever an event arrives. This scales to a whole list of tokens on one connection.src/badges-live.ts
index.html
Which one should you use
A simple rule. If you are decorating a static list and a number that is a little stale is fine, poll the REST count, it is one call and needs no connection. If the freshness is the point, a live count that ticks up as KOLs pile in, use the stream. You can also combine them. Seed each badge with a REST count on first paint so it is never empty, then let the stream take over for live updates.Billing note
The REST count is one request per call, cheap because it returns only a number. On the stream, each delivered wallet_count event counts against your plan, so a wildcard subscription on a busy chain can add up, filter to the tokens you actually show.Reference
GET /v1/transactions/count
The REST counter over a time window.
WSS count stream
The live KOL wallet count per token.

