Skip to main content
The AllTick WebSocket API is used to receive real-time quote pushes. After a connection is established, the client sends a subscription request, and after the subscription succeeds, the server continuously pushes latest trade price and latest order book data. During the connection, heartbeats must be sent as required to avoid timeout disconnection.

Connection Addresses

Data TypeWebSocket Address
US stocks, Hong Kong stocks, A shares, and major index datawss://quote.alltick.co/quote-stock-b-ws-api?token=your_token
Forex, precious metals, cryptocurrencies, crude oil, CFD indices, and commoditieswss://quote.alltick.co/quote-b-ws-api?token=your_token
Each time a connection is established, your authentication token must be appended to the URL. After the connection succeeds, send latest trade price or latest order book subscription requests as needed.

Interface List

Latest Trade Price (Real-time Tick Data, Current Price, Latest Price) Batch Subscription

Subscribe to the latest trade price of products. After the subscription succeeds, trade data is pushed through protocol number 22998.

Latest Order Book (Real-time Tick-by-Tick Depth, Order Book) Subscription

Subscribe to the latest order book depth of products. After the subscription succeeds, order book data is pushed through protocol number 22999.

Heartbeat

Send a heartbeat every 10 seconds. If no heartbeat request is received within 30 seconds, the WebSocket connection will be disconnected.

Cancel Quote Subscription

Cancel all quote subscriptions, or cancel order book, trade, or exchange-rate subscriptions by type.

K-Line Push (Not Supported)

WebSocket does not support K-line push. K-lines can be polled or batch queried through HTTP interfaces.

WebSocket Request Example

View WebSocket request examples for Go, Java, PHP, and Python.

Protocol Number Overview

Protocol NumberDescription
22004 / 22005Latest trade price subscription request / response
22998Latest trade price push
22002 / 22003Latest order book subscription request / response
22999Latest order book push
22000 / 22001Heartbeat request / response
22006 / 22007Cancel quote subscription request / response

Usage Flow

  1. Select the stock or non-stock WebSocket address according to the product type.
  2. Append the token to the connection URL and establish the WebSocket connection.
  3. Send a latest trade price or latest order book subscription request.
  4. Send a heartbeat request every 10 seconds to keep the connection valid.
  5. Receive data pushed by the server and handle automatic reconnection according to business needs.
  6. When pushes are no longer needed, send a cancel quote subscription request.
For each WebSocket connection, every time a subscription request is sent, the backend overwrites the previous subscription request by default. When adding products, you need to resend the complete product list.