Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Before using the connectors, ensure you have:
- [binance-staking](clients/staking) - Staking connector
- [binance-sub-account](clients/sub-account) - Sub Account connector
- [binance-vip-loan](clients/vip-loan) - VIP Loan connector
- [binance-w3w-prediction](clients/w3w-prediction) - W3W Prediction
- [binance-wallet](clients/wallet) - Wallet connector

## Documentation
Expand Down Expand Up @@ -255,6 +256,8 @@ When creating WebSocket API clients (such as SpotWebSocketApi), you can follow:

**Vip Loan**: [Rest API](clients/vip-loan/example_rest.md)

**W3W Prediction**: [Rest API](clients/w3w-prediction/example_rest.md)

**Wallet**: [Rest API](clients/wallet/example_rest.md)

## License
Expand Down
1 change: 1 addition & 0 deletions clients/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<module>staking</module>
<module>sub-account</module>
<module>vip-loan</module>
<module>w3w-prediction</module>
<module>wallet</module>
<!-- add_module -->
</modules>
Expand Down
5 changes: 5 additions & 0 deletions clients/w3w-prediction/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 1.0.0 - 2026-06-29

- Initial release
163 changes: 163 additions & 0 deletions clients/w3w-prediction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Binance Java W3W Prediction Connector

[![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-java)](https://github.com/binance/binance-connector-java/issues)
[![Code Style: Spotless](https://img.shields.io/badge/code%20style-spotless-ff69b4)](https://github.com/diffplug/spotless)
[![Maven Central Version](https://img.shields.io/maven-central/v/io.github.binance/binance-w3w-prediction)](https://central.sonatype.com/artifact/io.github.binance/binance-w3w-prediction)
![Java Version](https://img.shields.io/badge/Java-%3E=11-brightgreen)
[![Known Vulnerabilities](https://snyk.io/test/github/binance/binance-connector-java/badge.svg)](https://snyk.io/test/github/binance/binance-connector-java)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

This is a client library for the Binance W3W Prediction API, enabling developers to interact programmatically with Binance's W3W Prediction trading platform. The library provides tools to place and manage prediction market orders, query positions and transfer funds through the REST API:

- [REST API](./src/main/java/com/binance/connector/client/w3w-prediction/rest/api)
- WebSocket API: Currently under development

## Table of Contents

- [Supported Features](#supported-features)
- [Installation](#installation)
- [Documentation](#documentation)
- [REST APIs](#rest-apis)
- [Testing](#testing)
- [Migration Guide](#migration-guide)
- [Contributing](#contributing)
- [License](#license)

## Supported Features

- REST API Endpoints:
- `/sapi/v1/w3w/wallet/prediction/*`
- Inclusion of test cases and examples for quick onboarding.

## Installation

To use this library, ensure your environment is running Java version **11** or newer.

Then add dependency to pom.xml:

```xml
<dependency>
<groupId>io.github.binance</groupId>
<artifactId>binance-w3w-prediction</artifactId>
<version>1.0.0</version>
</dependency>
```

## Documentation

For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/w3w_prediction).

### REST APIs

All REST API endpoints are available through the [`rest`](./src/main/java/com/binance/connector/client/w3w_prediction/rest) module. Note that some endpoints require authentication using your Binance API credentials.

```java
import com.binance.connector.client.w3w_prediction.rest.W3WPredictionRestApiUtil;
import com.binance.connector.client.w3w_prediction.rest.api.W3WPredictionRestApi;
import com.binance.connector.client.common.ApiException;
import com.binance.connector.client.common.ApiResponse;
import com.binance.connector.client.common.configuration.ClientConfiguration;
import com.binance.connector.client.common.configuration.SignatureConfiguration;

public static void main(String[] args) {
ClientConfiguration clientConfiguration = W3WPredictionRestApiUtil.getClientConfiguration();
SignatureConfiguration signatureConfiguration = new SignatureConfiguration();
signatureConfiguration.setApiKey("apiKey");
signatureConfiguration.setPrivateKey("path/to/private.key");
clientConfiguration.setSignatureConfiguration(signatureConfiguration);
W3WPredictionRestApi api = new W3WPredictionRestApi(clientConfiguration);
}
```

More examples can be found in the [`examples/rest`](./../../examples/w3w-prediction/src/main/java/com/binance/connector/client/w3w_prediction/rest) folder.

#### Configuration Options

The REST API supports the following advanced configuration options:

- `proxy`: Proxy configuration for http client.
- `certificatePinner`: Certificate Pinner configuration for http client.
- `connectTimeout`: Timeout for requests in milliseconds (default: 1000 ms).
- `readTimeout`: Timeout for requests in milliseconds (default: 5000 ms).
- `compression`: Enable response compression (default: true).
- `retries`: Number of retry attempts for failed requests (default: 3).
- `backoff`: Delay in milliseconds between retries (default: 200 ms).
- `timeUnit`: TimeUnit to be returned by API (default MILLISECOND).
- `apiKey`: Binance API Key
- `secretKey`: Binance Secret Key, if using HMAC w3w-predictionrithm
- `privateKey`: RSA or ED25519 private key for authentication.
- `privateKeyPass`: Passphrase for the private key, if encrypted.

##### Timeout

You can configure a timeout for requests in milliseconds. If the request exceeds the specified timeout, it will be aborted. See the [Timeout example](./docs/rest-api/timeout.md) for detailed usage.

##### Proxy

The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest-api/proxy.md) for detailed usage.

##### Keep-Alive

Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest-api/keepAlive.md) for detailed usage.

##### Compression

Enable or disable response compression. See the [Compression example](./docs/rest-api/compression.md) for detailed usage.

##### Retries

Configure the number of retry attempts and delay in milliseconds between retries for failed requests. See the [Retries example](./docs/rest-api/retries.md) for detailed usage.

##### Key Pair Based Authentication

The REST API supports key pair-based authentication for secure communication. You can use `RSA` or `ED25519` keys for signing requests. See the [Key Pair Based Authentication example](./docs/rest-api/key-pair-authentication.md) for detailed usage.

##### Certificate Pinning

To enhance security, you can use certificate pinning with the `httpsAgent` option in the configuration. This ensures the client only communicates with servers using specific certificates. See the [Certificate Pinning example](./docs/rest-api/certificate-pinning.md) for detailed usage.

#### Error Handling

The REST API provides detailed error types to help you handle issues effectively:

- `ConnectorClientError`: General client error.

See the [Error Handling example](./docs/rest-api/error-handling.md) for detailed usage.

If `basePath` is not provided, it defaults to `https://api.binance.com`.

## Testing

To run the tests:

```bash
mvn -f clients/pom.xml -pl w3w-prediction test
```

The tests cover:

- REST API endpoints
- Signature generation

## Migration Guide

If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/rest-api/migration-guide.md) for detailed steps.

## Contributing

Contributions are welcome!

Since this repository contains auto-generated code, we encourage you to start by opening a GitHub issue to discuss your ideas or suggest improvements. This helps ensure that changes align with the project's goals and auto-generation processes.

To contribute:

1. Open a GitHub issue describing your suggestion or the bug you've identified.
2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.

Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.

Thank you for your contributions!

## License

This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details.
13 changes: 13 additions & 0 deletions clients/w3w-prediction/docs/AccountType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# AccountType

## Enum


* `SPOT` (value: `"SPOT"`)

* `FUNDING` (value: `"FUNDING"`)



15 changes: 15 additions & 0 deletions clients/w3w-prediction/docs/BatchCancelOrdersRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# BatchCancelOrdersRequest


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**walletAddress** | **String** | User&#39;s prediction wallet address | |
|**walletId** | **String** | Wallet ID | |
|**cancelInfoList** | **CancelInfoList** | | [optional] |



14 changes: 14 additions & 0 deletions clients/w3w-prediction/docs/BatchCancelOrdersResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# BatchCancelOrdersResponse


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**canceled** | **List&lt;String&gt;** | | [optional] |
|**failed** | [**List&lt;BatchCancelOrdersResponseFailedInner&gt;**](BatchCancelOrdersResponseFailedInner.md) | | [optional] |



Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# BatchCancelOrdersResponseFailedInner


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**orderId** | **String** | | [optional] |
|**reason** | **String** | | [optional] |



16 changes: 16 additions & 0 deletions clients/w3w-prediction/docs/BatchRedeemRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


# BatchRedeemRequest


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**walletAddress** | **String** | User&#39;s prediction wallet address | |
|**walletId** | **String** | Wallet ID | |
|**tokenIds** | **TokenIds** | | |
|**chainId** | **String** | Chain ID. Default &#x60;56&#x60; (BSC) | [optional] |



14 changes: 14 additions & 0 deletions clients/w3w-prediction/docs/BatchRedeemResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# BatchRedeemResponse


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**batchId** | **String** | | [optional] |
|**results** | [**List&lt;BatchRedeemResponseResultsInner&gt;**](BatchRedeemResponseResultsInner.md) | | [optional] |



16 changes: 16 additions & 0 deletions clients/w3w-prediction/docs/BatchRedeemResponseResultsInner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


# BatchRedeemResponseResultsInner


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**requestId** | **String** | | [optional] |
|**txHash** | **String** | | [optional] |
|**status** | **String** | | [optional] |
|**error** | **String** | | [optional] |



13 changes: 13 additions & 0 deletions clients/w3w-prediction/docs/CancelInfoList.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# CancelInfoList

List of orders to cancel (index `i` starts from 0)

## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|



13 changes: 13 additions & 0 deletions clients/w3w-prediction/docs/CancelInfoListInner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# CancelInfoListInner


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**orderId** | **String** | Internal order ID to cancel | |



19 changes: 19 additions & 0 deletions clients/w3w-prediction/docs/CreateInboundTransferRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


# CreateInboundTransferRequest


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**walletId** | **String** | Wallet ID | |
|**walletAddress** | **String** | User&#39;s prediction wallet address | |
|**fromTokenAmount** | **String** | Transfer amount in wei (18 decimals). Must be &gt; 0. Example: &#x60;1000000000000000000&#x60; &#x3D; 1 USDT | |
|**accountType** | **AccountType** | | |
|**fromToken** | **String** | Source token symbol. Default &#x60;USDT&#x60; | [optional] |
|**toToken** | **String** | Destination token symbol. Default &#x60;USDT&#x60; | [optional] |
|**chainId** | **String** | Chain ID. Default &#x60;56&#x60; (BSC) | [optional] |



14 changes: 14 additions & 0 deletions clients/w3w-prediction/docs/CreateInboundTransferResponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# CreateInboundTransferResponse


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**transferId** | **String** | | [optional] |
|**status** | **String** | | [optional] |



20 changes: 20 additions & 0 deletions clients/w3w-prediction/docs/CreateOutboundTransferRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


# CreateOutboundTransferRequest


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**walletId** | **String** | Wallet ID | |
|**walletAddress** | **String** | User&#39;s prediction wallet address | |
|**fromTokenAmount** | **String** | Transfer amount in wei (18 decimals). Must be &gt; 0. Example: &#x60;1000000000000000000&#x60; &#x3D; 1 USDT | |
|**accountType** | **AccountType** | | |
|**sourceBiz** | **SourceBiz** | | |
|**fromToken** | **String** | Source token symbol. Default &#x60;USDT&#x60; | [optional] |
|**toToken** | **String** | Destination token symbol. Default &#x60;USDT&#x60; | [optional] |
|**chainId** | **String** | Chain ID. Default &#x60;56&#x60; (BSC) | [optional] |



Loading
Loading