Skip to main content
WSS

Plan Access

A subscription to CN_Stock first sends a batched market snapshot, then continuously pushes changed tickers.

Enable WebSocket Compression

A full-market subscription must successfully negotiate permessage-deflate during the WebSocket handshake. This is different from the gzip, br, and zstd compression used by REST endpoints and cannot be enabled through Accept-Encoding or a subscription message.
  • The client must enable permessage-deflate when establishing the connection.
  • After successful negotiation, the handshake response includes permessage-deflate in Sec-WebSocket-Extensions.
  • If compression is not negotiated, a full-market subscription returns error code 2008. Enable compression and reconnect.
  • Browsers normally negotiate WebSocket compression automatically. Server-side clients should explicitly enable it and verify the negotiated extension.

Subscription Message

Use universes to specify one or more market universes. channels must contain ticker.
Successful subscription response:

JavaScript Example

The following Node.js example uses ws and explicitly enables permessage-deflate when connecting:

Push Format

Full-market data is pushed in JSON arrays of at most 500 ticker messages:
  • The first subscription delivers the current full snapshot, which may be split across multiple arrays.
  • After the initial snapshot, only changed tickers are pushed, using the same array format.
  • Quote fields follow the corresponding REST endpoint: A-share full-market quotes.
  • After a full-market subscription is activated for a market, existing per-symbol stock subscriptions for that market are canceled on the same connection to avoid duplicate messages.

Unsubscribe

Common Errors

api_key
type:httpApiKey
Subscribe/Unsubscribe to A-share Full-Market Ticker
type:object

Subscribe or unsubscribe to ticker updates for all A-share symbols; permessage-deflate is required

A-share Full-Market Ticker Batch
type:array

Initial snapshot and subsequent ticker updates are sent as arrays of up to 500 messages

WebSocket Error Response
type:object

Subscription or command error returned after the WebSocket connection is established