CGSimplePrice

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

This Websocket channel allows you to subscribe to real-time updates of price changes for token.

  • Lookup by Coin ID
  • It will return price & market data of the top pool of the specified token

Update Frequency: as fast as 8s, for large cap and actively traded coins.


Data Payload

Field

Type

Description

Example

c

channel_type

string

Indicates the type of channel subscribed to.

C1

i

coin_id

string

Identifier of the coins. Check full list of ids here.

ethereum
usd-coin

p

usd_price

string

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 - CGSimplePrice

Input Example:

{"command":"subscribe","identifier":"{\"channel\":\"CGSimplePrice\"}"}

Output Example:

{"type":"confirm_subscription","identifier":"{\"channel\":\"CGSimplePrice\"}"}

3. Stream CGSimplePrice

Input Example:

{"command":"message","identifier":"{\"channel\":\"CGSimplePrice\"}","data":"{\"coin_id\":[\"ethereum\",\"bitcoin\"],\"action\":\"set_tokens\"}"}

Output Example:

{
    "code": 2000,
    "message": "Subscription is successful for ethereum"
}

Output Example:

{
    "c": "C1",
    "i": "ethereum",
    "m": 312938652962.8005,
    "p": 2591.080889351465,
    "pp": 1.3763793110454519,
    "t": 1747808150.269067,
    "v": 20460612214.801384
}

The output keys will be in random order.




Tips:

Un-subscribe to stop streaming CGSimplePrice data

Input Example: Unsubscribe for 1 specific token data:

{"command":"message","identifier":"{\"channel\":\"CGSimplePrice\"}","data":"{\"coin_id\":[\"ethereum\"],\"action\":\"unset_tokens\"}"}

Output Example:

{
    "code": 2000,
    "message": "Unsubscription is successful for ethereum"
}

Input Example: Unsubscribe from CGSimplePrice channel and all token data:

{"command":"unsubscribe","identifier":"{\"channel\":\"CGSimplePrice\"}"}

Output Example:

{
    "code": 2000,
    "message": "Unsubscription is successful for all tokens"
}