Messages
{
"command": "<string>",
"identifier": "<string>"
}{
"command": "<string>",
"identifier": "<string>",
"data": "<string>"
}{
"c": "C1",
"i": "bitcoin",
"vs": "usd",
"p": 61696.68,
"pp": 1.42,
"m": 1236047139289.68,
"v": 30595921115.54,
"t": 1780839768
}Price
CGSimplePrice
Real-time coin price updates by CoinGecko coin IDs
WSS
/
v1
Notes
- Streams real-time prices for one or more coins by their unique Coin API IDs.
- Specify preferred quote currencies via
vs_currenciesin 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
nullwhen data is unavailable. Ensure your application handles null values.
Update Frequency:
As fast as ~10 seconds for large-cap and actively traded coins.
As fast as ~10 seconds for large-cap and actively traded coins.
Data Payload
| Key | Field | Type | Description | Example |
|---|---|---|---|---|
c | channel_type | string | Channel type subscribed to. | C1 |
i | coin_id | string | Coin identifier. | bitcoin |
vs | vs_currency | string | Target quote currency. | usd |
p | price | number | Current price in the specified vs_currency. | 61696.68 |
pp | price_24h_change_percentage | number | Price change percentage over the last 24 hours. | 1.42 |
m | market_cap | number | Market capitalization in the specified vs_currency. | 1236047139289.68 |
v | 24h_vol | number | 24-hour trading volume in the specified vs_currency. | 30595921115.54 |
t | last_updated_at | integer | UNIX 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{
"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\"}"}
{
"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\"}"}
{
"code": 2000,
"message": "Subscribed to bitcoin in usd"
}
{
"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"
}
{"command":"unsubscribe","identifier":"{\"channel\":\"CGSimplePrice\"}"}
{
"code": 2000,
"message": "Unsubscription is successful for all tokens"
}
Messages
{
"command": "<string>",
"identifier": "<string>"
}{
"command": "<string>",
"identifier": "<string>",
"data": "<string>"
}{
"c": "C1",
"i": "bitcoin",
"vs": "usd",
"p": 61696.68,
"pp": 1.42,
"m": 1236047139289.68,
"v": 30595921115.54,
"t": 1780839768
}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
Was this page helpful?
⌘I

