Domain
Endpoint refers to the network domain of the requested service, such as api.webull.co.jp
corresponding to the HTTP API service.
The region_id
is also related to the Endpoint. For example, the region_id
corresponding to the above two domain is jp (representing Japan).
In the process of using the SDK, the Endpoint has been managed by default. Generally, the developer only needs to set the region_id correctly, and there is no need to set the Endpoint separately.
HTTP API
Different ways for users to customize Endpoint
- Python
- Java
- Set through ApiClient and take effect globally. The sample code is as follows.
from webullsdkcore.client import ApiClient
client = ApiClient(app_key="<your_app_key>", app_secret="<your_app_secret>", region_id="<region_id>")
client.add_endpoint("<region_id>", "<endpoint>")
- Set by Request, and it only takes effect for the current Request. The sample code is as follows.
from webullsdkmdata.request.get_instruments_request import GetInstrumentsRequest
request = GetInstrumentsRequest()
request.set_endpoint("<endpoint>")
- Set through EndpointResolver and take effect globally. The sample code is as follows.
EndpointResolver.getDefault().addEndpoint("<region_id>", ApiModule.API, "<endpoint>");
- By setting HttpApiConfig, it only takes effect for the current Client/Service instance. The sample code is as follows.
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey("<your_app_key>")
.appSecret("<your_app_secret>")
.regionId("<region_id>")
.endpoint("<endpoint>")
.build();
// HttpApiClient client = new HttpApiClient(apiConfig);
TradeApiService apiService = new TradeHttpApiService(apiConfig);
- By setting HttpRequest, it is only valid for the current Request. The sample code is as follows.
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey("<your_app_key>")
.appSecret("<your_app_secret>")
.regionId(Region.jp.name())
.build();
HttpApiClient client = new HttpApiClient(apiConfig);
HttpRequest request = new HttpRequest("<endpoint>", "/trade/instrument", Versions.V1, HttpMethod.GET);
Map<String, Object> params = new HashMap<>();
params.put("instrument_id", instrumentId);
request.setQuery(params);
InstrumentInfo instrumentInfo = client.request(request).responseType(InstrumentInfo.class).doAction();
Trade Events Subscription
By setting the parameters of host and port, the user can implement the endpoint of the custom gRPC protocol. The sample code is as follows.
- Python
- Java
from webullsdktradeeventscore.events_client import EventsClient
events_client = EventsClient("<your_app_key>", "<your_app_secret>",region_id="<region_id>", host="<host>", port="<port>")
EventClient client = EventClient.builder()
.appKey("<your_app_key>")
.appSecret("<your_app_secret>")
.host("<host>")
.port(443)
.build();