# Basic Information

# Introduction

· Your application is capable of establishing long connections with servers, selecting subscribed channels and topics, and receiving the latest messages pushed by the server;

# 1. Channels

There are public channels and private channels, each containing different topics. Resources and permissions vary for each channel;

· Public Channels (PUBLIC): Typically consist of publicly available data such as market trends, order books, real-time transactions, and more;

· Private Channels (PRIVATE): Usually contain personalized user data such as asset change notifications, transaction messages, etc. Access to these channels is subject to resource and permission verification based on the APP key;

# 2. Topics

To cater to different business modules, Starex Open WebSocket provides a wide range of WebSocket topics for developers to subscribe to. These topics are continually updated to meet various business needs;

# 3 . Topic Parameters

Each topic subscription will have different parameters, allowing developers to engage in various business activities;

# Integration Guide

# 1 . Handshake

​ · baseURL

ws://api.starex.com/ws

​ · During the handshake process, it's also necessary to include authentication parameters in the request header. This typically includes STAREX-APP-KEY-V1、STAREX-TIMESTAMP、STAREX-SIGNATURE ;

​ · If your application doesn't support WebSocket request headers, you can also pass authentication parameters within the URL parameters;

​ · Upon receiving a server response (httpStatus: 101), it indicates a successful handshake. The server will then upgrade your request to the WebSocket protocol;

​ · After a successful handshake, you have established a persistent connection with the Starex Open WebSocket server. You can send commands to the server by sending messages, and the server can push the latest messages from your subscribed topics by pushing messages to you as well;

# 2 . Initiating Connection

Sending Messages to the WS Server

{"method":"CONNECT"}

Receiving Server Responses

{"e":"CONNECTED"}

This indicates a successful connection;

# 3 . Subscribing

You need to subscribe to specific channels for the server to actively push messages to you;

# Limitations

# Connection Limitations

Each App Key is allowed to maintain a maximum of 5 connections;

# Subscription Limitations

Each connection is allowed to subscribe to a maximum of 50 topics. Please allocate them wisely;

# Maintaining the Connection

Every 30 minutes, the server will send a PING heartbeat to the client. The server expects the client to respond with a PONG heartbeat. If there is no response within 10 seconds, the server will actively disconnect the connection;

# Message Format

# Request Message

Parameters Type Is it mandatory Description
method MethodTypeEnum Yes Command Type
subject String No Topic is mandatory when the method is set to subscribe (SUBSCRIBE) or unsubscribe (UNSUBSCRIBE)

MethodTypeEnum

Type Description
CONNECT Connect
DISCONNECT Disconnect
SUBSCRIBE Subscribe
UNSUBSCRIBE Unsubscribe
PONG Heartbeat is usually when the server initiates a PING to the client, expecting a PONG response within a specified time to keep the connection alive

Example

//Initiating a Connection
{"method":"CONNECT"}
//Subscribe to BTC/USDT spot trade
{"method":"SUBSCRIBE","subject":"PUBLIC@SPOT_TRADE?BTC/USDT"}

# Message Push

Parameters Type Description
e EventTypeEnum Push Event Type (event)
s String Topic (subject), push messages usually have topics that clients can use to differentiate between different business aspects
d Object Data, depending on the topic, the data varies. Refer to the topic messages for specific details;

EventTypeEnum

Type Description
PING Heartbeat, typically initiated by the server towards the client
CONNECTED Connected
ERROR Error

Example

//Initiating a Connection
{"e":"CONNECTED"}
//Initiating Heartbeat
{"e":"PING"}