---
title: "Binance WebSocket Public Usdm Funding Example | Siebly"
description: "Binance websocket public usdm funding JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/Binance/WebSockets/Public/ws-public-usdm-funding"
robots: "index,follow"
---

# Binance WebSocket Public Usdm Funding Example

Binance websocket public usdm funding JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [Binance](/examples/Binance) / [WebSockets](/examples/Binance/WebSockets) / [Public](/examples/Binance/WebSockets/Public) / [ws-public-usdm-funding.ts](/examples/Binance/WebSockets/Public/ws-public-usdm-funding)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Binance/WebSockets/Public/ws-public-usdm-funding.ts)

[Open the Binance JavaScript SDK guide](/sdk/binance/javascript)

## ws-public-usdm-funding.ts

```typescript
import {
  DefaultLogger,
  isWsFormattedMarkPriceUpdateArray,
  WebsocketClient,
} from 'binance';

(async () => {
  const logger = {
    ...DefaultLogger,
    // trace: () => {},
  };

  const wsClient = new WebsocketClient(
    {
      // api_key: key,
      // api_secret: secret,
      beautify: true,
    },
    logger,
  );

  wsClient.on('formattedMessage', (data) => {
    if (isWsFormattedMarkPriceUpdateArray(data)) {
      console.log('all mark price evt received ');

      const mapped = data
        .map((r) => {
          return {
            ...r,
            // value is in decimal, multiply by 100 to get percent value
            fundingRate: (Number(r.fundingRate) * 100).toFixed(2),
          };
        })
        .sort((a, b) => a.symbol.localeCompare(b.symbol));

      // log table sorted alphabetically by symbol
      console.table(mapped);
      return;
    }

    console.log('log unhandled formatted msg: ', data);
  });

  wsClient.on('open', (data) => {
    console.log('connection opened open:', data.wsKey, data.wsUrl);
  });

  // response to command sent via WS stream (e.g LIST_SUBSCRIPTIONS)
  wsClient.on('response', (data) => {
    console.log('log response: ', JSON.stringify(data, null, 2));
  });
  wsClient.on('reconnecting', (data) => {
    console.log('ws automatically reconnecting.... ', data?.wsKey);
  });
  wsClient.on('reconnected', (data) => {
    console.log('ws has reconnected ', data?.wsKey);
  });

  wsClient.subscribeAllMarketMarkPrice('usdm', 1000);
})();
```
