Skip to main content

Interface Description

This interface supports batch subscription to the latest trade price of products (real-time tick-by-tick data, also the current price and latest price). It does not support historical trade prices (historical tick-by-tick data). For each WebSocket connection, every time this request is sent, the backend overwrites the previous subscription request by default. For example, if you initially subscribed to products A, B, and C, and want to add E, F, and G, you need to resend A, B, C, E, F, and G together. After the subscription succeeds, data will be pushed. Notes:
  1. After a subscription succeeds once, you do not need to frequently initiate subscription requests again. You must send a heartbeat every 10 seconds, and the interface will push data in real time. If no heartbeat request is received within 30 seconds, it will be considered timed out and the requester’s WebSocket connection will be disconnected.
  2. During integration, customers can add automatic reconnection logic to ensure the connection can automatically reconnect after disconnection caused by network or other reasons.

Interface Limitations

  1. Be sure to read: WebSocket Interface Limitations
  2. Be sure to read: Error Code Description

API Endpoints

1. US Stocks, Hong Kong Stocks, A Shares, and Major Index Data API Endpoint:
  • Base Path: /quote-stock-b-ws-api
  • Full URL: wss://quote.alltick.co/quote-stock-b-ws-api
2. Forex, Precious Metals, Cryptocurrencies, Crude Oil, CFD Indices, and Commodities API Endpoint:
  • Base Path: /quote-b-ws-api
  • Full URL: wss://quote.alltick.co/quote-b-ws-api

Request Examples

1. Request example for US Stocks, Hong Kong Stocks, A Shares, and Major Index Data: Each time a connection is established, your authentication token must be appended to the URL as follows: wss://quote.alltick.co/quote-stock-b-ws-api?token=your_token After the connection succeeds, you can subscribe to specific stock market data as needed. For detailed calling methods, refer to the documentation below. 2. Request example for Forex, Precious Metals, Cryptocurrencies, Crude Oil, CFD Indices, and Commodities: Each time a connection is established, your authentication token must be appended to the URL as follows: wss://quote.alltick.co/quote-b-ws-api?token=your_token After the connection succeeds, you can subscribe to specific forex, cryptocurrency, precious metals, and commodity data as needed. For detailed calling methods, refer to the documentation below.

Request - Protocol Number: 22004

JSON Definition

FieldNameTypeRequiredDescription
cmd_idProtocol numberintegerYesThe tick subscription request protocol number is fixed: 22004
seq_idResponse IDintegerYesSubscription request identifier, returned in the response. Custom value; can be repeated for each request.
traceTraceable IDstringYesTraceable ID for request log information. Custom value; must not be repeated for each request.
symbol_listProduct listarrayYesSee the symbol definition below for the specific format.

Symbol Definition

FieldNameTypeRequiredDescription
codeCodestringYesFor details, view the code list: Click the code list
Note: The code value must match the case of the code in the product list.

Data Structure (JSON)

{
  "cmd_id": 22004,
  "seq_id": 123,
  "trace": "3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
  "data": {
    "symbol_list": [
      {
        "code": "BTCUSDT"
      },
      {
        "code": "ETHUSDT"
      }
    ]
  }
}

Response - Protocol Number: 22005

Data Structure (JSON)

{
  "ret": 200,
  "msg": "ok",
  "cmd_id": 22005,
  "seq_id": 123,
  "trace": "3baaa938-f92c-4a74-a228-fd49d5e2f8bc-1678419657806",
  "data": {}
}

Push - Protocol Number: 22998

Data Definition

FieldNameTypeDescription
codeCodestringFor details, view the code list: Click the code list
seqQuote sequence numberinteger
tick_timeQuote timestampintegerUnit: milliseconds
priceTrade pricestringLatest trade price
volumeTrade volumestringTrade volume corresponding to the latest trade price
turnoverTurnoverstringTurnover
trade_directionTrade directionstringTrade direction:
1. 0 is the default value, 1 is Buy, and 2 is Sell.
2. Forex, precious metals, and energy return only 1 by default.
3. Stocks and cryptocurrencies may return 0, 1, or 2 depending on market conditions.
4. Detailed description:
0: Neutral, meaning the trade was matched at a price between the best bid and best ask.
1: Aggressive buy, meaning the stock was traded at the ask price or a higher price.
2: Aggressive sell, meaning the stock was traded at the bid price or a lower price.

Data Structure (JSON)

{
  "cmd_id": 22998,
  "data": {
    "code": "1288.HK",
    "seq": 1782180168224,
    "tick_time": 1782180164000,
    "price": "651.12",
    "volume": "300",
    "turnover": "12345.6",
    "trade_direction": 1
  }
}

AllTick Website

Official website: https://alltick.co/