Subscribe to receive real-time transaction (trade/swap) updates for pools, as seen on GeckoTerminal.com
This Websocket channel allows you to subscribe to real-time updates of token trades of a pool.
- Lookup by Network + Pool Address
- It will return transaction type (buy/sell), tx hash, amount of token transacted, volume, and current price data of the specified pool.
Update Frequency: as fast as 0.1s, for actively traded pools.
Tips: use this Rest API endpoint Top Pools by Token Address to obtain contract address of the most liquid pool.
Data Payload
Field | Type | Description | Example | |
---|---|---|---|---|
ch | channel_type | string | Indicates the type of channel subscribed to. | G2 |
n | network_id | string | Identifier of the blockchain network. Check full list of ids here. | eth |
pa | pool_address | string | Contract address of the pool. | 0x88e6a0c2dd6fcb..3f5640 |
tx | tx_hash | string | transaction hash | 0x0b8ac5a16c2d5a..4d422 |
ty | type | string | type of transaction ("b" for buy or "s" for sell) | b |
to | token_amount | float | Amount of token transacted. | 100 |
vo | volume_in_usd | float | The transaction value in USD. | 1000 |
pc | price_in_token_currency | float | Current token price in target token currency | 3639.78228844745 |
pu | price_in_usd | float | Current token price in USD | 3.566 |
t | last_updated_at | integer | Timestamp of the last data update in Unix time. | 1752072129000 |
Tips: The Websocket payload will use the value null
when specific data is unavailable. Ensure your application is capable of handling null values for fields that may not always have data.
1. Establish Connection to Websocket
wss://stream.coingecko.com/v1?x_cg_pro_api_key=YOUR_KEY
OR
wss://stream.coingecko.com/v1
x-cg-pro-api-key: YOUR_KEY
2. Subscribe to a specific channel - OnchainTrade
Input Example:
{"command":"subscribe","identifier":"{\"channel\":\"OnchainTrade\"}"}
Output Example:
{"type":"confirm_subscription","identifier":"{\"channel\":\"OnchainTrade\"}"}
3. Stream OnchainTrade data
Input Example:
{"command":"message","identifier":"{\"channel\":\"OnchainTrade\"}","data":"{\"network_id:pool_address\":[\"eth:0x1d42064fc4beb5f8aaf85f4617ae8b3b5b8bd801\"],\"action\":\"set_pools\"}"}
Output Example:
{
"code": 2000,
"message": "Subscription successful for eth:0x1d42064fc4beb5f8aaf85f4617ae8b3b5b8bd801"
}
Output Example:
{
"c": "G2",
"n": "berachain-bartio",
"pa": "0x7507c1dc16935b82698e4c63f2746a2fcf994df8",
"tx": "0x0b8ac5a16c291832c1b4d5f0d8ef2d9d58e207cd8132c32392295617daa4d422",
"ty": "b",
"to": "1.51717616246451",
"vo": "2.75413132131313",
"pc": "0.000274100995437363"
"pu": "3656.8970003075",
"t": 1724927796000
}
The output keys will be in random order.
Tips:
Un-subscribe to stop streaming OnchainTrade data
Input Example: Unsubscribe for 1 specific pool data:
{"command":"message","identifier":"{\"channel\":\"OnchainTrade\"}","data":"{\"network_id:token_address\":[\"eth:0x1d42064fc4beb5f8aaf85f4617ae8b3b5b8bd801\"],\"action\":\"unset_tokens\"}"}
Output Example:
{
"code":2000,
"message":"Unsubscription is successful for eth:0x1d42064fc4beb5f8aaf85f4617ae8b3b5b8bd801"
}
Input Example: Unsubscribe from OnchainTrade channel and all token data:
{"command":"unsubscribe","identifier":"{\"channel\":\"OnchainTrade\"}"}
Output Example:
{
"code":2000,
"message":"Unsubscription is successful for all pools"
}