Skip to main content
WSS
/
v1

Notes

  • Streams real-time prices for one or more coins by their unique Coin API IDs.
  • Specify preferred quote currencies via vs_currencies in the subscription data. See Supported Currencies for valid values. Defaults to USD.
  • Find a coin’s API ID on its CoinGecko page, via Coins List, or this Google Sheet.
  • Fields may return null when data is unavailable. Ensure your application handles null values.
Update Frequency:
As fast as ~10 seconds for large-cap and actively traded coins.

Data Payload

KeyFieldTypeDescriptionExample
cchannel_typestringChannel type subscribed to.C1
icoin_idstringCoin identifier.bitcoin
vsvs_currencystringTarget quote currency.usd
ppricenumberCurrent price in the specified vs_currency.61696.68
ppprice_24h_change_percentagenumberPrice change percentage over the last 24 hours.1.42
mmarket_capnumberMarket capitalization in the specified vs_currency.1236047139289.68
v24h_volnumber24-hour trading volume in the specified vs_currency.30595921115.54
tlast_updated_atintegerUNIX timestamp in seconds.1780839768

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
Output:
{
  "code": 3000,
  "message": "Connection established",
  "uuid": "YOUR_SESSION_ID"
}
{
  "type": "welcome",
  "sid": "YOUR_SESSION_ID"
}

2. Subscribe to CGSimplePrice

Input:
{"command":"subscribe","identifier":"{\"channel\":\"CGSimplePrice\"}"}
Output:
{
  "type": "confirm_subscription",
  "identifier": "{\"channel\":\"CGSimplePrice\"}"
}

3. Stream Price Data

Input:
{"command":"message","identifier":"{\"channel\":\"CGSimplePrice\"}","data":"{\"coin_id\":[\"bitcoin\"],\"vs_currencies\":[\"usd\"],\"action\":\"set_tokens\"}"}
Output:
{
  "code": 2000,
  "message": "Subscribed to bitcoin in usd"
}
Streaming output:
{
  "c": "C1",
  "i": "bitcoin",
  "vs": "usd",
  "p": 61696.67928656691,
  "pp": 1.4192404041947198,
  "m": 1236047139289.684,
  "v": 30595921115.53988,
  "t": 1780839768
}
Output keys may appear in any order.

4. Unsubscribe

Unsubscribe from a specific token:
{"command":"message","identifier":"{\"channel\":\"CGSimplePrice\"}","data":"{\"coin_id\":[\"bitcoin\"],\"action\":\"unset_tokens\"}"}
{
  "code": 2000,
  "message": "Unsubscription is successful for bitcoin"
}
Unsubscribe from the channel entirely:
{"command":"unsubscribe","identifier":"{\"channel\":\"CGSimplePrice\"}"}
{
  "code": 2000,
  "message": "Unsubscription is successful for all tokens"
}

Messages
x_cg_pro_api_key
type:httpApiKey

CoinGecko API key

Subscribe to CGSimplePrice
type:object

Subscribe to the CGSimplePrice channel

Stream CGSimplePrice Data
type:object

Set coins to receive price updates for

CGSimplePrice Update
type:object

Real-time coin price update from server