net.sealake.binance.api.client.impl.BinanceApiService Maven / Gradle / Ivy
The newest version!
package net.sealake.binance.api.client.impl;
import net.sealake.binance.api.client.constant.BinanceApiConstants;
import net.sealake.binance.api.client.domain.OrderSide;
import net.sealake.binance.api.client.domain.OrderType;
import net.sealake.binance.api.client.domain.TimeInForce;
import net.sealake.binance.api.client.domain.account.Account;
import net.sealake.binance.api.client.domain.account.DepositAddress;
import net.sealake.binance.api.client.domain.account.DepositHistory;
import net.sealake.binance.api.client.domain.account.NewOrderResponse;
import net.sealake.binance.api.client.domain.account.NewOrderResponseType;
import net.sealake.binance.api.client.domain.account.Order;
import net.sealake.binance.api.client.domain.account.Trade;
import net.sealake.binance.api.client.domain.account.TradeHistoryItem;
import net.sealake.binance.api.client.domain.account.WithdrawHistory;
import net.sealake.binance.api.client.domain.account.WithdrawResult;
import net.sealake.binance.api.client.domain.event.ListenKey;
import net.sealake.binance.api.client.domain.general.Asset;
import net.sealake.binance.api.client.domain.general.ExchangeInfo;
import net.sealake.binance.api.client.domain.general.ServerTime;
import net.sealake.binance.api.client.domain.market.AggTrade;
import net.sealake.binance.api.client.domain.market.BookTicker;
import net.sealake.binance.api.client.domain.market.Candlestick;
import net.sealake.binance.api.client.domain.market.OrderBook;
import net.sealake.binance.api.client.domain.market.TickerPrice;
import net.sealake.binance.api.client.domain.market.TickerStatistics;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Query;
import retrofit2.http.Url;
/**
* Binance's REST API URL mappings and endpoint security configuration.
*/
public interface BinanceApiService {
// General endpoints
@GET("/api/v1/ping")
Call ping();
@GET("/api/v1/time")
Call getServerTime();
@GET("/api/v1/exchangeInfo")
Call getExchangeInfo();
@GET
Call> getAllAssets(@Url String url);
// Market data endpoints
@GET("/api/v1/depth")
Call getOrderBook(@Query("symbol") String symbol, @Query("limit") Integer limit);
@GET("/api/v1/trades")
Call> getTrades(@Query("symbol") String symbol, @Query("limit") Integer limit);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)
@GET("/api/v1/historicalTrades")
Call> getHistoricalTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId);
@GET("/api/v1/aggTrades")
Call> getAggTrades(@Query("symbol") String symbol, @Query("fromId") String fromId, @Query("limit") Integer limit,
@Query("startTime") Long startTime, @Query("endTime") Long endTime);
@GET("/api/v1/klines")
Call> getCandlestickBars(@Query("symbol") String symbol, @Query("interval") String interval, @Query("limit") Integer limit,
@Query("startTime") Long startTime, @Query("endTime") Long endTime);
@GET("/api/v1/ticker/24hr")
Call get24HrPriceStatistics(@Query("symbol") String symbol);
@GET("/api/v1/ticker/24hr")
Call> getAll24HrPriceStatistics();
@GET("/api/v1/ticker/allPrices")
Call> getLatestPrices();
@GET("/api/v3/ticker/price")
Call getLatestPrice(@Query("symbol") String symbol);
@GET("/api/v1/ticker/allBookTickers")
Call> getBookTickers();
// Account endpoints
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@POST("/api/v3/order")
Call newOrder(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type,
@Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, @Query("price") String price,
@Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice,
@Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType,
@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@POST("/api/v3/order/test")
Call newOrderTest(@Query("symbol") String symbol, @Query("side") OrderSide side, @Query("type") OrderType type,
@Query("timeInForce") TimeInForce timeInForce, @Query("quantity") String quantity, @Query("price") String price,
@Query("newClientOrderId") String newClientOrderId, @Query("stopPrice") String stopPrice,
@Query("icebergQty") String icebergQty, @Query("newOrderRespType") NewOrderResponseType newOrderRespType,
@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/api/v3/order")
Call getOrderStatus(@Query("symbol") String symbol, @Query("orderId") Long orderId,
@Query("origClientOrderId") String origClientOrderId, @Query("recvWindow") Long recvWindow,
@Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@DELETE("/api/v3/order")
Call cancelOrder(@Query("symbol") String symbol, @Query("orderId") Long orderId,
@Query("origClientOrderId") String origClientOrderId, @Query("newClientOrderId") String newClientOrderId,
@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/api/v3/openOrders")
Call> getOpenOrders(@Query("symbol") String symbol, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/api/v3/allOrders")
Call> getAllOrders(@Query("symbol") String symbol, @Query("orderId") Long orderId,
@Query("limit") Integer limit, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/api/v3/account")
Call getAccount(@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/api/v3/myTrades")
Call> getMyTrades(@Query("symbol") String symbol, @Query("limit") Integer limit, @Query("fromId") Long fromId,
@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@POST("/wapi/v3/withdraw.html")
Call withdraw(@Query("asset") String asset, @Query("address") String address, @Query("amount") String amount, @Query("name") String name, @Query("addressTag") String addressTag,
@Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/wapi/v3/depositHistory.html")
Call getDepositHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/wapi/v3/withdrawHistory.html")
Call getWithdrawHistory(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_SIGNED_HEADER)
@GET("/wapi/v3/depositAddress.html")
Call getDepositAddress(@Query("asset") String asset, @Query("recvWindow") Long recvWindow, @Query("timestamp") Long timestamp);
// User stream endpoints
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)
@POST("/api/v1/userDataStream")
Call startUserDataStream();
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)
@PUT("/api/v1/userDataStream")
Call keepAliveUserDataStream(@Query("listenKey") String listenKey);
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)
@DELETE("/api/v1/userDataStream")
Call closeAliveUserDataStream(@Query("listenKey") String listenKey);
}