com.binance.connector.client.impl.websocketapi.WebSocketApiAuth 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
package com.binance.connector.client.impl.websocketapi;
import org.json.JSONObject;
import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler;
/**
* Authentication requests
* All requests under the
* Authentication requests
* section of the WebSocket API documentation will be implemented in this class.
*
* Response will be returned as callback.
*/
public class WebSocketApiAuth implements WebSocketApiModule {
private WebSocketApiRequestHandler handler;
public WebSocketApiAuth(WebSocketApiRequestHandler handler) {
this.handler = handler;
}
/**
* Authenticate WebSocket connection using the provided API key.
*
* After calling session.logon, future requests under same connection won't send apiKey and signature parameters.
* Calling session.logon multiple times changes the current authenticated API key.
*
* @param parameters JSONObject composed by key-value pairs:
*
* recvWindow -- optional/int -- The value cannot be greater than 60000
* requestId -- optional/String or int
*
* @see
* https://binance-docs.github.io/apidocs/websocket_api/en/#log-in-with-api-key-signed
*/
public void logon(JSONObject parameters) {
this.handler.signedRequest("session.logon", parameters);
}
/**
* Query the status of the WebSocket connection, inspecting which API key (if any) is used to authorize requests.
*
* @param parameters JSONObject composed by key-value pairs:
*
* requestId -- optional/String or int
*
* @see
* https://binance-docs.github.io/apidocs/websocket_api/en/#query-session-status
*/
public void status(JSONObject parameters) {
this.handler.publicRequest("session.status", parameters);
}
/**
* Forget the API key previously authenticated. If the connection is not authenticated, this request does nothing.
*
* Note that the WebSocket connection stays open after session.logout request.
* You can continue using the connection, but now the requests will send the apiKey and signature parameters where is needed.
*
* @param parameters JSONObject composed by key-value pairs:
*
* requestId -- optional/String or int
*
* @see
* https://binance-docs.github.io/apidocs/websocket_api/en/#log-out-of-the-session
*/
public void logout(JSONObject parameters) {
this.handler.publicRequest("session.logout", parameters);
}
}