com.bybit.api.client.websocket.api.WebSocketApiAuth Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bybit-java-api Show documentation
Show all versions of bybit-java-api Show documentation
The Official Java API connector for Bybit's HTTP and WebSocket APIs.
Dive into a plethora of functionalities:
- Market Data Retrieval
- Trade Execution
- Position Management
- Account and Asset Info Retrieval
- User and Upgrade Management
— Public Websocket Streaming
- Private Websocket Streaming
- Lending Institution and Client
- Broker Earning Data
The newest version!
package com.bybit.api.client.websocket.api;
import com.bybit.api.client.websocket.callback.WebSocketApiRequestHandler;
import org.json.JSONObject;
/**
* 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 final 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);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy