# Search News
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_news(keyword, max_count=10, news_sub_type=NewsSubType.ALL)
Description
Search news by keyword and return a list of matched news, notices, ratings, and other items.
Parameters
Parameter Type Description keyword str Search keyword max_count int Maximum number of items returned in this request Default 10, maximum 100news_sub_type NewsSubType News sub type Default NewsSubType.ALLReturn
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns search news list str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description title str Title news_sub_type NewsSubType News sub type source str Source publish_time str Publish time view_count int View count related_securities list Related securities url str Detail page URL
Example
from futu import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_search_news('space', 10, news_sub_type=NewsSubType.ALL)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # Remember to close the connection to avoid exhausting connection quota
2
3
4
5
6
7
8
- Output
title news_sub_type source publish_time view_count related_securities url
0 Space:2026年12月期 第一财季业绩说明材料 NEWS 日本交易所 5/13 329 [] https://news.futunn.com/notice/307288728
1 Space:2026年12月期 第一财季业绩简报[日本会计准则](合并) NEWS 日本交易所 5/13 277 [] https://news.futunn.com/notice/307288725
2 SPACE CO., LTD. 第一季度盈利表现强劲,但全年利润和股息预期下调。 NEWS TipRanks 5/13 201 [] https://news.futunn.com/post/73007255?futusour...
3 New Street Research 开始覆盖太空经济和基础设施领域。 NEWS PR Newswire 5/14 6035 [] https://news.futunn.com/post/73047684?futusour...
4 Space:临时报告书 NEWS 日本金融厅 3/27 257 [] https://news.futunn.com/notice/306761904
5 Gemini Space Station | 8-K:重大事件 NOTICE 美股SEC公告 6/16 278 [US.GEMI] https://news.futunn.com/notice/307532371?futus...
6 Extra Space Storage | 4:持股变动声明-高管 McNeal Gwyn ... NOTICE 美股SEC公告 6/13 348 [US.EXR] https://news.futunn.com/notice/307521769?futus...
7 Space Exploration Technologies Corp:承保或代理协议 NOTICE SEDAR 6/12 400 [] https://news.futunn.com/notice/307519369?futus...
8 Space Exploration Technologies Corp:补充长期形式的预备招... NOTICE SEDAR 6/12 231 [] https://news.futunn.com/notice/307519371?futus...
9 Space Exploration Technologies Corp:补充长期形式的预备招... NOTICE SEDAR 6/12 210 [] https://news.futunn.com/notice/307519370?futus...
2
3
4
5
6
7
8
9
10
11
# Qot_GetSearchNews.proto
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
Protocol ID
3263
uint GetSearchNews(QotGetSearchNews.Request req);
virtual void OnReply_GetSearchNews(FTAPI_Conn client, uint nSerialNo, QotGetSearchNews.Response rsp);
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
- Output
int getSearchNews(QotGetSearchNews.Request req);
void onReply_GetSearchNews(FTAPI_Conn client, int nSerialNo, QotGetSearchNews.Response rsp);
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
- Output
Futu::u32_t GetSearchNews(const Qot_GetSearchNews::Request &stReq);
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) = 0;
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
class Program : public FTSPI_Qot, public FTSPI_Conn
{
public:
Program() {
m_pQotApi = FTAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr) {
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
FTAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(FTAPI_Conn* pConn, Futu::i64_t nErrCode, const char* strDesc) {
Qot_GetSearchNews::Request req;
Qot_GetSearchNews::C2S *c2s = req.mutable_c2s();
c2s->set_keyword("space");
c2s->set_max_count(10);
c2s->set_news_sub_type(Qot_GetSearchNews::NewsSubType_ALL);
m_GetSearchNewsSerialNo = m_pQotApi->GetSearchNews(req);
}
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) {
if (nSerialNo != m_GetSearchNewsSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetSearchNewsSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GetSearchNews(req);
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
import ftWebsocket from "futu-api";
import { Common, Qot_GetSearchNews } from "futu-api/proto";
import beautify from "js-beautify";
function QotGetSearchNews(){
const { RetType } = Common
const { NewsSubType } = Qot_GetSearchNews
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new ftWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
keyword: "space",
maxCount: 10,
newsSubType: NewsSubType.NewsSubType_ALL,
},
};
websocket.GetSearchNews(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetSearchNews: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(data);
}
})
.catch((error) => {
console.log("error:", error);
});
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetSearchNews()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
API Restrictions
- Maximum 10 search news requests per 30 seconds.
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_news(keyword, max_count=10, news_sub_type=NewsSubType.ALL)
Description
Search news by keyword and return a list of matched news, notices, ratings, and other items.
Parameters
Parameter Type Description keyword str Search keyword max_count int Maximum number of items returned in this request Default 10, maximum 100news_sub_type NewsSubType News sub type Default NewsSubType.ALLReturn
Parameter Type Description ret RET_CODE API call result data pd.DataFrame When ret == RET_OK, returns search news list str When ret != RET_OK, returns error description DataFrame fields:
Field Type Description title str Title news_sub_type NewsSubType News sub type source str Source publish_time str Publish time view_count int View count related_securities list Related securities url str Detail page URL
Example
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret, data = quote_ctx.get_search_news('space', 10, news_sub_type=NewsSubType.ALL)
if ret == RET_OK:
print(data)
else:
print('error:', data)
quote_ctx.close() # Remember to close the connection to avoid exhausting connection quota
2
3
4
5
6
7
8
- Output
title news_sub_type source publish_time view_count related_securities url
0 Space:2026年12月期 第一财季业绩说明材料 NEWS 日本交易所 5/13 329 [] https://news.futunn.com/notice/307288728
1 Space:2026年12月期 第一财季业绩简报[日本会计准则](合并) NEWS 日本交易所 5/13 277 [] https://news.futunn.com/notice/307288725
2 SPACE CO., LTD. 第一季度盈利表现强劲,但全年利润和股息预期下调。 NEWS TipRanks 5/13 201 [] https://news.futunn.com/post/73007255?futusour...
3 New Street Research 开始覆盖太空经济和基础设施领域。 NEWS PR Newswire 5/14 6035 [] https://news.futunn.com/post/73047684?futusour...
4 Space:临时报告书 NEWS 日本金融厅 3/27 257 [] https://news.futunn.com/notice/306761904
5 Gemini Space Station | 8-K:重大事件 NOTICE 美股SEC公告 6/16 278 [US.GEMI] https://news.futunn.com/notice/307532371?futus...
6 Extra Space Storage | 4:持股变动声明-高管 McNeal Gwyn ... NOTICE 美股SEC公告 6/13 348 [US.EXR] https://news.futunn.com/notice/307521769?futus...
7 Space Exploration Technologies Corp:承保或代理协议 NOTICE SEDAR 6/12 400 [] https://news.futunn.com/notice/307519369?futus...
8 Space Exploration Technologies Corp:补充长期形式的预备招... NOTICE SEDAR 6/12 231 [] https://news.futunn.com/notice/307519371?futus...
9 Space Exploration Technologies Corp:补充长期形式的预备招... NOTICE SEDAR 6/12 210 [] https://news.futunn.com/notice/307519370?futus...
2
3
4
5
6
7
8
9
10
11
# Qot_GetSearchNews.proto
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
Protocol ID
3263
uint GetSearchNews(QotGetSearchNews.Request req);
virtual void OnReply_GetSearchNews(MMAPI_Conn client, uint nSerialNo, QotGetSearchNews.Response rsp);
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
- Output
int getSearchNews(QotGetSearchNews.Request req);
void onReply_GetSearchNews(MMAPI_Conn client, int nSerialNo, QotGetSearchNews.Response rsp);
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
- Output
Futu::u32_t GetSearchNews(const Qot_GetSearchNews::Request &stReq);
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) = 0;
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
class Program : public FTSPI_Qot, public FTSPI_Conn
{
public:
Program() {
m_pQotApi = FTAPI::CreateQotApi();
m_pQotApi->RegisterQotSpi(this);
m_pQotApi->RegisterConnSpi(this);
}
~Program() {
if (m_pQotApi != nullptr) {
m_pQotApi->UnregisterQotSpi();
m_pQotApi->UnregisterConnSpi();
FTAPI::ReleaseQotApi(m_pQotApi);
m_pQotApi = nullptr;
}
}
void Start() {
m_pQotApi->InitConnect("127.0.0.1", 11111, false);
}
virtual void OnInitConnect(FTAPI_Conn* pConn, Futu::i64_t nErrCode, const char* strDesc) {
Qot_GetSearchNews::Request req;
Qot_GetSearchNews::C2S *c2s = req.mutable_c2s();
c2s->set_keyword("space");
c2s->set_max_count(10);
c2s->set_news_sub_type(Qot_GetSearchNews::NewsSubType_ALL);
m_GetSearchNewsSerialNo = m_pQotApi->GetSearchNews(req);
}
virtual void OnReply_GetSearchNews(Futu::u32_t nSerialNo, const Qot_GetSearchNews::Response &stRsp) {
if (nSerialNo != m_GetSearchNewsSerialNo) return;
string resp_str;
ProtoBufToBodyData(stRsp, resp_str);
cout << UTF8ToLocal(resp_str) << endl;
}
protected:
FTAPI_Qot *m_pQotApi;
Futu::u32_t m_GetSearchNewsSerialNo = 0;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GetSearchNews(req);
Description
Search news by keyword.
Parameters
message C2S
{
required string keyword = 1; //Search keyword
optional int32 max_count = 2; //Maximum items returned in this request, default 10, maximum 100
optional int32 news_sub_type = 3; //NewsSubType, news sub type, default NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- NewsSubType enum: NewsSubType
- Return
message SearchNews
{
optional string title = 1; //Title (contains keyword)
optional int32 news_sub_type = 2; //NewsSubType,News sub type
optional string source = 3; //Source, e.g. Futunn News / MT Newswires / Benzinga
optional string publish_time = 4; //Publish time
optional int64 view_count = 5; //View count
repeated string related_securities = 6; //Related securities, e.g. LITE.US
optional string url = 7; //Detail page URL
}
message S2C
{
repeated SearchNews searchNewsList = 1; //Search news list
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType, return result
optional string retMsg = 2;
optional int32 errCode = 3;
optional S2C s2c = 4;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
- API call result structure: RetType
- NewsSubType enum: NewsSubType
- Example
import mmWebsocket from "moomoo-api";
import { Common, Qot_GetSearchNews } from "moomoo-api/proto";
import beautify from "js-beautify";
function QotGetSearchNews(){
const { RetType } = Common
const { NewsSubType } = Qot_GetSearchNews
let [addr, port, enable_ssl, key] = ["127.0.0.1", 33333, false, '7522027ccf5a06b1'];
let websocket = new mmWebsocket();
websocket.onlogin = (ret, msg)=>{
if (ret) {
const req = {
c2s: {
keyword: "space",
maxCount: 10,
newsSubType: NewsSubType.NewsSubType_ALL,
},
};
websocket.GetSearchNews(req)
.then((res) => {
let { errCode, retMsg, retType, s2c } = res
console.log("GetSearchNews: errCode %d, retMsg %s, retType %d", errCode, retMsg, retType);
if(retType == RetType.RetType_Succeed){
let data = beautify(JSON.stringify(s2c), {
indent_size: 2,
space_in_empty_paren: true,
});
console.log(data);
}
})
.catch((error) => {
console.log("error:", error);
});
} else {
console.log("start error", msg);
}
};
websocket.start(addr, port, enable_ssl, key);
setTimeout(()=>{ websocket.stop(); process.exit(); }, 5000);
}
QotGetSearchNews()
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
API Restrictions
- Maximum 10 search news requests per 30 seconds.