All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.binance.connector.client.impl.spot.UserData Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
package com.binance.connector.client.impl.spot;

import java.util.Map;

import com.binance.connector.client.enums.HttpMethod;
import com.binance.connector.client.utils.ParameterChecker;
import com.binance.connector.client.utils.ProxyAuth;
import com.binance.connector.client.utils.RequestHandler;

/**
 * 

User Data Streams Endpoints

*
* Response will be returned in String format. */ public class UserData { private final String baseUrl; private final RequestHandler requestHandler; private final boolean showLimitUsage; public UserData(String baseUrl, String apiKey, boolean showLimitUsage, ProxyAuth proxy) { this.baseUrl = baseUrl; this.requestHandler = new RequestHandler(apiKey, proxy); this.showLimitUsage = showLimitUsage; } private final String SPOT_LISTEN_KEY = "/api/v3/userDataStream"; /** * Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. * If the account has an active listenKey, that listenKey will be returned and its validity will be extended for 60 minutes. *

* POST /api/v3/userDataStream *
* @return String * @see * https://developers.binance.com/docs/binance-spot-api-docs/user-data-stream#create-a-listenkey-user_stream */ public String createListenKey() { return requestHandler.sendApiRequest(baseUrl, SPOT_LISTEN_KEY, null, HttpMethod.POST, showLimitUsage); } /** * Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. * It's recommended to send a ping about every 30 minutes. *

* PUT /api/v3/userDataStream *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* listenKey -- mandatory/string
* @return String * @see * https://developers.binance.com/docs/binance-spot-api-docs/user-data-stream#pingkeep-alive-a-listenkey-user_stream */ public String extendListenKey(Map parameters) { ParameterChecker.checkParameter(parameters, "listenKey", String.class); return requestHandler.sendApiRequest(baseUrl, SPOT_LISTEN_KEY, parameters, HttpMethod.PUT, showLimitUsage); } /** * Close out a user data stream. *

* DELETE /api/v3/userDataStream *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* listenKey -- mandatory/string
* @return String * @see * https://developers.binance.com/docs/binance-spot-api-docs/user-data-stream#close-a-listenkey-user_stream */ public String closeListenKey(Map parameters) { ParameterChecker.checkParameter(parameters, "listenKey", String.class); return requestHandler.sendApiRequest(baseUrl, SPOT_LISTEN_KEY, parameters, HttpMethod.DELETE, showLimitUsage); } private final String MARGIN_LISTEN_KEY = "/sapi/v1/userDataStream"; /** * POST /sapi/v1/userDataStream *
* @return String * @see * https://developers.binance.com/docs/margin_trading/trade-data-stream/Start-Margin-User-Data-Stream */ public String createMarginListenKey() { return requestHandler.sendApiRequest(baseUrl, MARGIN_LISTEN_KEY, null, HttpMethod.POST, showLimitUsage); } /** * PUT /sapi/v1/userDataStream *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* listenKey -- mandatory/string
* @return String * @see * https://developers.binance.com/docs/margin_trading/trade-data-stream/Keepalive-Margin-User-Data-Stream */ public String extendMarginListenKey(Map parameters) { ParameterChecker.checkParameter(parameters, "listenKey", String.class); return requestHandler.sendApiRequest(baseUrl, MARGIN_LISTEN_KEY, parameters, HttpMethod.PUT, showLimitUsage); } /** * DELETE /sapi/v1/userDataStream *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* listenKey -- mandatory/string
* @return String * @see * https://developers.binance.com/docs/margin_trading/trade-data-stream/Close-Margin-User-Data-Stream#http-request */ public String closeMarginListenKey(Map parameters) { ParameterChecker.checkParameter(parameters, "listenKey", String.class); return requestHandler.sendApiRequest(baseUrl, MARGIN_LISTEN_KEY, parameters, HttpMethod.DELETE, showLimitUsage); } private final String ISOLATED_LISTEN_KEY = "/sapi/v1/userDataStream/isolated"; /** * POST /sapi/v1/userDataStream/isolated *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* symbol -- mandatory/string
* @return String * @see * https://developers.binance.com/docs/margin_trading/trade-data-stream/Start-Isolated-Margin-User-Data-Stream */ public String createIsolatedMarginListenKey(Map parameters) { ParameterChecker.checkParameter(parameters, "symbol", String.class); return requestHandler.sendApiRequest(baseUrl, ISOLATED_LISTEN_KEY, parameters, HttpMethod.POST, showLimitUsage); } /** * PUT /sapi/v1/userDataStream/isolated *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* symbol -- mandatory/string
* listenKey -- mandatory/string
* @return String * @see * https://developers.binance.com/docs/margin_trading/trade-data-stream/Keepalive-Isolated-Margin-User-Data-Stream */ public String extendIsolatedMarginListenKey(Map parameters) { ParameterChecker.checkParameter(parameters, "symbol", String.class); ParameterChecker.checkParameter(parameters, "listenKey", String.class); return requestHandler.sendApiRequest(baseUrl, ISOLATED_LISTEN_KEY, parameters, HttpMethod.PUT, showLimitUsage); } /** * DELETE /sapi/v1/userDataStream/isolated *
* @param * parameters Map of String,Object pair * where String is the name of the parameter and Object is the value of the parameter *

* symbol -- mandatory/string
* listenKey -- mandatory/string
* @return String * @see * https://developers.binance.com/docs/margin_trading/trade-data-stream/Close-Isolated-Margin-User-Data-Stream#http-request */ public String closeIsolatedMarginListenKey(Map parameters) { ParameterChecker.checkParameter(parameters, "symbol", String.class); ParameterChecker.checkParameter(parameters, "listenKey", String.class); return requestHandler.sendApiRequest(baseUrl, ISOLATED_LISTEN_KEY, parameters, HttpMethod.DELETE, showLimitUsage); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy