Skip to main content
This endpoint is only available to Growth and Enterprise plans.

Product demo

Endpoint Details

  • URL: wss://production-api.mobula.io
  • Event Type: ohlcv

Pool Mode Subscription

Subscribe to OHLCV data for a specific pool:
{
  "type": "ohlcv",
  "authorization": "YOUR_API_KEY",
  "payload": {
    "address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
    "chainId": "evm:1",
    "period": "1h",
    "subscriptionTracking": true
  }
}

Asset Mode Subscription

Subscribe to OHLCV data for a specific token:
{
  "type": "ohlcv",
  "authorization": "YOUR_API_KEY",
  "payload": {
    "asset": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "chainId": "evm:1",
    "period": "1h",
    "subscriptionTracking": true
  }
}

Parameters

  • address (conditional): Pool address for pool mode - required if not using asset
  • asset (conditional): Token address for asset mode - required if not using address
  • chainId (required): Blockchain identifier - See supported chains
  • period (required): Candlestick timeframe - 1s, 1min, 5min, 15min, 1h, 4h, 1d, 1w, 1M
  • subscriptionId (optional): Unique identifier for your WebSocket connection. Auto-generated if not provided
  • subscriptionTracking (optional, default: false): Include subscription details in response logs for debugging
You can use either pool mode (with address) or asset mode (with asset), but not both simultaneously.

Implementation Example

Pool Mode Example:
const socket = new WebSocket("wss://production-api.mobula.io");

socket.addEventListener("open", () => {
  socket.send(JSON.stringify({
    type: "ohlcv",
    authorization: "YOUR_API_KEY",
    payload: {
      address: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
      chainId: "evm:1",
      period: "1h",
      subscriptionTracking: true
    }
  }));
});

socket.addEventListener("message", (event) => {
  const data = JSON.parse(event.data);
  
  // Process OHLCV data
  console.log("OHLCV update:", data);
});

socket.addEventListener("error", (error) => {
  console.error("WebSocket error:", error);
});

socket.addEventListener("close", () => {
  console.log("WebSocket connection closed");
});
You can use the Network tab in your browser to see the WebSocket requests and responses in real-time.

Unsubscribing from the Stream

Unsubscribe from All Streams

To terminate all active subscriptions on the current WebSocket connection:
{
  "type": "unsubscribe",
  "authorization": "YOUR_API_KEY",
  "payload": {}
}

Unsubscribe from Specific Subscription

To unsubscribe from a specific subscription using its ID:
{
  "type": "unsubscribe",
  "authorization": "YOUR_API_KEY",
  "payload": {
    "subscriptionId": "your-subscription-id"
  }
}

Unsubscribe from All OHLCV Streams

To unsubscribe from all OHLCV streams while keeping other stream types active:
{
  "type": "unsubscribe",
  "authorization": "YOUR_API_KEY",
  "payload": {
    "type": "ohlcv"
  }
}
If you didn’t provide a subscriptionId when subscribing, one is auto-generated. To retrieve it, set "subscriptionTracking": true in the subscription payload.

Support

Can’t find what you’re looking for? Reach out to us, response times < 1h.