WebSocket

Connect WebSocket

Set up FastConnect WebSocket connection and general request rules.

Overview

FastConnect WebSocket is used to stream trading and market data in real time. Before connecting, the client must obtain a token from the getAccessToken API.

Connection endpoint

wss://stream.ssi.com.vn

Usage requirements

  • Access token is still valid.
  • The client keeps heartbeat throughout the connection session.
  • After reconnecting, the client must subscribe again to required topics.

Authentication and connection

The document describes how to obtain a token from client_id, api_key, api_secret via the auth API. Then use that token to connect to the stream.

{
  "client_id": "666666",
  "api_key": "<api-key>",
  "api_secret": "<api-secret>",
  "access_token": "<access-token>"
}

General WebSocket request structure

Every message sent via WebSocket follows this general structure:

{
  "method": "SUBSCRIBE|UNSUBSCRIBE|LIST_SUBSCRIPTION|PING|PONG",
  "channel": "TRADING|DATA|HEARTBEAT",
  "topics": ["trade.SSI@tick", "trade.SSI@1m", "room.*"]
}

List subscription

The client can check current scopes with this request:

{
  "method": "LIST_SUBSCRIPTION"
}

The response returns access scopes by trading/data groups.

Main event types

  • connect
  • heartbeat
  • orderEvent
  • orderMatchEvent
  • clientPortfolioEvent
  • fcoEvent — conditional order (FCO) event
  • trade
  • quote
  • room
  • put
  • oddlot
  • market
  • trade.index — realtime index value
  • indexsummary — index summary information

On this page