Collection of auto-generated java connectors for Binance APIs.
Before using the connectors, ensure you have:
- Java (version >= 11)
- binance-algo - Algo Trading connector
- Deprecated:
binance-auto-invest - Auto Invest connector - binance-c2c - C2C connector
- binance-convert - Convert connector
- binance-copy-trading - Copy Trading connector
- binance-crypto-loan - Crypto Loan connector
- binance-derivatives-trading-coin-futures - Derivatives Trading (COIN-M Futures) connector
- binance-derivatives-trading-options - Derivatives Trading (Options) connector
- binance-derivatives-trading-portfolio-margin - Derivatives Trading (Portfolio Margin) connector
- binance-derivatives-trading-portfolio-margin-pro - Derivatives Trading (Portfolio Margin Pro) connector
- binance-derivatives-trading-usds-futures - Derivatives Trading (USDS-M Futures) connector
- binance-dual-investment - Dual Investment connector
- binance-fiat - Fiat connector
- binance-gift-card - Gift Card connector
- binance-margin-trading - Margin Trading connector
- binance-mining - Mining connector
- binance-nft - NFT connector
- binance-pay - Pay connector
- binance-rebate - Rebate connector
- binance-simple-earn - Simple Earn connector
- binance-spot - Spot Trading connector
- binance-staking - Staking connector
- binance-sub-account - Sub Account connector
- binance-vip-loan - VIP Loan connector
- binance-wallet - Wallet connector
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>2.0.0</version>
</dependency>
Since this repository contains auto-generated code using OpenAPI Generator, we encourage you to:
- Open a GitHub issue to discuss your ideas or report bugs
- Allow maintainers to implement necessary changes through the code generation process
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
orED25519
- 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
orRSA
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.