Skip to content

Commit 8e5a913

Browse files
author
方佳
committed
Merge branch 'main_merge_261010' into 'main'
feat: support community-related capabilities for Webull US See merge request webull/webull-openapi-java-sdk!49
2 parents ddcd552 + 9c0b9c5 commit 8e5a913

16 files changed

Lines changed: 617 additions & 4 deletions

File tree

‎agent-docs/overview.md‎

Whitespace-only changes.

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<groupId>com.webull.openapi</groupId>
2222
<artifactId>webull-openapi-java-sdk-parent</artifactId>
2323
<packaging>pom</packaging>
24-
<version>2.0.2</version>
24+
<version>2.0.3</version>
2525

2626
<name>webull-openapi-java-sdk-parent</name>
2727
<url>https://github.com/webull-inc/webull-openapi-java-sdk/</url>

‎webull-openapi-java-sdk-samples/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>com.webull.openapi</groupId>
2121
<artifactId>webull-openapi-java-sdk-parent</artifactId>
22-
<version>2.0.2</version>
22+
<version>2.0.3</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

‎webull-openapi-java-sdk-samples/src/main/java/com/webull/openapi/samples/data/DataClient.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.webull.openapi.data.quotes.api.IDataClient;
1919
import com.webull.openapi.data.quotes.domain.*;
2020
import com.webull.openapi.samples.config.Env;
21+
import com.webull.openapi.trade.response.PaginatedResult;
2122

2223
import java.util.*;
2324
import java.math.BigDecimal;
@@ -297,6 +298,30 @@ public static void main(String[] args) {
297298
List<OptionContract> optionContracts = dataClient.getOptionContracts(optionParam);
298299
logger.info("Option Contracts: {}", optionContracts);
299300

301+
// Community APIs
302+
CreatePostResponse post = dataClient.createPost(
303+
"Hello, this is a test post from OpenAPI!",
304+
"NVDA",
305+
Category.US_STOCK.name());
306+
logger.info("Created post: {}", post);
307+
308+
CreateCommentResponse comment = dataClient.createComment(
309+
"995005758239301632",
310+
"Hello, this is a test comment from OpenAPI!");
311+
logger.info("Created comment: {}", comment);
312+
313+
List<HotStock> hotStocks = dataClient.listHotStocks();
314+
logger.info("Hot stocks: {}", hotStocks);
315+
316+
PaginatedResult<PostSummary> posts = dataClient.listPostsBySymbol(
317+
"NVDA", Category.US_STOCK.name(), null, null);
318+
logger.info("Posts by symbol: {}", posts);
319+
320+
PostDetail detail = dataClient.getPost("995005758239301632");
321+
logger.info("Post detail: {}", detail);
322+
323+
PaginatedResult<PostSummary> myPosts = dataClient.listMyPosts(null);
324+
logger.info("My posts: {}", myPosts);
300325

301326
// // get end of day market
302327
// List<EodBars> eodBars = IDataClient.getEodBars(instrumentIds, "2023-01-01", 10);

‎webull-openapi-java-sdk/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.webull.openapi</groupId>
99
<artifactId>webull-openapi-java-sdk-parent</artifactId>
10-
<version>2.0.2</version>
10+
<version>2.0.3</version>
1111
</parent>
1212

1313
<artifactId>webull-openapi-java-sdk</artifactId>

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/core/config/ProjectReaderHelper.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private ProjectReaderHelper() {
2424

2525
private static final String APPLICATION_VERSION = "application.version";
2626

27-
private static final String DEFAULT_APPLICATION_VERSION = "2.0.2";
27+
private static final String DEFAULT_APPLICATION_VERSION = "2.0.3";
2828

2929
private static final String APPLICATION_NAME = "application.name";
3030

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/DataClient.java‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,85 @@ public NoiiSnapshot getNoiiSnapshot(String symbol, String category, String imbal
15451545
}
15461546

15471547

1548+
// ==================== Community APIs ====================
1549+
1550+
@Override
1551+
public CreatePostResponse createPost(String text, String symbol, String category) {
1552+
Assert.notBlank(ArgNames.TEXT, text);
1553+
HttpRequest request = new HttpRequest("/market-data/communities/posts/create", Versions.V3, HttpMethod.POST);
1554+
Map<String, Object> params = new HashMap<>();
1555+
params.put(ArgNames.TEXT, text);
1556+
if (StringUtils.isNotBlank(symbol)) {
1557+
params.put(ArgNames.SYMBOL, symbol);
1558+
}
1559+
if (StringUtils.isNotBlank(category)) {
1560+
params.put(ArgNames.CATEGORY, category);
1561+
}
1562+
request.setBody(params);
1563+
addCustomHeaders(request);
1564+
return apiClient.request(request).responseType(new TypeToken<CreatePostResponse>() {}.getType()).doAction();
1565+
}
1566+
1567+
@Override
1568+
public CreateCommentResponse createComment(String postId, String text) {
1569+
Assert.notBlank(Arrays.asList(ArgNames.POST_ID, ArgNames.TEXT), postId, text);
1570+
HttpRequest request = new HttpRequest("/market-data/communities/comments/create", Versions.V3, HttpMethod.POST);
1571+
Map<String, Object> params = new HashMap<>();
1572+
params.put(ArgNames.POST_ID, postId);
1573+
params.put(ArgNames.TEXT, text);
1574+
request.setBody(params);
1575+
addCustomHeaders(request);
1576+
return apiClient.request(request).responseType(new TypeToken<CreateCommentResponse>() {}.getType()).doAction();
1577+
}
1578+
1579+
@Override
1580+
public List<HotStock> listHotStocks() {
1581+
HttpRequest request = new HttpRequest("/market-data/communities/stock-rankings/list", Versions.V3, HttpMethod.GET);
1582+
addCustomHeaders(request);
1583+
return apiClient.request(request).responseType(new TypeToken<List<HotStock>>() {}.getType()).doAction();
1584+
}
1585+
1586+
@Override
1587+
public PaginatedResult<PostSummary> listPostsBySymbol(String symbol, String category, String keyword, String paginationKey) {
1588+
Assert.notBlank(Arrays.asList(ArgNames.SYMBOL, ArgNames.CATEGORY), symbol, category);
1589+
HttpRequest request = new HttpRequest("/market-data/communities/posts/symbols/list", Versions.V3, HttpMethod.GET);
1590+
Map<String, Object> params = new HashMap<>();
1591+
params.put(ArgNames.SYMBOL, symbol);
1592+
params.put(ArgNames.CATEGORY, category);
1593+
if (StringUtils.isNotBlank(keyword)) {
1594+
params.put(ArgNames.KEYWORD, keyword);
1595+
}
1596+
if (StringUtils.isNotBlank(paginationKey)) {
1597+
params.put(ArgNames.PAGINATION_KEY, paginationKey);
1598+
}
1599+
request.setQuery(params);
1600+
addCustomHeaders(request);
1601+
return apiClient.request(request).responseType(new TypeToken<PaginatedResult<PostSummary>>() {}.getType()).doAction();
1602+
}
1603+
1604+
@Override
1605+
public PostDetail getPost(String postId) {
1606+
Assert.notBlank(ArgNames.POST_ID, postId);
1607+
HttpRequest request = new HttpRequest("/market-data/communities/posts/get", Versions.V3, HttpMethod.GET);
1608+
Map<String, Object> params = new HashMap<>();
1609+
params.put(ArgNames.POST_ID, postId);
1610+
request.setQuery(params);
1611+
addCustomHeaders(request);
1612+
return apiClient.request(request).responseType(new TypeToken<PostDetail>() {}.getType()).doAction();
1613+
}
1614+
1615+
@Override
1616+
public PaginatedResult<PostSummary> listMyPosts(String paginationKey) {
1617+
HttpRequest request = new HttpRequest("/market-data/communities/my-posts/list", Versions.V3, HttpMethod.GET);
1618+
Map<String, Object> params = new HashMap<>();
1619+
if (StringUtils.isNotBlank(paginationKey)) {
1620+
params.put(ArgNames.PAGINATION_KEY, paginationKey);
1621+
}
1622+
request.setQuery(params);
1623+
addCustomHeaders(request);
1624+
return apiClient.request(request).responseType(new TypeToken<PaginatedResult<PostSummary>>() {}.getType()).doAction();
1625+
}
1626+
15481627
// ==================== Option Instrument APIs ====================
15491628

15501629
@Override

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/common/ArgNames.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,9 @@ private ArgNames() {
9797
public static final String ROOT_SYMBOL = "root_symbol";
9898
public static final String PPIND = "ppind";
9999
public static final String SHOW_DELIVERABLES = "show_deliverables";
100+
101+
// Community related
102+
public static final String TEXT = "text";
103+
public static final String POST_ID = "post_id";
104+
public static final String KEYWORD = "keyword";
100105
}

‎webull-openapi-java-sdk/src/main/java/com/webull/openapi/data/quotes/api/IDataClient.java‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,4 +739,59 @@ FiftyTwoWeekResponse get52Whl(String rankType, String category, String sortBy,
739739
* @return paginated result containing option contract list and next pagination key
740740
*/
741741
PaginatedResult<OptionContract> getOptionContractsV2(OptionContractQueryParam param);
742+
743+
// ==================== Community APIs ====================
744+
745+
/**
746+
* Create a plain-text community post.
747+
*
748+
* @param text post content
749+
* @param symbol optional ticker symbol
750+
* @param category optional ticker category; provide it together with symbol
751+
* @return created post identifier
752+
*/
753+
CreatePostResponse createPost(String text, String symbol, String category);
754+
755+
/**
756+
* Create a plain-text comment on an existing community post.
757+
*
758+
* @param postId post identifier
759+
* @param text comment content
760+
* @return created comment identifier
761+
*/
762+
CreateCommentResponse createComment(String postId, String text);
763+
764+
/**
765+
* List hot stocks ranked by community activity.
766+
*
767+
* @return hot stock ranking entries
768+
*/
769+
List<HotStock> listHotStocks();
770+
771+
/**
772+
* List community posts associated with a symbol.
773+
*
774+
* @param symbol stock symbol
775+
* @param category market category
776+
* @param keyword optional search keyword
777+
* @param paginationKey pagination key from the previous response
778+
* @return paginated post summaries
779+
*/
780+
PaginatedResult<PostSummary> listPostsBySymbol(String symbol, String category, String keyword, String paginationKey);
781+
782+
/**
783+
* Get a community post by identifier.
784+
*
785+
* @param postId post identifier
786+
* @return post details
787+
*/
788+
PostDetail getPost(String postId);
789+
790+
/**
791+
* List posts created by the current user.
792+
*
793+
* @param paginationKey pagination key from the previous response
794+
* @return paginated post summaries
795+
*/
796+
PaginatedResult<PostSummary> listMyPosts(String paginationKey);
742797
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2022 Webull
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.webull.openapi.data.quotes.domain;
17+
18+
/**
19+
* Response returned after creating a community comment.
20+
*
21+
* @author Webull
22+
*/
23+
public class CreateCommentResponse {
24+
25+
private String commentId;
26+
27+
public String getCommentId() {
28+
return commentId;
29+
}
30+
31+
public void setCommentId(String commentId) {
32+
this.commentId = commentId;
33+
}
34+
35+
@Override
36+
public String toString() {
37+
return "CreateCommentResponse{" +
38+
"commentId='" + commentId + '\'' +
39+
'}';
40+
}
41+
}

0 commit comments

Comments
 (0)