Messages
{
"command": "<string>",
"identifier": "<string>"
}{
"command": "<string>",
"identifier": "<string>",
"data": "<string>"
}{
"c": "G2",
"n": "bsc",
"pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
"tx": "0x3aa702e87ebc87cc4f877ab494afa0ac59f46873c147ee406a546c1e12ab5f57",
"ty": "s",
"to": 0.0369078635593666,
"toq": 0.000062600168318069,
"vo": 0.036858979105679,
"pc": 0.0016961200752619,
"pu": 0.998675500314209,
"t": 1780840929000
}Trades
OnchainTrade
Real-time onchain DEX trade updates by pool address
WSS
/
v1
Notes
- Streams real-time trade/swap updates for pools by network and pool address.
- Returns transaction type (buy/sell), tx hash, token amounts, volume, and price data.
- Lookup format:
network_id:pool_address(e.g.bsc:0x172fcd41e0913e95784454622d1c3724f546f849). - Find supported network IDs via Networks List.
- Use Top Pools by Token Address to find the most liquid pool address.
- Fields may return
nullwhen data is unavailable. Ensure your application handles null values.
Update Frequency:
As fast as ~0.1 seconds for actively traded pools.
As fast as ~0.1 seconds for actively traded pools.
Data Payload
| Key | Field | Type | Description | Example |
|---|---|---|---|---|
c | channel_type | string | Channel type subscribed to. | G2 |
n | network_id | string | Blockchain network identifier. | bsc |
pa | pool_address | string | Pool contract address. | 0x172fcd41e0913e95784454622d1c3724f546f849 |
tx | tx_hash | string | Transaction hash. | 0x743b271e...5adf698 |
ty | type | string | Trade type (b = buy, s = sell). | b |
to | token_amount | number | Base token amount. | 0.037 |
toq | quote_token_amount | number | Quote token amount. | 0.0000626 |
vo | volume_in_usd | number | Trade volume in USD. | 0.037 |
pc | price_in_native_currency | number | Token price in network native currency. | 0.0017 |
pu | price_in_usd | number | Token price in USD. | 0.999 |
t | last_updated_at | integer | UNIX timestamp in milliseconds. | 1780840929000 |
1. Establish Connection
wss://stream.coingecko.com/v1?x_cg_pro_api_key=YOUR_KEY
You can also pass the key as a header:
x-cg-pro-api-key: YOUR_KEY{
"code": 3000,
"message": "Connection established",
"uuid": "YOUR_SESSION_ID"
}
{
"type": "welcome",
"sid": "YOUR_SESSION_ID"
}
2. Subscribe to OnchainTrade
Input:{"command":"subscribe","identifier":"{\"channel\":\"OnchainTrade\"}"}
{
"type": "confirm_subscription",
"identifier": "{\"channel\":\"OnchainTrade\"}"
}
3. Stream Trade Data
Input:{"command":"message","identifier":"{\"channel\":\"OnchainTrade\"}","data":"{\"network_id:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"action\":\"set_pools\"}"}
{
"code": 2000,
"message": "Subscription successful for bsc:0x172fcd41e0913e95784454622d1c3724f546f849"
}
{
"c": "G2",
"n": "bsc",
"pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
"tx": "0x3aa702e87ebc87cc4f877ab494afa0ac59f46873c147ee406a546c1e12ab5f57",
"ty": "s",
"to": 0.0369078635593666,
"toq": 0.000062600168318069,
"vo": 0.036858979105679,
"pc": 0.0016961200752619,
"pu": 0.998675500314209,
"t": 1780840929000
}
Output keys may appear in any order.
4. Unsubscribe
Unsubscribe from a specific pool:{"command":"message","identifier":"{\"channel\":\"OnchainTrade\"}","data":"{\"network_id:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"action\":\"unset_pools\"}"}
{
"code": 2000,
"message": "Unsubscription is successful for bsc:0x172fcd41e0913e95784454622d1c3724f546f849"
}
{"command":"unsubscribe","identifier":"{\"channel\":\"OnchainTrade\"}"}
{
"code": 2000,
"message": "Unsubscription is successful for all pools"
}
Messages
{
"command": "<string>",
"identifier": "<string>"
}{
"command": "<string>",
"identifier": "<string>",
"data": "<string>"
}{
"c": "G2",
"n": "bsc",
"pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
"tx": "0x3aa702e87ebc87cc4f877ab494afa0ac59f46873c147ee406a546c1e12ab5f57",
"ty": "s",
"to": 0.0369078635593666,
"toq": 0.000062600168318069,
"vo": 0.036858979105679,
"pc": 0.0016961200752619,
"pu": 0.998675500314209,
"t": 1780840929000
}x_cg_pro_api_key
type:httpApiKey
CoinGecko API key
Subscribe to OnchainTrade
type:object
Subscribe to the OnchainTrade channel
Stream OnchainTrade Data
type:object
Set pools to receive trade updates for
OnchainTrade Update
type:object
Real-time DEX trade update from server
Was this page helpful?
⌘I

