binance-sdk-mining 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. binance_sdk_mining-3.1.0/CHANGELOG.md +80 -0
  2. binance_sdk_mining-3.1.0/LICENCE +21 -0
  3. binance_sdk_mining-3.1.0/PKG-INFO +207 -0
  4. binance_sdk_mining-3.1.0/README.md +177 -0
  5. binance_sdk_mining-3.1.0/pyproject.toml +40 -0
  6. binance_sdk_mining-3.1.0/src/binance_sdk_mining/__init__.py +31 -0
  7. binance_sdk_mining-3.1.0/src/binance_sdk_mining/metadata.py +1 -0
  8. binance_sdk_mining-3.1.0/src/binance_sdk_mining/mining.py +34 -0
  9. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/__init__.py +13 -0
  10. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/api/__init__.py +11 -0
  11. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/api/mining_api.py +821 -0
  12. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/__init__.py +101 -0
  13. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/account_list_response.py +127 -0
  14. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/account_list_response_data_inner.py +127 -0
  15. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/account_list_response_data_inner_list_inner.py +110 -0
  16. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/acquiring_algorithm_response.py +127 -0
  17. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/acquiring_algorithm_response_data_inner.py +112 -0
  18. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/acquiring_coinname_response.py +127 -0
  19. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/acquiring_coinname_response_data_inner.py +120 -0
  20. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/cancel_hashrate_resale_configuration_response.py +106 -0
  21. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/earnings_list_response.py +120 -0
  22. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/earnings_list_response_data.py +129 -0
  23. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/earnings_list_response_data_account_profits_inner.py +133 -0
  24. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/enums.py +9 -0
  25. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/extra_bonus_list_response.py +120 -0
  26. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/extra_bonus_list_response_data.py +129 -0
  27. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/extra_bonus_list_response_data_other_profits_inner.py +122 -0
  28. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/hashrate_resale_detail_response.py +120 -0
  29. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/hashrate_resale_detail_response_data.py +135 -0
  30. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/hashrate_resale_detail_response_data_profit_transfer_details_inner.py +126 -0
  31. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/hashrate_resale_list_response.py +120 -0
  32. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/hashrate_resale_list_response_data.py +131 -0
  33. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/hashrate_resale_list_response_data_config_details_inner.py +132 -0
  34. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/hashrate_resale_request_response.py +106 -0
  35. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/mining_account_earning_response.py +120 -0
  36. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/mining_account_earning_response_data.py +131 -0
  37. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/mining_account_earning_response_data_account_profits_inner.py +123 -0
  38. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/request_for_detail_miner_list_response.py +127 -0
  39. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/request_for_detail_miner_list_response_data_inner.py +131 -0
  40. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/request_for_detail_miner_list_response_data_inner_hashrate_datas_inner.py +110 -0
  41. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/request_for_miner_list_response.py +120 -0
  42. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/request_for_miner_list_response_data.py +129 -0
  43. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/request_for_miner_list_response_data_worker_datas_inner.py +128 -0
  44. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/statistic_list_response.py +120 -0
  45. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/statistic_list_response_data.py +157 -0
  46. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/models/statistic_list_response_data_profit_today.py +106 -0
  47. binance_sdk_mining-3.1.0/src/binance_sdk_mining/rest_api/rest_api.py +537 -0
@@ -0,0 +1,80 @@
1
+ # Changelog
2
+
3
+ ## 3.1.0 - 2026-01-29
4
+
5
+ ### Changed (1)
6
+
7
+ - Updated `binance-common` library to version `3.5.0`
8
+
9
+ ## 3.0.0 - 2026-01-23
10
+
11
+ ### Changed (3)
12
+
13
+ - Updated `binance-common` library to version `3.4.1`
14
+
15
+ - Deleted parameter `userName`
16
+ - affected methods:
17
+ - `hashrate_resale_detail()` (`GET /sapi/v1/mining/hash-transfer/profit/details`)
18
+ - Modified response for `hashrate_resale_list()` (`GET /sapi/v1/mining/hash-transfer/config/details/list`):
19
+ - `data`.`configDetails`.items: property `type` added
20
+ - `data`.`configDetails`.items: item property `type` added
21
+
22
+ ## 2.1.0 - 2025-01-13
23
+
24
+ ### Changed (1)
25
+
26
+ - Updated `binance-common` library to version `3.4.0`
27
+
28
+ ## 2.0.0 - 2025-12-22
29
+
30
+ ### Changed (2)
31
+
32
+ - Updated `binance-common` library to version `3.3.0`
33
+ - Add `Body` to Rest API request
34
+
35
+ ## 1.7.0 - 2025-10-10
36
+
37
+ ### Changed (1)
38
+
39
+ - Updated `binance-common` library to version `3.2.0`
40
+
41
+ ## 1.6.0 - 2025-09-16
42
+
43
+ ### Changed (1)
44
+
45
+ - Updated `binance-common` library to version `3.1.1`
46
+
47
+ ## 1.5.0 - 2025-09-12
48
+
49
+ ### Changed (1)
50
+
51
+ - Updated `binance-common` library to version `3.1.0`
52
+
53
+ ## 1.4.0 - 2025-09-05
54
+
55
+ ### Changed (1)
56
+
57
+ - Updated `binance-common` library to version `3.0.0`
58
+
59
+ ## 1.3.0 - 2025-08-22
60
+
61
+ ### Changed (1)
62
+
63
+ - Standardized type hints for required parameters by replacing `default = None` annotations with `Union[..., None]`
64
+
65
+ ## 1.2.0 - 2025-08-07
66
+
67
+ ### Changed (1)
68
+
69
+ - Updated `binance-common` library to version `1.2.0`
70
+
71
+ ## 1.1.0 - 2025-08-06
72
+
73
+ ### Changed (2)
74
+
75
+ - Updated `binance-common` library to version `1.1.0`
76
+ - Added python version `3.13`
77
+
78
+ ## 1.0.0 - 2025-07-17
79
+
80
+ - Initial release
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Binance
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: binance-sdk-mining
3
+ Version: 3.1.0
4
+ Summary: Official Binance Mining SDK - A lightweight library that provides a convenient interface to Binance's Mining REST API
5
+ License: MIT
6
+ License-File: LICENCE
7
+ Author: Binance
8
+ Requires-Python: >=3.9,<3.15
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Provides-Extra: dev
18
+ Requires-Dist: aiohttp (>=3.9,<4.0)
19
+ Requires-Dist: binance-common (==3.5.0)
20
+ Requires-Dist: black (>=25.1.0,<26.0.0)
21
+ Requires-Dist: pycryptodome (>=3.17,<4.0)
22
+ Requires-Dist: pydantic (>=2.10.0)
23
+ Requires-Dist: pytest (>=6.2.5) ; extra == "dev"
24
+ Requires-Dist: requests (>=2.31.0)
25
+ Requires-Dist: ruff (>=0.12.0,<0.13.0)
26
+ Requires-Dist: websocket-client (>=1.6.3)
27
+ Requires-Dist: websockets (>=15.0.1,<16.0.0)
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Binance Python Mining SDK
31
+
32
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci.yaml)](https://github.com/binance/binance-connector-python/actions)
33
+ [![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-python)](https://github.com/binance/binance-connector-python/issues)
34
+ [![Code Style: Black](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
35
+ [![PyPI version](https://img.shields.io/pypi/v/binance-sdk-mining)](https://pypi.python.org/pypi/binance-sdk-mining)
36
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-mining.svg)](https://pypi.org/project/binance-sdk-mining/)
37
+ [![Python version](https://img.shields.io/pypi/pyversions/binance-sdk-mining)](https://www.python.org/downloads/)
38
+ [![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-python/security)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
40
+
41
+ This is a client library for the Binance Mining SDK API, enabling developers to interact programmatically with Binance's Mining trading platform. The library provides tools to mine through the REST API:
42
+
43
+ - [REST API](./src/binance_sdk_mining/rest_api/rest_api.py)
44
+
45
+ ## Table of Contents
46
+
47
+ - [Supported Features](#supported-features)
48
+ - [Installation](#installation)
49
+ - [Documentation](#documentation)
50
+ - [REST APIs](#rest-apis)
51
+ - [Testing](#testing)
52
+ - [Migration Guide](#migration-guide)
53
+ - [Contributing](#contributing)
54
+ - [Licence](#licence)
55
+
56
+ ## Supported Features
57
+
58
+ - REST API Endpoints:
59
+ - `/sapi/v1/mining/*`
60
+ - Inclusion of test cases and examples for quick onboarding.
61
+
62
+ ## Installation
63
+
64
+ To use this library, ensure your environment is running Python version **3.9** or later.
65
+
66
+ ```bash
67
+ pip install binance-sdk-mining
68
+ ```
69
+
70
+ ## Documentation
71
+
72
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/mining/Introduction).
73
+
74
+ ### REST APIs
75
+
76
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_mining/rest_api/rest_api.py) module. The REST API enables you to fetch market data, manage trades, and access account information. Note that some endpoints require authentication using your Binance API credentials.
77
+
78
+ ```python
79
+ from binance_common.configuration import ConfigurationRestAPI
80
+ from binance_common.constants import MINING_REST_API_PROD_URL
81
+ from binance_sdk_mining.mining import Mining
82
+ from binance_sdk_mining.rest_api.models import AcquiringAlgorithmResponse
83
+
84
+ logging.basicConfig(level=logging.INFO)
85
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=MINING_REST_API_PROD_URL)
86
+
87
+ client = Mining(config_rest_api=configuration)
88
+
89
+ try:
90
+ response = client.rest_api.acquiring_algorithm()
91
+
92
+ data: AcquiringAlgorithmResponse = response.data()
93
+ logging.info(f"acquiring_algorithm() response: {data}")
94
+ except Exception as e:
95
+ logging.error(f"acquiring_algorithm() error: {e}")
96
+ ```
97
+
98
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
99
+
100
+ #### Configuration Options
101
+
102
+ The REST API supports the following advanced configuration options:
103
+
104
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
105
+ - `proxy`: Proxy configuration:
106
+ - `host`: Proxy server hostname.
107
+ - `port`: Proxy server port.
108
+ - `protocol`: Proxy protocol (http or https).
109
+ - `auth`: Proxy authentication credentials:
110
+ - `username`: Proxy username.
111
+ - `password`: Proxy password.
112
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
113
+ - `compression`: Enable response compression (default: true).
114
+ - `retries`: Number of retry attempts for failed requests (default: 3).
115
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
116
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
117
+ - `private_key`: RSA or ED25519 private key for authentication.
118
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
119
+
120
+ ##### Timeout
121
+
122
+ 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.
123
+
124
+ ##### Proxy
125
+
126
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
127
+
128
+ ##### Keep-Alive
129
+
130
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
131
+
132
+ ##### Compression
133
+
134
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
135
+
136
+ ##### Retries
137
+
138
+ 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.
139
+
140
+ ##### HTTPS Agent
141
+
142
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
143
+
144
+ ##### Key Pair Based Authentication
145
+
146
+ 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.
147
+
148
+ ##### Certificate Pinning
149
+
150
+ To enhance security, you can use certificate pinning with the `https_agent` 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.
151
+
152
+ #### Error Handling
153
+
154
+ The REST API provides detailed error types to help you handle issues effectively:
155
+
156
+ - `ClientError`: Represents an error that occurred in the SDK client.
157
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
158
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
159
+ - `ForbiddenError`: Access to the requested resource is forbidden.
160
+ - `TooManyRequestsError`: Rate limit exceeded.
161
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
162
+ - `ServerError`: Internal server error, optionally includes a status code.
163
+ - `NetworkError`: Issues with network connectivity.
164
+ - `NotFoundError`: Resource not found.
165
+ - `BadRequestError`: Invalid request or one that cannot be served.
166
+
167
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
168
+
169
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
170
+
171
+ ## Testing
172
+
173
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
174
+
175
+ ```bash
176
+ poetry install
177
+ poetry run pytest ./tests
178
+ ```
179
+
180
+ The tests cover:
181
+ * REST API endpoints
182
+ * Error handling
183
+ * Edge cases
184
+
185
+ ## Migration Guide
186
+
187
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_mining_sdk.md) for detailed steps.
188
+
189
+ ## Contributing
190
+
191
+ Contributions are welcome!
192
+
193
+ 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.
194
+
195
+ To contribute:
196
+
197
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
198
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
199
+
200
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
201
+
202
+ Thank you for your contributions!
203
+
204
+ ## Licence
205
+
206
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
207
+
@@ -0,0 +1,177 @@
1
+ # Binance Python Mining SDK
2
+
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci.yaml)](https://github.com/binance/binance-connector-python/actions)
4
+ [![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-python)](https://github.com/binance/binance-connector-python/issues)
5
+ [![Code Style: Black](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
6
+ [![PyPI version](https://img.shields.io/pypi/v/binance-sdk-mining)](https://pypi.python.org/pypi/binance-sdk-mining)
7
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-mining.svg)](https://pypi.org/project/binance-sdk-mining/)
8
+ [![Python version](https://img.shields.io/pypi/pyversions/binance-sdk-mining)](https://www.python.org/downloads/)
9
+ [![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-python/security)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ This is a client library for the Binance Mining SDK API, enabling developers to interact programmatically with Binance's Mining trading platform. The library provides tools to mine through the REST API:
13
+
14
+ - [REST API](./src/binance_sdk_mining/rest_api/rest_api.py)
15
+
16
+ ## Table of Contents
17
+
18
+ - [Supported Features](#supported-features)
19
+ - [Installation](#installation)
20
+ - [Documentation](#documentation)
21
+ - [REST APIs](#rest-apis)
22
+ - [Testing](#testing)
23
+ - [Migration Guide](#migration-guide)
24
+ - [Contributing](#contributing)
25
+ - [Licence](#licence)
26
+
27
+ ## Supported Features
28
+
29
+ - REST API Endpoints:
30
+ - `/sapi/v1/mining/*`
31
+ - Inclusion of test cases and examples for quick onboarding.
32
+
33
+ ## Installation
34
+
35
+ To use this library, ensure your environment is running Python version **3.9** or later.
36
+
37
+ ```bash
38
+ pip install binance-sdk-mining
39
+ ```
40
+
41
+ ## Documentation
42
+
43
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/mining/Introduction).
44
+
45
+ ### REST APIs
46
+
47
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_mining/rest_api/rest_api.py) module. The REST API enables you to fetch market data, manage trades, and access account information. Note that some endpoints require authentication using your Binance API credentials.
48
+
49
+ ```python
50
+ from binance_common.configuration import ConfigurationRestAPI
51
+ from binance_common.constants import MINING_REST_API_PROD_URL
52
+ from binance_sdk_mining.mining import Mining
53
+ from binance_sdk_mining.rest_api.models import AcquiringAlgorithmResponse
54
+
55
+ logging.basicConfig(level=logging.INFO)
56
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=MINING_REST_API_PROD_URL)
57
+
58
+ client = Mining(config_rest_api=configuration)
59
+
60
+ try:
61
+ response = client.rest_api.acquiring_algorithm()
62
+
63
+ data: AcquiringAlgorithmResponse = response.data()
64
+ logging.info(f"acquiring_algorithm() response: {data}")
65
+ except Exception as e:
66
+ logging.error(f"acquiring_algorithm() error: {e}")
67
+ ```
68
+
69
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
70
+
71
+ #### Configuration Options
72
+
73
+ The REST API supports the following advanced configuration options:
74
+
75
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
76
+ - `proxy`: Proxy configuration:
77
+ - `host`: Proxy server hostname.
78
+ - `port`: Proxy server port.
79
+ - `protocol`: Proxy protocol (http or https).
80
+ - `auth`: Proxy authentication credentials:
81
+ - `username`: Proxy username.
82
+ - `password`: Proxy password.
83
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
84
+ - `compression`: Enable response compression (default: true).
85
+ - `retries`: Number of retry attempts for failed requests (default: 3).
86
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
87
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
88
+ - `private_key`: RSA or ED25519 private key for authentication.
89
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
90
+
91
+ ##### Timeout
92
+
93
+ 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.
94
+
95
+ ##### Proxy
96
+
97
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
98
+
99
+ ##### Keep-Alive
100
+
101
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
102
+
103
+ ##### Compression
104
+
105
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
106
+
107
+ ##### Retries
108
+
109
+ 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.
110
+
111
+ ##### HTTPS Agent
112
+
113
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
114
+
115
+ ##### Key Pair Based Authentication
116
+
117
+ 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.
118
+
119
+ ##### Certificate Pinning
120
+
121
+ To enhance security, you can use certificate pinning with the `https_agent` 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.
122
+
123
+ #### Error Handling
124
+
125
+ The REST API provides detailed error types to help you handle issues effectively:
126
+
127
+ - `ClientError`: Represents an error that occurred in the SDK client.
128
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
129
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
130
+ - `ForbiddenError`: Access to the requested resource is forbidden.
131
+ - `TooManyRequestsError`: Rate limit exceeded.
132
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
133
+ - `ServerError`: Internal server error, optionally includes a status code.
134
+ - `NetworkError`: Issues with network connectivity.
135
+ - `NotFoundError`: Resource not found.
136
+ - `BadRequestError`: Invalid request or one that cannot be served.
137
+
138
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
139
+
140
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
141
+
142
+ ## Testing
143
+
144
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
145
+
146
+ ```bash
147
+ poetry install
148
+ poetry run pytest ./tests
149
+ ```
150
+
151
+ The tests cover:
152
+ * REST API endpoints
153
+ * Error handling
154
+ * Edge cases
155
+
156
+ ## Migration Guide
157
+
158
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_mining_sdk.md) for detailed steps.
159
+
160
+ ## Contributing
161
+
162
+ Contributions are welcome!
163
+
164
+ 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.
165
+
166
+ To contribute:
167
+
168
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
169
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
170
+
171
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
172
+
173
+ Thank you for your contributions!
174
+
175
+ ## Licence
176
+
177
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
@@ -0,0 +1,40 @@
1
+ [tool.poetry]
2
+ name = "binance-sdk-mining"
3
+ version = "3.1.0"
4
+ description = "Official Binance Mining SDK - A lightweight library that provides a convenient interface to Binance's Mining REST API"
5
+ authors = ["Binance"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ include = ["CHANGELOG.md", "LICENSE", "README.md"]
9
+ packages = [
10
+ { include = "binance_sdk_mining", from = "src" }
11
+ ]
12
+
13
+ [tool.poetry.dependencies]
14
+ python = ">=3.9,<3.15"
15
+ requests = ">=2.31.0"
16
+ pydantic = ">=2.10.0"
17
+ websockets = "^15.0.1"
18
+ websocket-client = ">=1.6.3"
19
+ black = "^25.1.0"
20
+ ruff = "^0.12.0"
21
+ pycryptodome = "^3.17"
22
+ aiohttp = "^3.9"
23
+ binance-common = "3.5.0"
24
+ pytest = { version = ">=6.2.5", optional = true }
25
+
26
+ [tool.poetry.extras]
27
+ dev = ["pytest"]
28
+
29
+ [tool.poetry.group.dev.dependencies]
30
+ tox = "^4.27.0"
31
+ pytest = ">=8.4.1"
32
+ pytest-asyncio = "^1.0.0"
33
+
34
+ [tool.ruff]
35
+ exclude = [".git", ".tox", "build", "dist"]
36
+ lint.ignore = ["E741"]
37
+
38
+ [build-system]
39
+ requires = ["poetry-core>=1.0.0"]
40
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,31 @@
1
+ from binance_sdk_mining.mining import Mining
2
+ from binance_common.errors import (
3
+ ClientError,
4
+ RequiredError,
5
+ UnauthorizedError,
6
+ ForbiddenError,
7
+ TooManyRequestsError,
8
+ RateLimitBanError,
9
+ ServerError,
10
+ NetworkError,
11
+ NotFoundError,
12
+ BadRequestError,
13
+ )
14
+ from binance_common.constants import (
15
+ MINING_REST_API_PROD_URL,
16
+ )
17
+
18
+ __all__ = [
19
+ "Mining",
20
+ "MINING_REST_API_PROD_URL",
21
+ "ClientError",
22
+ "RequiredError",
23
+ "UnauthorizedError",
24
+ "ForbiddenError",
25
+ "TooManyRequestsError",
26
+ "RateLimitBanError",
27
+ "ServerError",
28
+ "NetworkError",
29
+ "NotFoundError",
30
+ "BadRequestError",
31
+ ]
@@ -0,0 +1 @@
1
+ NAME = "binance-sdk-mining"
@@ -0,0 +1,34 @@
1
+ import platform
2
+ from importlib.metadata import version
3
+
4
+ from binance_common.configuration import ConfigurationRestAPI
5
+ from binance_common.constants import MINING_REST_API_PROD_URL
6
+ from . import metadata
7
+ from .rest_api import MiningRestAPI
8
+
9
+ LIB_NAME = metadata.NAME
10
+ LIB_VERSION = version(LIB_NAME)
11
+
12
+
13
+ class Mining:
14
+ """Mining API that exposes REST APIs in a single interface."""
15
+
16
+ def __init__(self, config_rest_api: ConfigurationRestAPI = None) -> None:
17
+ self._rest_api = None
18
+ self._rest_api_config = (
19
+ ConfigurationRestAPI() if config_rest_api is None else config_rest_api
20
+ )
21
+
22
+ @property
23
+ def rest_api(self) -> MiningRestAPI:
24
+ if self._rest_api is None and self._rest_api_config:
25
+ self._rest_api_config.base_headers["User-Agent"] = (
26
+ f"{LIB_NAME}/{LIB_VERSION} (Python/{platform.python_version()}; {platform.system()}; {platform.machine()})"
27
+ )
28
+ self._rest_api_config.base_path = (
29
+ MINING_REST_API_PROD_URL
30
+ if self._rest_api_config.base_path is None
31
+ else self._rest_api_config.base_path
32
+ )
33
+ self._rest_api = MiningRestAPI(self._rest_api_config)
34
+ return self._rest_api
@@ -0,0 +1,13 @@
1
+ """
2
+ Binance Mining REST API
3
+
4
+ OpenAPI Specification for the Binance Mining REST API
5
+ The version of the OpenAPI document: 1.0.0
6
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
7
+
8
+ Do not edit the class manually.
9
+ """
10
+
11
+ from .rest_api import MiningRestAPI
12
+
13
+ __all__ = ["MiningRestAPI"]
@@ -0,0 +1,11 @@
1
+ """
2
+ Binance Mining REST API
3
+
4
+ OpenAPI Specification for the Binance Mining REST API
5
+ The version of the OpenAPI document: 1.0.0
6
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
7
+
8
+ Do not edit the class manually.
9
+ """
10
+
11
+ from .mining_api import MiningApi as MiningApi