# 搜索资讯
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_news(keyword, max_count=10, news_sub_type=NewsSubType.ALL)
介绍
按关键词搜索资讯,返回匹配的新闻、公告、评级等资讯列表。
参数
参数 类型 说明 keyword str 搜索词 max_count int 本次请求的最大返回条数 默认10条,最大100条news_sub_type NewsSubType 资讯子类型 默认 NewsSubType.ALL返回
参数 类型 说明 ret RET_CODE 接口调用结果 data pd.DataFrame 当 ret == RET_OK,返回搜索资讯列表 str 当 ret != RET_OK,返回错误描述 DataFrame 字段说明:
字段 类型 说明 title str 标题 news_sub_type NewsSubType 资讯子类型 source str 来源 publish_time str 发布时间 view_count int 浏览量 related_securities list 关联标的列表 url str 详情页链接
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() # 结束后记得关闭当条连接,防止连接条数用尽
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
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 NewsSubType
协议 ID
3263
uint GetSearchNews(QotGetSearchNews.Request req);
virtual void OnReply_GetSearchNews(FTAPI_Conn client, uint nSerialNo, QotGetSearchNews.Response rsp);
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 NewsSubType
- Example
- Output
int getSearchNews(QotGetSearchNews.Request req);
void onReply_GetSearchNews(FTAPI_Conn client, int nSerialNo, QotGetSearchNews.Response rsp);
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 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;
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 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("腾讯");
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);
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 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: "腾讯",
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
接口限制
- 每 30 秒内最多请求 10 次搜索资讯接口。
- Python
- Proto
- C#
- Java
- C++
- JavaScript
get_search_news(keyword, max_count=10, news_sub_type=NewsSubType.ALL)
介绍
按关键词搜索资讯,返回匹配的新闻、公告、评级等资讯列表。
参数
参数 类型 说明 keyword str 搜索词 max_count int 本次请求的最大返回条数 默认10条,最大100条news_sub_type NewsSubType 资讯子类型 默认 NewsSubType.ALL返回
参数 类型 说明 ret RET_CODE 接口调用结果 data pd.DataFrame 当 ret == RET_OK,返回搜索资讯列表 str 当 ret != RET_OK,返回错误描述 DataFrame 字段说明:
字段 类型 说明 title str 标题 news_sub_type NewsSubType 资讯子类型 source str 来源 publish_time str 发布时间 view_count int 浏览量 related_securities list 关联标的列表 url str 详情页链接
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() # 结束后记得关闭当条连接,防止连接条数用尽
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
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 NewsSubType
协议 ID
3263
uint GetSearchNews(QotGetSearchNews.Request req);
virtual void OnReply_GetSearchNews(MMAPI_Conn client, uint nSerialNo, QotGetSearchNews.Response rsp);
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 NewsSubType
- Example
- Output
int getSearchNews(QotGetSearchNews.Request req);
void onReply_GetSearchNews(MMAPI_Conn client, int nSerialNo, QotGetSearchNews.Response rsp);
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 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;
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 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("腾讯");
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);
介绍
按关键词搜索资讯。
参数
message C2S
{
required string keyword = 1; //搜索词,如 lite
optional int32 max_count = 2; //本次请求的最大返回条数,默认10条,最大100条
optional int32 news_sub_type = 3; //NewsSubType,资讯子类型,默认 NewsSubType_ALL
}
message Request
{
required C2S c2s = 1;
}
2
3
4
5
6
7
8
9
10
11
- 资讯子类型枚举参见 NewsSubType
- 返回
message SearchNews
{
optional string title = 1; //标题(含关键词)
optional int32 news_sub_type = 2; //NewsSubType,资讯子类型
optional string source = 3; //来源,如 富途资讯 / MT Newswires / Benzinga
optional string publish_time = 4; //发布时间
optional int64 view_count = 5; //浏览量
repeated string related_securities = 6; //关联标的列表,如 LITE.US,用于跳转
optional string url = 7; //详情页链接
}
message S2C
{
repeated SearchNews searchNewsList = 1; //搜索资讯列表
}
message Response
{
required int32 retType = 1 [default = -400]; //RetType,返回结果
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
- 接口调用结果,结构参见 RetType
- 资讯子类型枚举参见 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: "腾讯",
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
接口限制
- 每 30 秒内最多请求 10 次搜索资讯接口。