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

Endpoint Details

  • URL: wss://api.mobula.io
  • Event Type: funding

Subscription Format

Subscribe to funding rates for specific trading pairs:
{
  "type": "funding",
  "authorization": "YOUR_API_KEY",
  "payload": {
    "symbol": "BTC",
    "quote": "USDT",
    "interval": 10,
    "exchange": "binance,bybit,hyperliquid",
    "subscriptionId": "funding-feed-1",
    "subscriptionTracking": true
  }
}

Parameters

  • symbol (required): Trading symbol (e.g., "BTC", "ETH")
  • quote (optional): Quote asset (e.g., "USDT", "USD"). Defaults depend on exchange pairs
  • exchange (optional): Comma-separated list of exchanges - binance, bybit, deribit, okx, hyperliquid
  • interval (optional): Refresh interval in seconds for updates
  • 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
Supported Exchanges: Binance, Bybit, Deribit, OKX, Hyperliquid

Hyperliquid DEX (HIP3) Usage

Funding rates from Hyperliquid are available only for HIP3 perpetuals:
  • Prefix the symbol with dex: (e.g., "dex:BTC", "dex:XYZ100")
  • Include exchange: "hyperliquid" in the payload
Example:
{
  "type": "funding",
  "authorization": "YOUR_API_KEY",
  "payload": {
    "symbol": "dex:XYZ100",
    "exchange": "hyperliquid",
    "subscriptionTracking": true
  }
}

Response Format

Each funding rate update includes data from all requested exchanges:
{
  "queryDetails": {
    "base": "BTC",
    "quote": "USDT"
  },
  "subscriptionId": "funding-feed-1",
  "timestamp": 1756194263149,
  "sequence": 1,
  "binanceFundingRate": {
    "symbol": "BTCUSDT",
    "fundingTime": 1756166400000,
    "fundingRate": 0.00004522,
    "marketPrice": "110064.58160507",
    "epochDurationMs": 28800000,
    "fundingRateCap": 0.3,
    "fundingRateFloor": -0.3
  },
  "bybitFundingRate": {
    "symbol": "BTCUSDT",
    "fundingTime": 1756166400000,
    "fundingRate": 0.0001,
    "epochDurationMs": 28800000
  },
  "hyperliquidFundingRate": {
    "symbol": "BTC",
    "fundingTime": 1756188000000,
    "fundingRate": 0.0000125,
    "marketPrice": 110301,
    "epochDurationMs": 3600000
  },
  "okxFundingRate": {
    "symbol": "BTC-USDT-SWAP",
    "fundingTime": 1756195200000,
    "fundingRate": 0.0001,
    "epochDurationMs": 28800000
  }
}

Implementation Example

const socket = new WebSocket("wss://api.mobula.io");

socket.addEventListener("open", () => {
  socket.send(JSON.stringify({
    type: "funding",
    authorization: "YOUR_API_KEY",
    payload: {
      symbol: "BTC",
      quote: "USDT",
      interval: 10,
      exchange: "binance,bybit,hyperliquid",
      subscriptionTracking: true
    }
  }));
});

socket.addEventListener("message", (event) => {
  const data = JSON.parse(event.data);
  
  // Process funding rate updates
  if (data.binanceFundingRate) {
    console.log(`Binance Funding Rate: ${data.binanceFundingRate.fundingRate}`);
  }
  
  if (data.hyperliquidFundingRate) {
    console.log(`Hyperliquid Funding Rate: ${data.hyperliquidFundingRate.fundingRate}`);
  }
});

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 Funding Streams

To unsubscribe from all funding streams while keeping other stream types active:
{
  "type": "unsubscribe",
  "authorization": "YOUR_API_KEY",
  "payload": {
    "type": "funding"
  }
}
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.