WSS:OnchainOHLCV

Subscribe to receive real-time OHLCV updates for pools, as seen on GeckoTerminal.com

This websocket channel allows you to subscribe to real-time OHLCV updates of a pool.

  • Lookup by Network + Pool Address
  • It will return Open, High, Low, Close price and Volume data the specified pool.

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

Tips: use this Rest API endpoint Top Pools by Token Address to obtain contract address of the most liquid pool.

Notes:

  • Interval options: 1s / 1m / 5m / 1h / 2h / 4h / 8h
  • You may stream the pool ohlcv data based on 'base' or 'quote' token of a pool.
  • Please note that your subscription quota is based on the number of unique data streams you request. Each unique combination of an interval and token for a given pool is considered a distinct subscription and will count towards your max subscription limit.

Data Payload

Field

Type

Description

Example

ch

channel_type

string

Indicates the type of channel subscribed to.

G3

n

network_id

string

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

eth

pa

pool_address

string

Contract address of the pool.

0x88e6a0c2dd6fcb..3f5640

to

token

string

'base' or 'quote' token

base

i

interval

string

Interval or resolution of the candle:
1s / 1m / 5m / 1h / 2h / 4h / 8h

1m

o

open

float

Open price in USD

3539

h

high

float

High price in USD

3541

l

low

float

Low price in USD

3530

c

close

float

Close price in USD

3531

v

volume

float

Volume in USD

323333

t

timestamp

integer

Opening timestamp of candle interval

1753803600

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

Input Example:

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

Output Example:

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

3. Stream OnchainOHLCV data

Input Example: (1 minute interval and base token of a pool)

  • Interval options: 1s / 1m / 5m / 1h / 2h / 4h / 8h
  • You may stream the pool ohlcv data of 'base' or 'quote' token.
{"command":"message","identifier":"{\"channel\":\"OnchainOHLCV\"}","data":"{\"network_id:pool_addresses\":[\"bsc:0x172fcd41e0913e95784454622d1c3724f546f849\"],\"interval\":\"1m\",\"token\":\"base\",\"action\":\"set_pools\"}"}

Output Example:

{
  "code": 2000,
  "message": "Subscription successful for bsc:0x172fcd41e0913e95784454622d1c3724f546f849:1m:base"
}

Output Example:

{
    "c": 0.999727235252031,
    "ch": "G3",
    "h": 0.999974654065411,
    "i": "1m",
    "l": 0.999353212178554,
    "n": "bsc",
    "o": 0.999570907451071,
    "pa": "0x172fcd41e0913e95784454622d1c3724f546f849",
    "t": 1753886760,
    "to": "base",
    "v": 63932.29404921795
}

The output keys will be in random order.



Tips:

Un-subscribe to stop streaming OnchainOHLCV data

Input Example: Unsubscribe for 1 specific pool data:

{"command":"message","identifier":"{\"channel\":\"OnchainOHLCV\"}","data":"{\"network_id:pool_addresses\":[\"eth:0xc7bbec68d12a0d1830360f8ec58fa599ba1b0e9b\"],\"interval\":\"1m\",\"token\":\"base\",\"action\":\"unset_pools\"}"}

Output Example:

{
  "code":2000,
  "message":"Unsubscription is successful for eth:0xc7bbec68d12a0d1830360f8ec58fa599ba1b0e9b:1m:base"
}

Input Example: Unsubscribe from OnchainOHLCV channel and all pools data:

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

Output Example:

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