Real-Time News (News) Subscription
This WebSocket provides real-time news
Overview
This WebSocket API provides real-time news push notifications.
After the connection is established, the client subscribes by language (lang):
data.langis required. It must be a single language code (case-insensitive; normalized to lowercase on the server). See the language enum below for supported valuesA new subscription on the same connection overwrites the previous
langThe package must have news permission enabled (
newsFlag=1); otherwise the handshake failsEach
apikeyis allowed only one connection; a new connection is rejected if one already exists
Language Enum
lang supports only the following values. The right column is the associated country/market code (en maps to global, with an empty country code):
en
(empty)
English
zh-Hans
CN
Simplified Chinese
zh-Hant
HK
Traditional Chinese
ja
JP
Japanese
ko
KR
Korean
de
DE
German
fr
FR
French
es
ES
Spanish
pt
BR
Portuguese
ru
RU
Russian
tr
TR
Turkish
Request Frequency
Keep the connection alive with heartbeats. It is recommended to send a heartbeat every 30 seconds (protocol number 10010). If the server does not receive a heartbeat (business heartbeat or WebSocket Ping) for more than 60 seconds, the connection will be closed automatically.
Error Code Explanation
Please refer to the WebSocket error code documentation for further details.
Common handshake / connection errors:
200
Handshake success
507
Missing parameter (e.g. data / data.lang)
513
Heartbeat timeout
514
Incorrect WebSocket path
515
Request is not JSON
517
Handshake failed: apikey is missing
518
Handshake failed: apikey does not exist
519
Handshake failed: no news permission (newsFlag!=1)
520
Handshake failed: apikey already connected
521
Handshake failed: server connection limit reached
Subscription Address
The path must be
/news, andapikeymust be passed as a query parameter.
Request Quantity
Each WebSocket connection keeps only one active subscription at a time (a new subscription overwrites the previous one). Each apikey is allowed only one concurrent connection.
Request (Protocol Number: 10020)
code
Integer
Yes
Protocol number for the request
Real-time news subscribe: 10020
trace
String
Yes
Trace ID (random string)
423afec425004bd8a5e02e1ba5f9b2b0
data
JSON
Yes
Subscription data
<lang
String
Yes
Language to subscribe (single language, case-insensitive). See the language enum above
en
Response (Protocol Number: 10021)
code
Integer
Yes
Response protocol number
Real-time news subscribe response: 10021
trace
String
Yes
Trace ID from the request
423afec425004bd8a5e02e1ba5f9b2b0
msg
String
Yes
Response message
ok
data
JSON
Yes
Active subscription criteria
<lang
String
Yes
Subscribed language (normalized lowercase)
en
Push (Protocol Number: 10022)
code
Integer
Yes
Push protocol number
Real-time news push: 10022
data
JSON
Yes
Push data entity
<dk
String
Yes
Deduplication key (md5(title + content))
a1b2c3d4e5f6...
<country
String
No
Country (may be empty for global feeds)
US
<lang
String
Yes
Language
en / zh-Hans
<route
String
Yes
Ingestion route
country / lang
<title
String
Yes
Title
Apple raises full-year revenue forecast
<published
Long
Yes
Publish timestamp (Unix seconds)
1747552358
<urgency
Integer
Yes
Urgency level (lower means more urgent)
2
<provider
String
Yes
News provider
reuters / gelonghui
<symbols
Array
No
Related symbols
["AAPL"]
<link
String
No
External link (flash/brief news)
https://www.example.com/article/123
<content
String
No
Plain-text content
<sd
String
No
Summary (shortDescription)
Heartbeat (Protocol Number: 10010)
The server refreshes the connection activity timestamp and does not send a business response. You may also use standard WebSocket Ping / Pong to keep the connection alive.
Last updated
