Subscribe
This endpoint returns a websocket that can be used to subscribe to balances for a given address Every time the API detects a token transfer to or from this address, an update will be sent.
The Token Balances API provides accurate and fast real time balances of the native and ERC20 tokens of accounts on supported blockchains (EVM currently).
The websocket complement that by allowing you to subscribe to balance changes in real-time, whenever a token is transferred to or from address
, without the need to poll the API.
Install the dependencies
Wscat is a popular WebSocket utility for creating WebSocket connections. It allows you to send and receive messages interactively via the command line.
npm install -g wscat
Call the webhook
Just replace Wallet Address
and Dune API Key
with your own values.
wscat -c wss://api.dune.com/api/beta/balance/{Wallet Address}/subscribe \
-H "X-Dune-Api-Key: {Dune API Key}"
Get balance changes in your terminal
Whenever there is a balance change, you will receive the updates in your terminal. Here an example:
{
"response_time":"2024-07-24T14:36:46.086ZZ","wallet_address":"0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad","balances":
[
{
"chain": "polygon",
"chain_id": 137,
"address": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
"amount": "1000000",
"symbol": "USDC",
"decimals": 6,
"price_usd": 0.9999765798076116,
"value_usd": 0.9999765798076116
}
]
}
Headers
API key to access the service
Path Parameters
Wallet to get balances for
Query Parameters
Comma separated list of chain ids to filter by
Was this page helpful?