com.binance.connector.client.impl.websocketapi.WebSocketApiGeneral Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of binance-connector-java Show documentation
Show all versions of binance-connector-java Show documentation
lightweight connector to API
The newest version!
package com.binance.connector.client.impl.websocketapi;
import org.json.JSONObject;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler;
/**
* General Requests
* All requests under the
* General requests
* section of the WebSocket API documentation will be implemented in this class.
*
* Response will be returned as callback.
*/
public class WebSocketApiGeneral implements WebSocketApiModule {
private WebSocketApiRequestHandler handler;
public WebSocketApiGeneral(WebSocketApiRequestHandler handler) {
this.handler = handler;
}
/**
* Test connectivity to the WebSocket API.
* Note:
* You can use regular WebSocket ping frames to test connectivity as well, WebSocket API will respond with pong frames as soon as possible.
* ping request along with time is a safe way to test request-response handling in your application.
*
* @param parameters JSONObject composed by key-value pairs:
*
* requestId -- optional/String or int
*
* @see
* https://binance-docs.github.io/apidocs/websocket_api/en/#test-connectivity
*/
public void ping(JSONObject parameters) {
this.handler.publicRequest("ping", parameters);
}
/**
* Test connectivity to the WebSocket API and get the current server time.
*
* @param parameters JSONObject composed by key-value pairs:
*
* requestId -- optional/String or int
*
* @see
* https://binance-docs.github.io/apidocs/websocket_api/en/#check-server-time
*/
public void serverTime(JSONObject parameters) {
this.handler.publicRequest("time", parameters);
}
/**
* Query current exchange trading rules, rate limits, and symbol information.
*
* Notes:
* Without parameters, exchangeInfo displays all symbols with ["SPOT, "MARGIN", "LEVERAGED"] permissions.
* In order to list all active symbols on the exchange, you need to explicitly request all permissions.
* Available Permissions
*
* @param parameters JSONObject composed by key-value pairs:
*
* symbol -- optional/String
* symbols -- optional/Array of String
* permissions -- optional/Array of String
* requestId -- optional/String or int
*
* @see
* https://binance-docs.github.io/apidocs/websocket_api/en/#exchange-information
*/
public void exchangeInfo(JSONObject parameters) {
ParameterChecker.checkOnlyOneOfParameters(parameters, "symbol", "symbols", "permissions");
this.handler.publicRequest("exchangeInfo", parameters);
}
}