Skip to main content
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 null when data is unavailable. Ensure your application handles null values.
Update Frequency:
As fast as ~0.1 seconds for actively traded pools.

Data Payload

KeyFieldTypeDescriptionExample
cchannel_typestringChannel type subscribed to.G2
nnetwork_idstringBlockchain network identifier.bsc
papool_addressstringPool contract address.0x172fcd41e0913e95784454622d1c3724f546f849
txtx_hashstringTransaction hash.0x743b271e...5adf698
tytypestringTrade type (b = buy, s = sell).b
totoken_amountnumberBase token amount.0.037
toqquote_token_amountnumberQuote token amount.0.0000626
vovolume_in_usdnumberTrade volume in USD.0.037
pcprice_in_native_currencynumberToken price in network native currency.0.0017
puprice_in_usdnumberToken price in USD.0.999
tlast_updated_atintegerUNIX 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
Output:
{
  "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\"}"}
Output:
{
  "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\"}"}
Output:
{
  "code": 2000,
  "message": "Subscription successful for bsc:0x172fcd41e0913e95784454622d1c3724f546f849"
}
Streaming output:
{
  "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"
}
Unsubscribe from the channel entirely:
{"command":"unsubscribe","identifier":"{\"channel\":\"OnchainTrade\"}"}
{
  "code": 2000,
  "message": "Unsubscription is successful for all pools"
}

Messages
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