Messages
{
"command": "<string>",
"identifier": "<string>"
}{
"command": "<string>",
"identifier": "<string>",
"data": "<string>"
}{
"c": "G1",
"n": "bsc",
"ta": "0x55d398326f99059ff775485246999027b3197955",
"p": 1.0002630480973,
"pp": 0.04574653488,
"m": 9187408426.01,
"v": 1999727791.12,
"t": 1780840630
}Price
OnchainSimpleTokenPrice
Real-time onchain token price updates by network and token address
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
nullwhen data is unavailable. Ensure your application handles null values.
Update Frequency:
As fast as ~1 second for actively traded tokens.
As fast as ~1 second for actively traded tokens.
Data Payload
| Key | Field | Type | Description | Example |
|---|---|---|---|---|
c | channel_type | string | Channel type subscribed to. | G1 |
n | network_id | string | Blockchain network identifier. | bsc |
ta | token_address | string | Token contract address. | 0x55d398326f99059ff775485246999027b3197955 |
p | usd_price | number | Current token price in USD. | 1.0002630480973 |
pp | usd_price_24h_change_percentage | number | Price change percentage (24h). | 0.05 |
m | usd_market_cap | number | Market capitalization in USD. | 9187408426.01 |
v | usd_24h_vol | number | 24-hour trading volume in USD. | 1999727791.12 |
t | last_updated_at | integer | UNIX 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{
"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\"}"}
{
"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\"}"}
{
"code": 2000,
"message": "Subscription successful for bsc:0x55d398326f99059ff775485246999027b3197955"
}
{
"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"
}
{"command":"unsubscribe","identifier":"{\"channel\":\"OnchainSimpleTokenPrice\"}"}
{
"code": 2000,
"message": "Unsubscription is successful for all tokens"
}
Messages
{
"command": "<string>",
"identifier": "<string>"
}{
"command": "<string>",
"identifier": "<string>",
"data": "<string>"
}{
"c": "G1",
"n": "bsc",
"ta": "0x55d398326f99059ff775485246999027b3197955",
"p": 1.0002630480973,
"pp": 0.04574653488,
"m": 9187408426.01,
"v": 1999727791.12,
"t": 1780840630
}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
Was this page helpful?
⌘I

