Skip to main content
WSS
/
v1
Messages
x_cg_pro_api_key
type:httpApiKey

Insert CoinGecko Pro API key to establish WebSocket connection

Subscribe to CGSimplePrice
type:object

Subscribe to the CGSimplePrice channel

Stream CGSimplePrice Data
type:object

Set coins to receive price updates

CGSimplePrice Update
type:object

Real-time price update

This WebSocket channel allows you to subscribe to real-time updates of price changes for tokens.
  • It will return the prices of one or more coins by using their unique Coin API IDs
  • You may specify preferred exchange rate(s) using vs_currencies in the subscription data. Choose from /simple/supported_vs_currencies. If not specified, data is returned in USD by default.
  • You may obtain the coin ID (API ID) via several ways:
    • Refer to respective coin page and find ‘API ID’.
    • Refer to /coins/list endpoint.
    • Refer to Google Sheets here.
Update Frequency: as fast as ~10s, for large cap and actively traded coins.

Data Payload

FieldTypeDescriptionExample
cchannel_typestringIndicates the type of channel subscribed to.C1
icoin_idstringIdentifier of the coins. Check full list of IDs here.ethereum, usd-coin
vsvs_currencystringThe target currency for price data. Defaults to usd if vs_currencies is not specified.usd, eur
ppricefloatCurrent token price in the specified vs_currency.3639.78228844745
ppprice_24h_change_percentagefloatPercentage change in token price over the last 24 hours.3.566
mmarket_capfloatMarket capitalization in the specified vs_currency.123
v24h_volfloat24-hour trading volume in the specified vs_currency.31233333.33
tlast_updated_atintegerTimestamp 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\"],\"vs_currencies\":[\"usd\",\"eur\"],\"action\":\"set_tokens\"}"}
Output Example:
{
    "code": 2000,
    "message": "Subscription is successful for ethereum"
}
Output Example:
{
    "c": "C1",
    "i": "ethereum",
    "vs": "usd",
    "m": 312938652962.8005,
    "p": 2591.080889351465,
    "pp": 1.3763793110454519,
    "t": 1747808150.269067,
    "v": 20460612214.801384
}
The output keys will be in random order.

Tips:

Unsubscribe 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"
}