Collection of auto-generated java connectors for Binance APIs.
Before using the connectors, ensure you have:
For detailed information, refer to the Binance API Documentation.
Each connector is published as a separate maven dependency. For example:
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-spot</artifactId>
<version>6.0.0</version>
</dependency>
Since this repository contains auto-generated code using OpenAPI Generator, we encourage you to:
When creating REST clients (such as SpotRestApi), you use one of the following types of Signature Generator to create signatures (for SIGNED endpoints) based on your security preference:
HMAC
- Use of API Key and Secret Key.
SignatureConfiguration signatureConfiguration = new SignatureConfiguration();
signatureConfiguration.setApiKey("apiKey");
signatureConfiguration.setSecretKey("secretKey");
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setSignatureConfiguration(signatureConfiguration);
SpotRestApi spotRestApi = new SpotRestApi(clientConfiguration);
RSA
or ED25519
- use of API Key and RSA/Ed25519 algorithm keys.
SignatureConfiguration signatureConfiguration = new SignatureConfiguration();
signatureConfiguration.setApiKey("apiKey");
signatureConfiguration.setPrivateKey("path/to/private.key");
// if the private key is protected by a password
signatureConfiguration.setPrivateKeyPass("privateKeyPass");
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setSignatureConfiguration(signatureConfiguration);
SpotRestApi spotRestApi = new SpotRestApi(clientConfiguration);
When creating WebSocket API clients (such as SpotWebSocketApi), you can follow:
HMAC
SignatureConfiguration signatureConfiguration = new SignatureConfiguration();
signatureConfiguration.setApiKey("apiKey");
signatureConfiguration.setSecretKey("secretKey");
WebSocketClientConfiguration clientConfiguration = new WebSocketClientConfiguration();
clientConfiguration.setSignatureConfiguration(signatureConfiguration);
SpotWebSocketApi spotRestApi = new SpotWebSocketApi(clientConfiguration);
Ed25519
or RSA
SignatureConfiguration signatureConfiguration = new SignatureConfiguration();
signatureConfiguration.setApiKey("apiKey");
signatureConfiguration.setPrivateKey("path/to/private.key");
// if the private key is protected by a password
signatureConfiguration.setPrivateKeyPass("privateKeyPass");
WebSocketClientConfiguration clientConfiguration = new WebSocketClientConfiguration();
clientConfiguration.setSignatureConfiguration(signatureConfiguration);
SpotWebSocketApi spotRestApi = new SpotWebSocketApi(clientConfiguration);
// Basic client config
WebSocketClientConfiguration clientConfiguration = SpotWebSocketApiUtil.getClientConfiguration();
// set usePool flag to true
clientConfiguration.setUsePool(true);
// Use the api
SpotWebSocketApi spotWebSocketApi = new SpotWebSocketApi(connectionWrapper);
// Basic client config
WebSocketClientConfiguration clientConfiguration = SpotWebSocketStreamsUtil.getClientConfiguration();
// set usePool flag to true
clientConfiguration.setUsePool(true);
// Use the api
SpotWebSocketStreams api = new SpotWebSocketStreams(clientConfiguration);
// Basic client config
ClientConfiguration clientConfiguration = SpotRestApiUtil.getClientConfiguration();
// Create the HTTP proxy
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("host", 123));
// Add the proxy to the configuration
clientConfiguration.setProxy(proxy);
// Create the Proxy Authenticator
Authenticator proxyAuthenticator = new Authenticator() {
@Override public Request authenticate(Route route, Response response) throws IOException {
String credential = Credentials.basic("username", "password");
return response.request().newBuilder()
.header("Proxy-Authorization", credential)
.build();
}
};
// Add the proxy authenticator to the configuration
clientConfiguration.setProxyAuthenticator(proxyAuthenticator);
// Use with API
SpotRestApi spotRestApi = new SpotRestApi(clientConfiguration);
// Basic client config
WebSocketClientConfiguration clientConfiguration = SpotWebSocketApiUtil.getClientConfiguration();
// Create the HTTP proxy
HttpProxy proxy = new HttpProxy("host", 123);
// Add the proxy to the configuration
clientConfiguration.setWebSocketProxy(proxy);
// Create the Proxy Authentication
BasicAuthentication basicAuthentication = new BasicAuthentication(
URI.create("http://host:123"),
Authentication.ANY_REALM,
"username",
"password"
);
// Add the Proxy Authentication to the configuration
clientConfiguration.setWebSocketProxyAuthentication(basicAuthentication);
// Use with API
SpotWebSocketApi spotWebSocketApi = new SpotWebSocketApi(clientConfiguration);
// Basic client config
WebSocketClientConfiguration clientConfiguration = SpotWebSocketStreamsUtil.getClientConfiguration();
// Create the HTTP proxy
HttpProxy proxy = new HttpProxy("host", 123);
// Add the proxy to the configuration
clientConfiguration.setWebSocketProxy(proxy);
// Create the Proxy Authentication
BasicAuthentication basicAuthentication = new BasicAuthentication(
URI.create("http://host:123"),
Authentication.ANY_REALM,
"username",
"password"
);
// Add the Proxy Authentication to the configuration
clientConfiguration.setWebSocketProxyAuthentication(basicAuthentication);
// Use with API
SpotWebSocketStreams spotWebSocketApi = new SpotWebSocketStreams(clientConfiguration);
Algo: Rest API
C2c: Rest API
Convert: Rest API
Copy Trading: Rest API
Crypto Loan: Rest API
Derivatives Trading Coin Futures: Rest API - WebSocket API - WebSocket Streams
Derivatives Trading Options: Rest API - WebSocket Streams
Derivatives Trading Portfolio Margin: Rest API
Derivatives Trading Portfolio Margin Pro: Rest API
Derivatives Trading Usds Futures: Rest API - WebSocket API - WebSocket Streams
Dual Investment: Rest API
Fiat: Rest API
Gift Card: Rest API
Margin Trading: Rest API
Mining: Rest API
Nft: Rest API
Pay: Rest API
Rebate: Rest API
Simple Earn: Rest API
Spot: Rest API - WebSocket API - WebSocket Streams
Staking: Rest API
Sub Account: Rest API
Vip Loan: Rest API
Wallet: Rest API
This project is licensed under the MIT License - see the LICENSE file for details.