OnchainSimpleTokenPrice

Subscribe to receive real-time price updates for tokens, as seen on GeckoTerminal.com

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 & market data of the top pool of the specified token

Update Frequency: as fast as 1s, for actively traded tokens.


Data Payload

Field

Type

Description

Example

c

channel_type

string

Indicates the type of channel subscribed to.

G1

n

network_id

string

Identifier of the blockchain network. Check full list of ids here.

eth

ta

token_address

string

Contract address of the token on the blockchain.

0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

p

usd_price

float

Current token price in USD.

3639.78228844745

pp

usd_price_24h_change_percentage

float

Percentage change in token price over the last 24 hours.

3.566

m

usd_market_cap

float

Market capitalization in USD.

123

v

usd_24h_vol

float

24-hour trading volume in USD.

31233333.33

t

last_updated_at

integer

Timestamp 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": "berachain-bartio",
  "ta": "0x7507c1dc16935b82698e4c63f2746a2fcf994df8",
  "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"
}