Spot

This document outlines how to establish and maintain a WebSocket connection for Spot trading via two supported authentication methods: Token and API Key.

Token Connection

1. Overview

  • The client sends a WebSocket request with a token in the header.

  • A subscription message must be sent to receive real-time data upon successful connection.

2. Connection Details

  • Request Path:

    wss://ws2.coinlocally.com/spotws_user/userData/ws

3. Request Header

Parameter Name
Type
Required
Description

token

string

Yes

Token generated after login

4. Subscription Message Format

{
  "event": "sub",
  "token": "<your_token>"
}

API Key Connection

1. Overview

  • The client sends a WebSocket request with an api-key in the header.

  • A subscription message must be followed to start receiving real-time messages.

2. Connection Details

  • Request Path:

3. Request Header

Parameter Name
Type
Required
Description

api-key

string

Yes

API key generated on the frontend

4. Subscription Message Format

Receiving Messages

1. Connection Responses

  • Connect Success: "connect success"

  • Subscribe Success: "sub success"

2. Message Format

  • Messages are compressed in binary format using GZIP.

  • Decompress using your language's GZIP library.

Example (Base64 Encoded, Gzipped):

Decompressed Message (Example):


Event Types

1. Account Update: outboundAccountPosition

2. Order Status Update: executionReport

  • Order Status (X):

    • FILLED: Fully filled

    • PART_FILLED: Partially filled

    • CANCELED: Cancelled successfully

    • PENDING_CANCEL: Cancellation in progress

3. System Close Notification

V. Heartbeat Mechanism

  • Client must send a ping every 30 seconds:

  • Server responds with pong:

  • The connection will be closed if no ping is received in 40 seconds.

Last updated