---
title: "Coinbase Cb Intx WebSocket JavaScript SDK Example | Siebly"
description: "Coinbase Institutional CBInternational Exchange cb intx websocket JavaScript example for the Siebly Coinbase SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/Coinbase/Institutional/CBInternationalExchange/cb-intx-ws"
robots: "index,follow"
---

# Coinbase Cb Intx WebSocket JavaScript SDK Example

Coinbase Institutional CBInternational Exchange cb intx websocket JavaScript example for the Siebly Coinbase SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [Coinbase](/examples/Coinbase) / [Institutional](/examples/Coinbase/Institutional) / [CBInternationalExchange](/examples/Coinbase/Institutional/CBInternationalExchange) / [cb-intx-ws.ts](/examples/Coinbase/Institutional/CBInternationalExchange/cb-intx-ws)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Coinbase/Institutional/CBInternationalExchange/cb-intx-ws.ts)

[Open the Coinbase JavaScript SDK guide](/sdk/coinbase/javascript)

## cb-intx-ws.ts

```typescript
import 'dotenv/config';

import { WebsocketClient, WsTopicRequest } from 'coinbase-api';

const client = new WebsocketClient(
  {
    apiKey: process.env.CB_INTX_API_KEY!,
    apiSecret: process.env.CB_INTX_API_SECRET!,
    apiPassphrase: process.env.CB_INTX_API_PASSPHRASE!,
  },
  // logger,
);

client.on('open', (data) => {
  console.log('open: ', data?.wsKey);
});

// Data received
client.on('update', (data) => {
  console.info(new Date(), 'data received: ', JSON.stringify(data));
});

// Something happened, attempting to reconnect
client.on('reconnect', (data) => {
  console.log('reconnect: ', data);
});

// Reconnect successful
client.on('reconnected', (data) => {
  console.log('reconnected: ', data);
});

// Connection closed. If unexpected, expect reconnect -> reconnected.
client.on('close', (data) => {
  console.error('close: ', data);
});

// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
client.on('response', (data) => {
  console.info('response: ', JSON.stringify(data, null, 2));
});

client.on('exception', (data) => {
  console.error('exception: ', data);
});

const OrderbookSubscribeRequest: WsTopicRequest = {
  topic: 'LEVEL1', // ws topic
  /**
   * Anything in the payload will be merged into the subscribe "request",
   * allowing you to send misc parameters supported by the exchange (such as `product_ids: string[]`)
   */
  payload: {
    product_ids: ['BTC-PERP'],
  },
};
client.subscribe(OrderbookSubscribeRequest, 'internationalMarketData');
```
