This Websocket channel allows you to subscribe to real-time updates of price changes for token.
  • Lookup by Network + Token Address
  • It will return price and market data of the top pool of the specified token
Update Frequency: as fast as 1s, for actively traded tokens.

Data Payload

FieldTypeDescriptionExample
cchannel_typestringIndicates the type of channel subscribed to.G1
nnetwork_idstringIdentifier of the blockchain network. Check full list of IDs here.eth
tatoken_addressstringContract address of the token on the blockchain.0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
pusd_pricefloatCurrent token price in USD.3639.78228844745
ppusd_price_24h_change_percentagefloatPercentage change in token price over the last 24 hours.3.566
musd_market_capfloatMarket capitalization in USD.123
vusd_24h_volfloat24-hour trading volume in USD.31233333.33
tlast_updated_atintegerTimestamp of the last data update in UNIX time.1709542750
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 - OnchainSimpleTokenPrice

Input Example:
{"command":"subscribe","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}"}
Output Example:
{"type":"confirm_subscription","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}"}

3. Stream OnchainSimpleTokenPrice data

Input Example:
{"command":"message","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}","data":"{\"network_id:token_addresses\":[\"bsc:0x55d398326f99059ff775485246999027b3197955\"],\"action\":\"set_tokens\"}"}
Output Example:
{
  "code": 2000,
  "message": "Subscription successful for bsc:0x55d398326f99059ff775485246999027b3197955"
}
Output Example:
{
  "c": "G1",
  "n": "bsc",
  "ta": "0x55d398326f99059ff775485246999027b3197955",
  "p": 0.999457718373347,
  "pp": -0.009028866490825653,
  "m": 1317802988326.25,
  "v": 1476864199.38384,
  "t": 1737427063
}
The output keys will be in random order.

Tips:

Un-subscribe to stop streaming OnchainSimpleTokenPrice data

Input Example: Unsubscribe for 1 specific token data:
{"command":"message","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}","data":"{\"network_id:token_addresses\":[\"bsc:0x55d398326f99059ff775485246999027b3197955\"],\"action\":\"unset_tokens\"}"}
Output Example:
{
  "code":2000,
  "message":"Unsubscription is successful for bsc:0x55d398326f99059ff775485246999027b3197955"
}
Input Example: Unsubscribe from OnchainSimpleTokenPrice channel and all token data:
{"command":"unsubscribe","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}"}
Output Example:
{
  "code":2000,
  "message":"Unsubscription is successful for all tokens"
}