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

FieldTypeDescriptionExample
chchannel_typestringIndicates the type of channel subscribed to.G2
nnetwork_idstringIdentifier of the blockchain network. Check full list of IDs here.eth
papool_addressstringContract address of the pool.0x88e6a0c2dd6fcb..3f5640
txtx_hashstringtransaction hash0x0b8ac5a16c2d5a..4d422
tytypestringtype of transaction (b for buy or s for sell)b
totoken_amountfloatAmount of token transacted.100
vovolume_in_usdfloatThe transaction value in USD.1000
pcprice_in_token_currencyfloatCurrent token price in target token currency3639.78228844745
puprice_in_usdfloatCurrent token price in USD3.566
tlast_updated_atintegerTimestamp 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_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"action\":\"set_pools\"}"}
Output Example:
{
  "code": 2000,
  "message": "Subscription successful for bsc:0x172fcd41e0913e95784454622d1c3724f546f849"
}
Output Example:
{
  "c": "G2",
  "n": "bsc",
  "pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
  "tx": "0x3e71ee7da66000a5a92f13abd2ae95e0abc0bc828087d8dd210338fd262cf6c9",
  "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:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"action\":\"unset_pools\"}"}
Output Example:
{
  "code":2000,
  "message":"Unsubscription is successful for bsc:0x172fcd41e0913e95784454622d1c3724f546f849"
}
Input Example: Unsubscribe from OnchainTrade channel and all pools data:
{"command":"unsubscribe","identifier":"{\"channel\":\"OnchainTrade\"}"}
Output Example:
{
  "code":2000,
  "message":"Unsubscription is successful for all pools"
}