This endpoint is only available to Growth and Enterprise plans.

Product demo

Endpoint details

  • URL: wss://production-api.mobula.io
  • Message (string):
{
    "type": "ohlcv",
    "authorization": "YOUR_API_KEY",
    "payload": {
        "address": "0x123456789",
        "chainId": "evm:1",
        "period": "1h",
    }
};

Parameters

  • apiKey: your Mobula API key (you can get one here)
  • address: the address of the pool you want to get OHLCV data for
  • chainId: details here
  • period: the period of the OHLCV data you want to get (1s, 1min, 5min, 15min, 1h, 4h, 1d, 1w, 1M)
  • subscriptionId (optional): A unique ID for your WebSocket connection. If not provided, it is automatically generated by the server.
  • subscriptionTracking (optional, default: false): Set this to true to include the subscriptionId and additional connection details in the response logs. Helpful for debugging and managing multiple active streams.

Implementation example

Let’s take a look at:
const socket = new WebSocket("wss://production-api.mobula.io");

socket.addEventListener("open", () => {
  socket.send(`{
    "type": "ohlcv",
    "authorization": "YOUR_API_KEY",
    "payload": {
      "address": "0x123456789",
      "chainId": "evm:1",
      "period": "1h",
    }
}`);
});

socket.addEventListener("message", (event) => {
  const data = JSON.parse(event.data);

  console.log(data);

  // ...
});

// No need to close the socket, it will close automatically.
You can use the Network tab in your browser to see the WSS requests.

Unsubscribing from the stream

You can unsubscribe from the stream by sending an unsubscribe message:
  • Unsubscribe from all active streams: Send an empty payload as shown above. This will terminate all active subscriptions associated with the current WebSocket connection.

{
  "type": "unsubscribe",
  "authorization": "API-KEY", 
  "payload": {},
};
 
  • Unsubscribe from a specific subscriptionId: Include the relevant subscriptionId in the payload:

{
  "type": "unsubscribe",
  "authorization": "API-KEY",
  "payload": {
	  "subscriptionId": "your-subscription-id"
   }
};
If you did not provide a subscriptionId when subscribing, one is generated automatically. To retrieve it, set “subscriptionTracking”: “true” in the subscription payload. Otherwise, it will not be returned in the response.
  • Unsubscribe from a specific stream type: To unsubscribe all streams of a given type (e.g., all “pair”, “market” streams):
{
  "type": "unsubscribe",
  "authorization": "API-KEY",
  "payload": {
    "type": "ohlcv"
   }
}
After sending the unsubscribe payload, you will receive a message with the following payload:
{ 
    data: 'Successfully unsubscribed from stream' 
}
Can’t find what you’re looking for? Reach out to us, response times < 1h.