Kana Perps Websocket API

Overview of supported trading markets and installation prerequisites for using the Websocket API.

Websocket Overview

Supported Markets

This Websocket API provides information for the following trading markets:

Asset

Market ID

Description

APT/USDC

66

Aptos-based trading market.

BTC/USDC

67

Bitcoin-based trading market.

ETH/USDC

68

Ethereum-based trading market.

Prerequisites

Install Required Packages

Before you begin, install the following dependencies:

npm install ws

This documentation explains how to connect and receive data from the WebSocket streams: You can connect order book stream using client initialization code in TypeScript.

Endpoint URL :

Example Request: wss://perps-sdk-ws.kanalabs.io/wsOrderBook/marketId=66 Here is the steps to initialize the client code in typescript : Example code to fetch the Order Book Client Initialization Code:

import WebSocket from 'ws';

const marketId = 'your_market_id';

const ws = new WebSocket(`wss://perps-sdk-ws.kanalabs.io/wsOrderBook?marketId=${marketId}`);

ws.on('open', () => {
    console.log('[client] Connected to the server');
    ws.send('Request data from endpoint');
});

ws.on('message', (data) => {
    console.log(`Received a message from the server:, ${data}`);
});

ws.on('close', () => {
    console.log('[client] Disconnected from the server');
});

Last updated