binance-exchange / binance-java-api

binance-java-api is a lightweight Java library for the Binance API, supporting synchronous and asynchronous requests, as well as event streaming using WebSockets.
MIT License
831 stars 628 forks source link

Can I use spot testnet api with this library? #370

Open hamidrezaabroshan opened 3 years ago

hamidrezaabroshan commented 3 years ago

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

ghost commented 3 years ago

+1

georgesoler commented 3 years ago

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.

AndreJuntermanns commented 3 years ago

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

AndreJuntermanns commented 3 years ago

or does it implement a unique apikey-inspector function

georgesoler commented 3 years ago

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.

AndreJuntermanns commented 3 years ago

You committed a essential feature for development. This function is important....also right on time. Thank you. ..... rest email stuff ... 🤦

naserkaka commented 2 years ago

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);
}

}

georgesoler commented 1 year ago

Hello naserkaka, I am no longer working on Binance code but as far as I know this feature was accepted and pulled from my branch and subsequently merged into binance-exchange:master sometime last June. Two possibilities- -You are looking at the wrong fork or branch. -The feature was removed from binance-exchange:master sometime between last June and now. Good luck. -George

On Sun, 13 Mar 2022 at 05:34, naserkaka @.***> wrote:

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); }

}

— Reply to this email directly, view it on GitHub https://github.com/binance-exchange/binance-java-api/issues/370#issuecomment-1066092220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5GCDEAGURSAD5XE457IPTU7XOG3ANCNFSM444PJJ5A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>