Market
Installation
- Maven
- Gradle
pom.xml
<dependency>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<version>{{version}}</version>
</dependency>
build.gradle
implementation '{{groupId}}:{{artifactId}}:{{version}}'
Client instantiation
MarketDataClient client = new MarketDataClient(key, secret);
Features
Test connectivity
client.ping().sync();
Get server time
- Sync
- Async
try{
ServerTimeRespons res = client.getServerTime().sync();
}catch(ApiException e){
//...
}
client.getServerTime().async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get exchange info
- All symbols
- One symbol
- Multiple symbols
- Sync
- Async
try{
ExchangeInfo res = client.getExchangeInfo().sync();
}catch(ApiException e){
//...
}
client.getExchangeInfo().async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
ExchangeInfo res = client.getExchangeInfo(new ExchangeInfoParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getExchangeInfo(new ExchangeInfoParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
ExchangeInfo res = client.getExchangeInfo(new ExchangeInfoParams(symbols[])).sync();
}catch(ApiException e){
//...
}
client.getExchangeInfo(new ExchangeInfoParams(symbols[])).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get a symbol's order book
- One symbol
- With limit (Enum)
- With limit (String)
- Sync
- Async
try{
OrderBook res = client.getOrderBook(new OrderBookParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getOrderBook(new OrderBookParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
OrderBook res = client.getOrderBook(new OrderBookParams(symbol,OrderBookLimit.LIMIT_10)).sync();
}catch(ApiException e){
//...
}
client.getOrderBook(new OrderBookParams(symbol,OrderBookLimit.LIMIT_10)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
OrderBook res = client.getOrderBook(new OrderBookParams(symbol,"10")).sync();
}catch(ApiException e){
//...
}
client.getOrderBook(new OrderBookParams(symbol,"10")).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
caution
The String value must match one of the OrderBookLimit
values or the request will fail
Get recent trades
- One symbol
- With limit
- Sync
- Async
try{
List<Trade> res = client.getTrades(new TradesParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getTrades(new TradesParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
List<Trade> res = client.getTrades(new TradesParams(symbol,10)).sync();
}catch(ApiException e){
//...
}
client.getTrades(new TradesParams(symbol,10)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get historical trades
- Default
- With limit
- Sync
- Async
try{
List<Trade> res = client.getHistoricalTrades(new TradesParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getHistoricalTrades(new TradesParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
List<Trade> res = client.getHistoricalTrades(new TradesParams(symbol,10)).sync();
}catch(ApiException e){
//...
}
client.getHistoricalTrades(new TradesParams(symbol,10)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get compressed/aggregate trades List
- Default
- Framed
- Sync
- Async
try{
List<AggTrade> res = client.getAggTrades(new AggTradeParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getAggTrades(new AggTradeParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
List<AggTrade> res = client.getAggTrades(new AggTradeParams(symbol), new TimeFrame(startTime, endTime, limit)).sync();
}catch(ApiException e){
//...
}
client.getAggTrades(new AggTradeParams(symbol), new TimeFrame(startTime, endTime, limit)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get Klines / candles
- Enum interval
- String interval
- Sync
- Async
try{
List<Candle> res = client.getKlines(new KlinesParams(symbol, CandlestickInterval.ONE_MINUTE)).sync();
}catch(ApiException e){
//...
}
client.getKlines(new KlinesParams(symbol, CandlestickInterval.ONE_MINUTE)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
List<Candle> res = client.getKlines(new KlinesParams(symbol, "1m")).sync();
}catch(ApiException e){
//...
}
client.getKlines(new KlinesParams(symbol, "1m")).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
caution
The String interval must correspond to one of the CandlestickInterval
else the request will throw an ApiException
Get average price
- Sync
- Async
try{
AveragePrice res = client.getAveragePrice(new AveragePriceParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getAveragePrice(new AveragePriceParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get 24h ticker statistics
- Sync
- Async
try{
TickerStatistics res = client.get24hTickerStatistics(new TickerStatisticsParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.get24hTickerStatistics(new TickerStatisticsParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- All symbols
- Multiple symbols
- Sync
- Async
try{
List<TickersStatistics> res = client.get24hTickerStatistics().sync();
}catch(ApiException e){
//...
}
client.get24hTickerStatistics().async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
List<TickersStatistics> res = client.get24hTickerStatistics(new TickerStatisticsParams(symbols[])).sync();
}catch(ApiException e){
//...
}
client.get24hTickerStatistics(new TickerStatisticsParams(symbols[])).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get price ticker
- Sync
- Async
try{
PriceTicker res = client.getTicker(new PriceTickerParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getTicker(new PriceTickerParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- All symbols
- Multiple symbols
- Sync
- Async
try{
List<PriceTicker> res = client.getTicker().sync();
}catch(ApiException e){
//...
}
client.getTicker().async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
List<PriceTicker> res = client.getTicker(new PriceTickersParams(symbols[])).sync();
}catch(ApiException e){
//...
}
client.getTicker(new PriceTickersParams(symbols[])).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
Get order book ticker
- Default
- With limit (Enum)
- With limit (String)
- Sync
- Async
try{
OrderBook res = client.getOrderBook(new OrderBookParams(symbol)).sync();
}catch(ApiException e){
//...
}
client.getOrderBook(new OrderBookParams(symbol)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
OrderBook res = client.getOrderBook(new OrderBookParams(symbol, OrderBookLimit.LIMIT_10)).sync();
}catch(ApiException e){
//...
}
client.getOrderBook(new OrderBookParams(symbol, OrderBookLimit.LIMIT_10)).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
- Sync
- Async
try{
OrderBook res = client.getOrderBook(new OrderBookParams(symbol, "10")).sync();
}catch(ApiException e){
//...
}
client.getOrderBook(new OrderBookParams(symbol, "10")).async((response, exception) -> {
if(exception == null){
//...
}else{
//...
}
});
caution
The String value must match one of the OrderBookLimit
values or the request will fail