com.binance.connector.client.impl.spot.Mining 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.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;
import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator;
import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator;
/**
* Mining Endpoints
* All endpoints under the
* Mining Endpoint
* section of the API documentation will be implemented in this class.
*
* Response will be returned in String format.
*/
public class Mining {
private final String baseUrl;
private final RequestHandler requestHandler;
private final boolean showLimitUsage;
public Mining(String baseUrl, String apiKey, String secretKey, boolean showLimitUsage, ProxyAuth proxy) {
this.baseUrl = baseUrl;
this.requestHandler = new RequestHandler(apiKey, new HmacSignatureGenerator(secretKey), proxy);
this.showLimitUsage = showLimitUsage;
}
public Mining(String baseUrl, String apiKey, SignatureGenerator signatureGenerator, boolean showLimitUsage, ProxyAuth proxy) {
this.baseUrl = baseUrl;
this.requestHandler = new RequestHandler(apiKey, signatureGenerator, proxy);
this.showLimitUsage = showLimitUsage;
}
private final String ALGO = "/sapi/v1/mining/pub/algoList";
/**
* GET /sapi/v1/mining/pub/algoList
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#acquiring-algorithm-user_data
*/
public String algorithm(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, ALGO, parameters, HttpMethod.GET, showLimitUsage);
}
private final String COIN_NAME = "/sapi/v1/mining/pub/coinList";
/**
* GET /sapi/v1/mining/pub/coinList
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#acquiring-coinname-user_data
*/
public String coinName(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, COIN_NAME, parameters, HttpMethod.GET, showLimitUsage);
}
private final String DETAIL_MINER_LIST = "/sapi/v1/mining/worker/detail";
/**
* GET /sapi/v1/mining/worker/detail
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* algo -- mandatory/string -- sha256
* userName -- mandatory/string -- Mining account
* workerName -- mandatory/string -- Miner's name(required)
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#request-for-detail-miner-list-user_data
*/
public String detailMinerList(Map parameters) {
ParameterChecker.checkParameter(parameters, "algo", String.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
ParameterChecker.checkParameter(parameters, "workerName", String.class);
return requestHandler.sendSignedRequest(baseUrl, DETAIL_MINER_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String MINER_LIST = "/sapi/v1/mining/worker/list";
/**
* GET /sapi/v1/mining/worker/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* algo -- mandatory/string -- sha256
* userName -- mandatory/string -- Mining account
* pageIndex -- optional/int -- Page number,default is first page,start form 1
* sort -- optional/int -- sort sequence(default=0)0 positive sequence, 1 negative sequence
* sortColumn -- optional/int -- Sort by( default 1):
* 1: miner name,
* 2: real-time computing power,
* 3: daily average computing power,
* 4: real-time rejection rate,
* 5: last submission time
* workerStatus -- optional/int -- miners status(default=0)0 all,1 valid,2 invalid,3 failure
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#request-for-miner-list-user_data
*/
public String minerList(Map parameters) {
ParameterChecker.checkParameter(parameters, "algo", String.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
return requestHandler.sendSignedRequest(baseUrl, MINER_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String EARNING_LIST = "/sapi/v1/mining/payment/list";
/**
* GET /sapi/v1/mining/payment/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* algo -- mandatory/string -- sha256
* userName -- mandatory/string -- Mining account
* coin -- optional/string
* startDate -- optional/long -- Search date, millisecond timestamp, while empty query all
* endDate -- optional/long -- Search date, millisecond timestamp, while empty query all
* pageIndex -- optional/int -- Page number, empty default first page, starting from 1
* pageSize -- optional/int -- Number of pages, minimum 10, maximum 200
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#earnings-list-user_data
*/
public String earningList(Map parameters) {
ParameterChecker.checkParameter(parameters, "algo", String.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
return requestHandler.sendSignedRequest(baseUrl, EARNING_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String BONUS_LIST = "/sapi/v1/mining/payment/other";
/**
* GET /sapi/v1/mining/payment/other
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* algo -- mandatory/string -- sha256
* userName -- mandatory/string -- Mining account
* coin -- optional/string
* startDate -- optional/long -- Search date, millisecond timestamp, while empty query all
* endDate -- optional/long -- Search date, millisecond timestamp, while empty query all
* pageIndex -- optional/int -- Page number, empty default first page, starting from 1
* pageSize -- optional/int -- Number of pages, minimum 10, maximum 200
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#extra-bonus-list-user_data
*/
public String bonusList(Map parameters) {
ParameterChecker.checkParameter(parameters, "algo", String.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
return requestHandler.sendSignedRequest(baseUrl, BONUS_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String HASHRATE_RESALE_LIST = "/sapi/v1/mining/hash-transfer/config/details/list";
/**
* GET /sapi/v1/mining/hash-transfer/config/details/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* pageIndex -- optional/int -- Page number, empty default first page, starting from 1
* pageSize -- optional/int -- Number of pages, minimum 10, maximum 200
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#hashrate-resale-list-user_data
*/
public String hashrateResaleList(Map parameters) {
return requestHandler.sendSignedRequest(baseUrl, HASHRATE_RESALE_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String HASHRATE_RESALE_DETAIL = "/sapi/v1/mining/hash-transfer/profit/details";
/**
* GET /sapi/v1/mining/hash-transfer/profit/details
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* configId -- mandatory/int -- Mining ID
* userName -- mandatory/string -- Mining Account
* pageIndex -- optional/int -- Page number, empty default first page, starting from 1
* pageSize -- optional/int -- Number of pages, minimum 10, maximum 200
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#hashrate-resale-detail-user_data
*/
public String hashrateResaleDetail(Map parameters) {
ParameterChecker.checkParameter(parameters, "configId", Integer.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
return requestHandler.sendSignedRequest(baseUrl, HASHRATE_RESALE_DETAIL, parameters, HttpMethod.GET, showLimitUsage);
}
private final String HASHRATE_RESALE_REQUEST = "/sapi/v1/mining/hash-transfer/config";
/**
* GET /sapi/v1/mining/hash-transfer/config
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* userName -- mandatory/string -- Mining Account
* algo -- mandatory/string -- Transfer algorithm(sha256)
* endDate -- mandatory/long -- Resale End Time (Millisecond timestamp)
* startDate -- mandatory/long -- Resale Start Time(Millisecond timestamp)
* toPoolUser -- mandatory/string -- Mining Account
* hashRate -- mandatory/long -- Resale hashrate h/s must be transferred (BTC is greater than 500000000000 ETH is greater than 500000)
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#hashrate-resale-request-user_data
*/
public String hashrateResaleRequest(Map parameters) {
ParameterChecker.checkParameter(parameters, "userName", String.class);
ParameterChecker.checkParameter(parameters, "algo", String.class);
ParameterChecker.checkParameter(parameters, "endDate", Long.class);
ParameterChecker.checkParameter(parameters, "startDate", Long.class);
ParameterChecker.checkParameter(parameters, "toPoolUser", String.class);
ParameterChecker.checkParameter(parameters, "hashRate", Long.class);
return requestHandler.sendSignedRequest(baseUrl, HASHRATE_RESALE_REQUEST, parameters, HttpMethod.POST, showLimitUsage);
}
private final String CANCEL_HASHRATE_RESALE_CONFIG = "/sapi/v1/mining/hash-transfer/config/cancel";
/**
* GET /sapi/v1/mining/hash-transfer/config/cancel
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* configId -- mandatory/int -- Mining ID
* userName -- mandatory/string -- Mining Account
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#cancel-hashrate-resale-configuration-user_data
*/
public String cancelHashrateResaleConfig(Map parameters) {
ParameterChecker.checkParameter(parameters, "configId", Integer.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
return requestHandler.sendSignedRequest(baseUrl, CANCEL_HASHRATE_RESALE_CONFIG, parameters, HttpMethod.POST, showLimitUsage);
}
private final String STATSTICS_LIST = "/sapi/v1/mining/statistics/user/status";
/**
* GET /sapi/v1/mining/statistics/user/status
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* algo -- mandatory/string -- Algorithm(sha256)
* userName -- mandatory/string -- Mining Account
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#statistic-list-user_data
*/
public String statsticsList(Map parameters) {
ParameterChecker.checkParameter(parameters, "algo", String.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
return requestHandler.sendSignedRequest(baseUrl, STATSTICS_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ACCOUNT_LIST = "/sapi/v1/mining/statistics/user/list";
/**
* GET /sapi/v1/mining/statistics/user/list
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* algo -- mandatory/string -- Algorithm(sha256)
* userName -- mandatory/string -- Mining Account
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#account-list-user_data
*/
public String accountList(Map parameters) {
ParameterChecker.checkParameter(parameters, "algo", String.class);
ParameterChecker.checkParameter(parameters, "userName", String.class);
return requestHandler.sendSignedRequest(baseUrl, ACCOUNT_LIST, parameters, HttpMethod.GET, showLimitUsage);
}
private final String ACCOUNT_EARNING = "/sapi/v1/mining/payment/uid";
/**
* GET /sapi/v1/mining/payment/uid
*
* @param
* parameters Map of String,Object pair
* where String is the name of the parameter and Object is the value of the parameter
*
* algo -- mandatory/string -- Algorithm(sha256)
* startDate -- optional/long -- Millisecond timestamp
* endDate -- optional/long -- Millisecond timestamp
* pageIndex -- optional/int -- Default 1
* pageSize -- optional/int -- Min 10,Max 200
* recvWindow -- optional/long
* @return String
* @see
* https://binance-docs.github.io/apidocs/spot/en/#mining-account-earning-user_data
*/
public String accountEarning(Map parameters) {
ParameterChecker.checkParameter(parameters, "algo", String.class);
return requestHandler.sendSignedRequest(baseUrl, ACCOUNT_EARNING, parameters, HttpMethod.GET, showLimitUsage);
}
}