Messages
{
"action": "<string>",
"chain_id": 123,
"dataset_id": "<string>",
"params": {
"base_token_address": "<string>",
"quote_token_address": "<string>",
"aggregation_interval": "<string>"
}
}{
"action": "<string>",
"chain_id": 123,
"dataset_id": "<string>"
}No examples foundNo examples foundNo examples foundPricing Suite - Crypto
Spot OHLC
Subscribe to real-time OHLC candlestick bars from on-chain AMM swap aggregates (0404).
WSS
/
Overview
- Dataset ID:
0404 - Token-to-Token OHLC - Description: Time-bucketed OHLC bars (1m..1d) per pool and token pair direction.
- Sample: Hugging Face Sample
Subscription Parameters
ERC-20 contract address for the base asset (hex string, 20 bytes, no
0x prefix).ERC-20 contract address for the quote asset (hex string, 20 bytes, no
0x prefix).Candle width, expressed as an ISO-8601 duration shorthand (
1m, 5m, 1h, 1d). Default is 1m.Message Fields (data)
Top-level fields: chain_id, dataset_id, is_reorg, data (object). The data object mirrors b0404_token_to_token_prices_ohlc_v1:
BYTEA — Pool id (hex).INTEGERINTEGERTIMESTAMPTZ — Inclusive UTC bucket start.TIMESTAMPTZ — Exclusive UTC bucket end (bucket_start + bucket_seconds).INTEGERBYTEABYTEANUMERIC(78,18)NUMERIC(78,18)NUMERIC(78,18)NUMERIC(78,18)NUMERIC(78,0) — Sum of raw UInt256 amountIn values.NUMERIC(78,18) — Decimal-adjusted token_in volume; null if decimals unknown.NUMERIC(78,0) — Sum of raw UInt256 amountOut values.NUMERIC(78,18) — Decimal-adjusted token_out volume; null if decimals unknown.BIGINTBYTEABYTEA[] — Optional parent lineage references.TIMESTAMPTZTIMESTAMPTZSubscription Example
# Use wscat to connect and subscribe
wscat -c wss://api.blockdb.io/v1/evm/ \
-H "Authorization: Bearer $BLOCKDB_API_KEY" \
-x '{"action": "subscribe", "dataset_id": "0404", "chain_id": 1, "params": {"base_token_address": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "quote_token_address": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "aggregation_interval": "1m"}}'
#include <libwebsockets.h>
#include <string.h>
#include <stdio.h>
static int callback_blockdb(struct lws *wsi, enum lws_callback_reasons reason,
void *user, void *in, size_t len) {
switch (reason) {
case LWS_CALLBACK_CLIENT_ESTABLISHED:
lws_callback_on_writable(wsi);
break;
case LWS_CALLBACK_CLIENT_RECEIVE:
printf("Received: %s\n", (char *)in);
break;
case LWS_CALLBACK_CLIENT_WRITEABLE: {
unsigned char buf[LWS_PRE + 1024];
unsigned char *p = &buf[LWS_PRE];
size_t n = sprintf((char *)p, "{\"action\": \"subscribe\", \"dataset_id\": \"0404\", \"chain_id\": 1, \"params\": {\"base_token_address\": \"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", \"quote_token_address\": \"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\", \"aggregation_interval\": \"1m\"}}");
lws_write(wsi, p, n, LWS_WRITE_TEXT);
break;
}
}
return 0;
}
using System;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
class Program {
static async Task Main() {
using var ws = new ClientWebSocket();
ws.Options.SetRequestHeader("Authorization", $"Bearer {Environment.GetEnvironmentVariable("BLOCKDB_API_KEY")}");
await ws.ConnectAsync(new Uri("wss://api.blockdb.io/v1/evm/"), CancellationToken.None);
var subMsg = "{\"action\": \"subscribe\", \"dataset_id\": \"0404\", \"chain_id\": 1, \"params\": {\"base_token_address\": \"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\", \"quote_token_address\": \"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\", \"aggregation_interval\": \"1m\"}}";
await ws.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes(subMsg)), WebSocketMessageType.Text, true, CancellationToken.None);
var buffer = new byte[1024 * 4];
while (ws.State == WebSocketState.Open) {
var result = await ws.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
Console.WriteLine(Encoding.UTF8.GetString(buffer, 0, result.Count));
}
}
}
import websocket
import json
import os
def on_message(ws, message):
print(f"Received: {message}")
def on_open(ws):
msg = {
"action": "subscribe",
"dataset_id": "0404",
"chain_id": 1,
"params": {
"base_token_address": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"quote_token_address": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"aggregation_interval": "1m"
}
}
ws.send(json.dumps(msg))
ws = websocket.WebSocketApp(
"wss://api.blockdb.io/v1/evm/",
header={"Authorization": f"Bearer {os.getenv('BLOCKDB_API_KEY')}"},
on_message=on_message,
on_open=on_open
)
ws.run_forever()
const WebSocket = require('ws');
const ws = new WebSocket('wss://api.blockdb.io/v1/evm/', {
headers: { 'Authorization': `Bearer ${process.env.BLOCKDB_API_KEY}` }
});
ws.on('open', () => {
ws.send(JSON.stringify({
action: 'subscribe',
dataset_id: '0404',
chain_id: 1,
params: {
base_token_address: "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
quote_token_address: "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
aggregation_interval: "1m"
}
}));
});
ws.on('message', (data) => {
console.log('Received:', JSON.parse(data));
});
package main
import (
"fmt"
"log"
"net/http"
"os"
"github.com/gorilla/websocket"
)
func main() {
header := http.Header{"Authorization": []string{"Bearer " + os.Getenv("BLOCKDB_API_KEY")}}
c, _, err := websocket.DefaultDialer.Dial("wss://api.blockdb.io/v1/evm/", header)
if err != nil {
log.Fatal("dial:", err)
}
defer c.Close()
sub := `{"action": "subscribe", "dataset_id": "0404", "chain_id": 1, "params": {"base_token_address": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "quote_token_address": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "aggregation_interval": "1m"}}`
err = c.WriteMessage(websocket.TextMessage, []byte(sub))
if err != nil {
log.Fatal("write:", err)
}
for {
_, message, err := c.ReadMessage()
if err != nil {
log.Fatal("read:", err)
}
fmt.Printf("Received: %s\n", message)
}
}
Response Example
{
"chain_id": 1,
"dataset_id": "0404",
"is_reorg": false,
"data": {
"pool_uid": "88e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000",
"exchange_id": 1,
"type_id": 201,
"bucket_start": "2025-11-11T00:00:00.000Z",
"bucket_end": "2025-11-11T00:01:00.000Z",
"bucket_seconds": 60,
"token_in": "c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"token_out": "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"open": "3010.112233445566778899",
"high": "3033.998877665544332211",
"low": "3008.001122334455667788",
"close": "3025.219821481234567890",
"volume_in_raw": "420000000000000000000",
"volume_in": "420.000000000000000000",
"volume_out_raw": "1269000000000",
"volume_out": "1269000.000000000000000000",
"trades_count": 128,
"_tracing_id": "0404000000000000000000000000000000000001",
"_parent_tracing_ids": null,
"_created_at": "2025-11-11T00:01:05.000Z",
"_updated_at": "2025-11-11T00:01:05.000Z"
}
}
Messages
{
"action": "<string>",
"chain_id": 123,
"dataset_id": "<string>",
"params": {
"base_token_address": "<string>",
"quote_token_address": "<string>",
"aggregation_interval": "<string>"
}
}{
"action": "<string>",
"chain_id": 123,
"dataset_id": "<string>"
}No examples foundNo examples foundNo examples foundsubscribe
type:object
unsubscribe
type:object
subscribe_response
type:object
unsubscribe_response
type:object
update
type:object
Last modified on May 27, 2026
Was this page helpful?
⌘I