bitforex-java-api is a lightweight Java library for interacting with the Bitforex API
- getBalance
- createOrder
- getOpenOrders
- cancelOrder
- Install library into your Maven's local repository by running
mvn install
- Add the following Maven dependency to your project's
pom.xml
:
<dependency>
<groupId>com.github.mpawlucz.bitforex</groupId>
<artifactId>bitforex-java-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
BitforexRestApi api = new BitforexRestApi(ApiKey.builder()
.key("<YOUR-API-KEY>")
.secret("<YOUR-API-SECRET>")
.build());
final BalanceResponse balance = api.getBalance();
if (balance.getSuccess()){
for (BalanceEntry balanceEntry : balance.getData()) {
if (balanceEntry.getTotal().compareTo(BigDecimal.ZERO) > 0){
System.out.println(balanceEntry.getCurrency() + ": " + balanceEntry.getTotal());
}
}
} else {
System.out.println("error: " + balance.getMessage());
}
final TradeResponse trade = api.trade(TradeRequest.builder()
.base("ETH")
.quote("BTC")
.volume(new BigDecimal("0.001"))
.price(new BigDecimal("0.01"))
.isBuy(true)
.build());
if (!trade.isSuccess()){
throw new RuntimeException("Create order failed: " + trade.getMessage());
}
System.out.println(trade.getData().getOrderId());