Skip to main content
WSS
/
v1

Notes

  • Streams real-time price and market data for tokens by network and token address.
  • Returns data from the top pool of the specified token.
  • Lookup format: network_id:token_address (e.g. bsc:0x55d398326f99059ff775485246999027b3197955).
  • Find supported network IDs via Networks List.
  • Fields may return null when data is unavailable. Ensure your application handles null values.
Update Frequency:
As fast as ~1 second for actively traded tokens.

Data Payload

KeyFieldTypeDescriptionExample
cchannel_typestringChannel type subscribed to.G1
nnetwork_idstringBlockchain network identifier.bsc
tatoken_addressstringToken contract address.0x55d398326f99059ff775485246999027b3197955
pusd_pricenumberCurrent token price in USD.1.0002630480973
ppusd_price_24h_change_percentagenumberPrice change percentage (24h).0.05
musd_market_capnumberMarket capitalization in USD.9187408426.01
vusd_24h_volnumber24-hour trading volume in USD.1999727791.12
tlast_updated_atintegerUNIX timestamp in seconds.1780840630

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 OnchainSimpleTokenPrice

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

3. Stream Token Price Data

Input:
{"command":"message","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}","data":"{\"network_id:token_addresses\":[\"bsc:0x55d398326f99059ff775485246999027b3197955\"],\"action\":\"set_tokens\"}"}
Output:
{
  "code": 2000,
  "message": "Subscription successful for bsc:0x55d398326f99059ff775485246999027b3197955"
}
Streaming output:
{
  "c": "G1",
  "n": "bsc",
  "ta": "0x55d398326f99059ff775485246999027b3197955",
  "p": 1.0002630480973,
  "pp": 0.04574653488,
  "m": 9187408426.010283,
  "v": 1999727791.12026,
  "t": 1780840630
}
Output keys may appear in any order.

4. Unsubscribe

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

Messages
x_cg_pro_api_key
type:httpApiKey

CoinGecko API key

Subscribe to OnchainSimpleTokenPrice
type:object

Subscribe to the OnchainSimpleTokenPrice channel

Stream OnchainSimpleTokenPrice Data
type:object

Set tokens to receive price updates for

OnchainSimpleTokenPrice Update
type:object

Real-time onchain token price update from server