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,
"r": 30595921111,
"tr": 130595921115,
"pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
"t": 1780840630
}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, except
tr, which totals the reserve across all pools. - 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 |
r | reserve | number | Liquidity reserve in USD of the token’s most liquid pool. | 30595921111 |
tr | total_reserve | number | Total liquidity reserve in USD of the token, across all pools. | 130595921115 |
pa | pool_address | string | Pool address of the token’s most liquid pool. | 0x172fcd41e0913e95784454622d1c3724f546f849 |
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,
"r": 30595921111,
"tr": 130595921115,
"pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
"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,
"r": 30595921111,
"tr": 130595921115,
"pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
"t": 1780840630
}x_cg_pro_api_key
type:httpApiKey
CoinGecko API key
Subscribe to OnchainSimpleTokenPrice
type:object
Subscribe to the OnchainSimpleTokenPrice channel
command
type:enum
required
Subscription command
Available options:
subscribeidentifier
type:string
required
JSON string specifying the target channel
Stream OnchainSimpleTokenPrice Data
type:object
Set tokens to receive price updates for
command
type:enum
required
Message command
Available options:
messageidentifier
type:string
required
JSON string specifying the target channel
data
type:string
required
JSON string with network_id:token_addresses array, format: network_id:token_address
OnchainSimpleTokenPrice Update
type:object
Real-time onchain token price update from server
c
type:string
Channel type
n
type:string
Network identifier
ta
type:string
Token contract address
p
type:number
Token price in USD
pp
type:number
24h price change percentage
m
type:number
Market cap in USD
v
type:number
24h trading volume in USD
r
type:number
Liquidity reserve in USD of the most liquid pool
tr
type:number
Total liquidity reserve in USD across all pools
pa
type:string
Address of the most liquid pool
t
type:integer
UNIX timestamp in seconds
Was this page helpful?

