binance-exchange/binance-java-api

Can I use spot testnet api with this library?

hamidrezaabroshan opened this issue · 8 comments

How can I use testnet api with this library? and is it possible to change uri of requests?

aibar commented

+1

I forked this project precisely to allow connections to endpoint testnet.binance.vision
There are options for both websocket streaming and non-streaming clients.
https://github.com/georgesoler/binance-java-api
Created a pull request.

Really useful, if it would be documented, on wich object is the new setter ?

or does it implement a unique apikey-inspector function

The way to use this feature is to call one of the two overloaded static constructors for either non-auth or authenticated clients:

BinanceApiClientFactory.newInstance​(boolean useTestnet, boolean useTestnetStreaming)
or
BinanceApiClientFactory.newInstance​(java.lang.String apiKey, java.lang.String secret, boolean useTestnet, boolean useTestnetStreaming)

Parameters are documented in the javadoc.

The pull request for this fork has just been approved and merged into the main branch joaopsilva/binance-java-api so you are better off getting it from there since I may delete my branch in the future.

Hi, its still not possible to use testnet. This is the BinanceApiClientFactory class , there is no function that recieves two boolean values

import com.binance.api.client.impl.BinanceApiWebSocketClientImpl;

public class BinanceApiClientFactory {
private String apiKey;
private String secret;

private BinanceApiClientFactory(String apiKey, String secret) {
    this.apiKey = apiKey;
    this.secret = secret;
}

public static BinanceApiClientFactory newInstance(String apiKey, String secret) {
    return new BinanceApiClientFactory(apiKey, secret);
}

public static BinanceApiClientFactory newInstance() {
    return new BinanceApiClientFactory((String)null, (String)null);
}

public BinanceApiRestClient newRestClient() {
    return new BinanceApiRestClientImpl(this.apiKey, this.secret);
}

public BinanceApiAsyncRestClient newAsyncRestClient() {
    return new BinanceApiAsyncRestClientImpl(this.apiKey, this.secret);
}

public BinanceApiAsyncMarginRestClient newAsyncMarginRestClient() {
    return new BinanceApiAsyncMarginRestClientImpl(this.apiKey, this.secret);
}

public BinanceApiMarginRestClient newMarginRestClient() {
    return new BinanceApiMarginRestClientImpl(this.apiKey, this.secret);
}

public BinanceApiWebSocketClient newWebSocketClient() {
    return new BinanceApiWebSocketClientImpl(BinanceApiServiceGenerator.getSharedClient());
}

public BinanceApiSwapRestClient newSwapRestClient() {
    return new BinanceApiSwapRestClientImpl(this.apiKey, this.secret);
}

}