binance-sdk-rebate 1.0.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.
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2025-07-17
4
+
5
+ - 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,205 @@
1
+ Metadata-Version: 2.1
2
+ Name: binance-sdk-rebate
3
+ Version: 1.0.0
4
+ Summary: Official Binance Rebate SDK - A lightweight library that provides a convenient interface to Binance's Rebate REST API
5
+ License: MIT
6
+ Author: Binance
7
+ Requires-Python: >=3.9,<=3.13
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Provides-Extra: dev
16
+ Requires-Dist: aiohttp (>=3.9,<4.0)
17
+ Requires-Dist: binance-common (==1.0.0)
18
+ Requires-Dist: black (>=25.1.0,<26.0.0)
19
+ Requires-Dist: pycryptodome (>=3.17,<4.0)
20
+ Requires-Dist: pydantic (>=2.10.0)
21
+ Requires-Dist: pytest (>=6.2.5) ; extra == "dev"
22
+ Requires-Dist: requests (>=2.31.0)
23
+ Requires-Dist: ruff (>=0.12.0,<0.13.0)
24
+ Requires-Dist: websocket-client (>=1.6.3)
25
+ Requires-Dist: websockets (>=15.0.1,<16.0.0)
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Binance Python Rebate SDK
29
+
30
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-rebate.yml)](https://github.com/binance/binance-connector-python/actions)
31
+ [![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-python)](https://github.com/binance/binance-connector-python/issues)
32
+ [![Code Style: Black](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
33
+ [![PyPI version](https://img.shields.io/pypi/v/binance-sdk-rebate)](https://pypi.python.org/pypi/binance-sdk-rebate)
34
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-rebate.svg)](https://pypi.org/project/binance-sdk-rebate/)
35
+ [![Python version](https://img.shields.io/pypi/pyversions/binance-connector)](https://www.python.org/downloads/)
36
+ [![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-python/security)
37
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
38
+
39
+ This is a client library for the Binance Rebate SDK API, enabling developers to interact programmatically with Binance's Rebate trading platform. The library provides tools to query spot rebate history Records through the REST API:
40
+
41
+ - [REST API](./src/binance_sdk_rebate/rest_api/rest_api.py)
42
+
43
+ ## Table of Contents
44
+
45
+ - [Supported Features](#supported-features)
46
+ - [Installation](#installation)
47
+ - [Documentation](#documentation)
48
+ - [REST APIs](#rest-apis)
49
+ - [Testing](#testing)
50
+ - [Migration Guide](#migration-guide)
51
+ - [Contributing](#contributing)
52
+ - [Licence](#licence)
53
+
54
+ ## Supported Features
55
+
56
+ - REST API Endpoints:
57
+ - `/sapi/v1/rebate/*`
58
+ - Inclusion of test cases and examples for quick onboarding.
59
+
60
+ ## Installation
61
+
62
+ To use this library, ensure your environment is running Python version **3.9** or later.
63
+
64
+ ```bash
65
+ pip install binance-sdk-rebate
66
+ ```
67
+
68
+ ## Documentation
69
+
70
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/rebate/Introduction).
71
+
72
+ ### REST APIs
73
+
74
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_rebate/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.
75
+
76
+ ```python
77
+ from binance_common.configuration import ConfigurationRestAPI
78
+ from binance_common.constants import REBATE_REST_API_PROD_URL
79
+ from binance_sdk_rebate.rebate import Rebate
80
+ from binance_sdk_rebate.rest_api.models import GetSpotRebateHistoryRecordsResponse
81
+
82
+ logging.basicConfig(level=logging.INFO)
83
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=REBATE_REST_API_PROD_URL)
84
+
85
+ client = Rebate(config_rest_api=configuration)
86
+
87
+ try:
88
+ response = client.rest_api.get_spot_rebate_history_records()
89
+
90
+ data: GetSpotRebateHistoryRecordsResponse = response.data()
91
+ logging.info(f"get_spot_rebate_history_records() response: {data}")
92
+ except Exception as e:
93
+ logging.error(f"get_spot_rebate_history_records() error: {e}")
94
+ ```
95
+
96
+ More examples can be found in the [`examples/rest_api`](./examples/rest_api/) folder.
97
+
98
+ #### Configuration Options
99
+
100
+ The REST API supports the following advanced configuration options:
101
+
102
+ - `timeout`: Timeout for requests in milliseconds (default: 1000 ms).
103
+ - `proxy`: Proxy configuration:
104
+ - `host`: Proxy server hostname.
105
+ - `port`: Proxy server port.
106
+ - `protocol`: Proxy protocol (http or https).
107
+ - `auth`: Proxy authentication credentials:
108
+ - `username`: Proxy username.
109
+ - `password`: Proxy password.
110
+ - `keep_alive`: Enable HTTP keep-alive (default: true).
111
+ - `compression`: Enable response compression (default: true).
112
+ - `retries`: Number of retry attempts for failed requests (default: 3).
113
+ - `backoff`: Delay in milliseconds between retries (default: 1000 ms).
114
+ - `https_agent`: Custom HTTPS agent for advanced TLS configuration.
115
+ - `private_key`: RSA or ED25519 private key for authentication.
116
+ - `private_key_passphrase`: Passphrase for the private key, if encrypted.
117
+
118
+ ##### Timeout
119
+
120
+ 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.
121
+
122
+ ##### Proxy
123
+
124
+ The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/rest_api/proxy.md) for detailed usage.
125
+
126
+ ##### Keep-Alive
127
+
128
+ Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/rest_api/keepAlive.md) for detailed usage.
129
+
130
+ ##### Compression
131
+
132
+ Enable or disable response compression. See the [Compression example](./docs/rest_api/compression.md) for detailed usage.
133
+
134
+ ##### Retries
135
+
136
+ 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.
137
+
138
+ ##### HTTPS Agent
139
+
140
+ Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/rest_api/httpsAgent.md) for detailed usage.
141
+
142
+ ##### Key Pair Based Authentication
143
+
144
+ 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.
145
+
146
+ ##### Certificate Pinning
147
+
148
+ 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.
149
+
150
+ #### Error Handling
151
+
152
+ The REST API provides detailed error types to help you handle issues effectively:
153
+
154
+ - `ClientError`: Represents an error that occurred in the SDK client.
155
+ - `RequiredError`: Thrown when a required parameter is missing or undefined.
156
+ - `UnauthorizedError`: Indicates missing or invalid authentication credentials.
157
+ - `ForbiddenError`: Access to the requested resource is forbidden.
158
+ - `TooManyRequestsError`: Rate limit exceeded.
159
+ - `RateLimitBanError`: IP address banned for exceeding rate limits.
160
+ - `ServerError`: Internal server error, optionally includes a status code.
161
+ - `NetworkError`: Issues with network connectivity.
162
+ - `NotFoundError`: Resource not found.
163
+ - `BadRequestError`: Invalid request or one that cannot be served.
164
+
165
+ See the [Error Handling example](./docs/rest_api/error-handling.md) for detailed usage.
166
+
167
+ If `base_path` is not provided, it defaults to `https://api.binance.com`.
168
+
169
+ ## Testing
170
+
171
+ To run the tests, ensure you have [Poetry](https://python-poetry.org/) installed, then execute the following commands:
172
+
173
+ ```bash
174
+ poetry install
175
+ poetry run pytest ./tests
176
+ ```
177
+
178
+ The tests cover:
179
+ * REST API endpoints
180
+ * Error handling
181
+ * Edge cases
182
+
183
+ ## Migration Guide
184
+
185
+ If you are upgrading to the new modularized structure, refer to the [Migration Guide](./docs/migration_guide_rebate_sdk.md) for detailed steps.
186
+
187
+ ## Contributing
188
+
189
+ Contributions are welcome!
190
+
191
+ 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.
192
+
193
+ To contribute:
194
+
195
+ 1. Open a GitHub issue describing your suggestion or the bug you've identified.
196
+ 2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.
197
+
198
+ Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.
199
+
200
+ Thank you for your contributions!
201
+
202
+ ## Licence
203
+
204
+ This project is licensed under the MIT License. See the [LICENCE](./LICENCE) file for details.
205
+
@@ -0,0 +1,177 @@
1
+ # Binance Python Rebate SDK
2
+
3
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-python/ci-rebate.yml)](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-rebate)](https://pypi.python.org/pypi/binance-sdk-rebate)
7
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/binance-sdk-rebate.svg)](https://pypi.org/project/binance-sdk-rebate/)
8
+ [![Python version](https://img.shields.io/pypi/pyversions/binance-connector)](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 Rebate SDK API, enabling developers to interact programmatically with Binance's Rebate trading platform. The library provides tools to query spot rebate history Records through the REST API:
13
+
14
+ - [REST API](./src/binance_sdk_rebate/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/rebate/*`
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-rebate
39
+ ```
40
+
41
+ ## Documentation
42
+
43
+ For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/rebate/Introduction).
44
+
45
+ ### REST APIs
46
+
47
+ All REST API endpoints are available through the [`rest_api`](./src/binance_sdk_rebate/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 REBATE_REST_API_PROD_URL
52
+ from binance_sdk_rebate.rebate import Rebate
53
+ from binance_sdk_rebate.rest_api.models import GetSpotRebateHistoryRecordsResponse
54
+
55
+ logging.basicConfig(level=logging.INFO)
56
+ configuration = ConfigurationRestAPI(api_key="your-api-key", api_secret="your-api-secret", base_path=REBATE_REST_API_PROD_URL)
57
+
58
+ client = Rebate(config_rest_api=configuration)
59
+
60
+ try:
61
+ response = client.rest_api.get_spot_rebate_history_records()
62
+
63
+ data: GetSpotRebateHistoryRecordsResponse = response.data()
64
+ logging.info(f"get_spot_rebate_history_records() response: {data}")
65
+ except Exception as e:
66
+ logging.error(f"get_spot_rebate_history_records() 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_rebate_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-rebate"
3
+ version = "1.0.0"
4
+ description = "Official Binance Rebate SDK - A lightweight library that provides a convenient interface to Binance's Rebate 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_rebate", from = "src" }
11
+ ]
12
+
13
+ [tool.poetry.dependencies]
14
+ python = ">=3.9,<=3.13"
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 = "1.0.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_rebate.rebate import Rebate
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
+ REBATE_REST_API_PROD_URL,
16
+ )
17
+
18
+ __all__ = [
19
+ "Rebate",
20
+ "REBATE_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-rebate"
@@ -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 REBATE_REST_API_PROD_URL
6
+ from . import metadata
7
+ from .rest_api import RebateRestAPI
8
+
9
+ LIB_NAME = metadata.NAME
10
+ LIB_VERSION = version(LIB_NAME)
11
+
12
+
13
+ class Rebate:
14
+ """Rebate 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) -> RebateRestAPI:
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
+ REBATE_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 = RebateRestAPI(self._rest_api_config)
34
+ return self._rest_api
@@ -0,0 +1,13 @@
1
+ """
2
+ Binance Rebate REST API
3
+
4
+ OpenAPI Specification for the Binance Rebate 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 RebateRestAPI
12
+
13
+ __all__ = ["RebateRestAPI"]
@@ -0,0 +1,11 @@
1
+ """
2
+ Binance Rebate REST API
3
+
4
+ OpenAPI Specification for the Binance Rebate 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 .rebate_api import RebateApi as RebateApi
@@ -0,0 +1,86 @@
1
+ """
2
+ Binance Rebate REST API
3
+
4
+ OpenAPI Specification for the Binance Rebate 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 typing import Optional
12
+ from requests import Session
13
+ from binance_common.configuration import ConfigurationRestAPI
14
+ from binance_common.models import ApiResponse
15
+ from binance_common.signature import Signers
16
+ from binance_common.utils import send_request
17
+
18
+ from ..models import GetSpotRebateHistoryRecordsResponse
19
+
20
+
21
+ class RebateApi:
22
+ """API Client for RebateApi endpoints."""
23
+
24
+ def __init__(
25
+ self,
26
+ configuration: ConfigurationRestAPI = None,
27
+ session: Session = None,
28
+ signer: Signers = None,
29
+ ) -> None:
30
+ self._configuration = configuration
31
+ self._session = session
32
+ self._signer = signer
33
+
34
+ def get_spot_rebate_history_records(
35
+ self,
36
+ start_time: Optional[int] = None,
37
+ end_time: Optional[int] = None,
38
+ page: Optional[int] = None,
39
+ recv_window: Optional[int] = None,
40
+ ) -> ApiResponse[GetSpotRebateHistoryRecordsResponse]:
41
+ """
42
+ Get Spot Rebate History Records (USER_DATA)
43
+ GET /sapi/v1/rebate/taxQuery
44
+ https://developers.binance.com/docs/rebate/rest-api/Get-Spot-Rebate-History-Records
45
+
46
+ Get Spot Rebate History Records
47
+
48
+ * The max interval between startTime and endTime is 30 days.
49
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
50
+ * The earliest startTime is supported on June 10, 2020
51
+ * Return up to 200 records per request.
52
+
53
+ Weight: 12000
54
+
55
+ Args:
56
+ start_time (Optional[int]):
57
+ end_time (Optional[int]):
58
+ page (Optional[int]): Default 1
59
+ recv_window (Optional[int]):
60
+
61
+ Returns:
62
+ ApiResponse[GetSpotRebateHistoryRecordsResponse]
63
+
64
+ Raises:
65
+ RequiredError: If a required parameter is missing.
66
+
67
+ """
68
+
69
+ payload = {
70
+ "start_time": start_time,
71
+ "end_time": end_time,
72
+ "page": page,
73
+ "recv_window": recv_window,
74
+ }
75
+
76
+ return send_request(
77
+ self._session,
78
+ self._configuration,
79
+ method="GET",
80
+ path="/sapi/v1/rebate/taxQuery",
81
+ payload=payload,
82
+ time_unit=self._configuration.time_unit,
83
+ response_model=GetSpotRebateHistoryRecordsResponse,
84
+ is_signed=True,
85
+ signer=self._signer,
86
+ )
@@ -0,0 +1,19 @@
1
+ """
2
+ Binance Rebate REST API
3
+
4
+ OpenAPI Specification for the Binance Rebate 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 .get_spot_rebate_history_records_response import (
12
+ GetSpotRebateHistoryRecordsResponse as GetSpotRebateHistoryRecordsResponse,
13
+ )
14
+ from .get_spot_rebate_history_records_response_data import (
15
+ GetSpotRebateHistoryRecordsResponseData as GetSpotRebateHistoryRecordsResponseData,
16
+ )
17
+ from .get_spot_rebate_history_records_response_data_data_inner import (
18
+ GetSpotRebateHistoryRecordsResponseDataDataInner as GetSpotRebateHistoryRecordsResponseDataDataInner,
19
+ )
@@ -0,0 +1,9 @@
1
+ """
2
+ Binance Rebate REST API
3
+
4
+ OpenAPI Specification for the Binance Rebate 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
+ """
@@ -0,0 +1,122 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Binance Rebate REST API
5
+
6
+ OpenAPI Specification for the Binance Rebate REST API
7
+ The version of the OpenAPI document: 1.0.0
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from binance_sdk_rebate.rest_api.models.get_spot_rebate_history_records_response_data import (
22
+ GetSpotRebateHistoryRecordsResponseData,
23
+ )
24
+ from typing import Set
25
+ from typing_extensions import Self
26
+
27
+
28
+ class GetSpotRebateHistoryRecordsResponse(BaseModel):
29
+ """
30
+ GetSpotRebateHistoryRecordsResponse
31
+ """ # noqa: E501
32
+
33
+ status: Optional[StrictStr] = None
34
+ type: Optional[StrictStr] = None
35
+ code: Optional[StrictStr] = None
36
+ data: Optional[GetSpotRebateHistoryRecordsResponseData] = None
37
+ additional_properties: Dict[str, Any] = {}
38
+ __properties: ClassVar[List[str]] = ["status", "type", "code", "data"]
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+ def to_str(self) -> str:
47
+ """Returns the string representation of the model using alias"""
48
+ return pprint.pformat(self.model_dump(by_alias=True))
49
+
50
+ def to_json(self) -> str:
51
+ """Returns the JSON representation of the model using alias"""
52
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
53
+ return json.dumps(self.to_dict())
54
+
55
+ @classmethod
56
+ def is_array(cls) -> bool:
57
+ return False
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of GetSpotRebateHistoryRecordsResponse from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ * Fields in `self.additional_properties` are added to the output dict.
74
+ """
75
+ excluded_fields: Set[str] = set(
76
+ [
77
+ "additional_properties",
78
+ ]
79
+ )
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ # override the default output from pydantic by calling `to_dict()` of data
87
+ if self.data:
88
+ _dict["data"] = self.data.to_dict()
89
+ # puts key-value pairs in additional_properties in the top level
90
+ if self.additional_properties is not None:
91
+ for _key, _value in self.additional_properties.items():
92
+ _dict[_key] = _value
93
+
94
+ return _dict
95
+
96
+ @classmethod
97
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98
+ """Create an instance of GetSpotRebateHistoryRecordsResponse from a dict"""
99
+ if obj is None:
100
+ return None
101
+
102
+ if not isinstance(obj, dict):
103
+ return cls.model_validate(obj)
104
+
105
+ _obj = cls.model_validate(
106
+ {
107
+ "status": obj.get("status"),
108
+ "type": obj.get("type"),
109
+ "code": obj.get("code"),
110
+ "data": (
111
+ GetSpotRebateHistoryRecordsResponseData.from_dict(obj["data"])
112
+ if obj.get("data") is not None
113
+ else None
114
+ ),
115
+ }
116
+ )
117
+ # store additional fields in additional_properties
118
+ for _key in obj.keys():
119
+ if _key not in cls.__properties:
120
+ _obj.additional_properties[_key] = obj.get(_key)
121
+
122
+ return _obj
@@ -0,0 +1,131 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Binance Rebate REST API
5
+
6
+ OpenAPI Specification for the Binance Rebate REST API
7
+ The version of the OpenAPI document: 1.0.0
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from binance_sdk_rebate.rest_api.models.get_spot_rebate_history_records_response_data_data_inner import (
22
+ GetSpotRebateHistoryRecordsResponseDataDataInner,
23
+ )
24
+ from typing import Set
25
+ from typing_extensions import Self
26
+
27
+
28
+ class GetSpotRebateHistoryRecordsResponseData(BaseModel):
29
+ """
30
+ GetSpotRebateHistoryRecordsResponseData
31
+ """ # noqa: E501
32
+
33
+ page: Optional[StrictInt] = None
34
+ total_records: Optional[StrictInt] = Field(default=None, alias="totalRecords")
35
+ total_page_num: Optional[StrictInt] = Field(default=None, alias="totalPageNum")
36
+ data: Optional[List[GetSpotRebateHistoryRecordsResponseDataDataInner]] = None
37
+ additional_properties: Dict[str, Any] = {}
38
+ __properties: ClassVar[List[str]] = ["page", "totalRecords", "totalPageNum", "data"]
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+ def to_str(self) -> str:
47
+ """Returns the string representation of the model using alias"""
48
+ return pprint.pformat(self.model_dump(by_alias=True))
49
+
50
+ def to_json(self) -> str:
51
+ """Returns the JSON representation of the model using alias"""
52
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
53
+ return json.dumps(self.to_dict())
54
+
55
+ @classmethod
56
+ def is_array(cls) -> bool:
57
+ return False
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of GetSpotRebateHistoryRecordsResponseData from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ * Fields in `self.additional_properties` are added to the output dict.
74
+ """
75
+ excluded_fields: Set[str] = set(
76
+ [
77
+ "additional_properties",
78
+ ]
79
+ )
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ # override the default output from pydantic by calling `to_dict()` of each item in data (list)
87
+ _items = []
88
+ if self.data:
89
+ for _item_data in self.data:
90
+ if _item_data:
91
+ _items.append(_item_data.to_dict())
92
+ _dict["data"] = _items
93
+ # puts key-value pairs in additional_properties in the top level
94
+ if self.additional_properties is not None:
95
+ for _key, _value in self.additional_properties.items():
96
+ _dict[_key] = _value
97
+
98
+ return _dict
99
+
100
+ @classmethod
101
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
102
+ """Create an instance of GetSpotRebateHistoryRecordsResponseData from a dict"""
103
+ if obj is None:
104
+ return None
105
+
106
+ if not isinstance(obj, dict):
107
+ return cls.model_validate(obj)
108
+
109
+ _obj = cls.model_validate(
110
+ {
111
+ "page": obj.get("page"),
112
+ "totalRecords": obj.get("totalRecords"),
113
+ "totalPageNum": obj.get("totalPageNum"),
114
+ "data": (
115
+ [
116
+ GetSpotRebateHistoryRecordsResponseDataDataInner.from_dict(
117
+ _item
118
+ )
119
+ for _item in obj["data"]
120
+ ]
121
+ if obj.get("data") is not None
122
+ else None
123
+ ),
124
+ }
125
+ )
126
+ # store additional fields in additional_properties
127
+ for _key in obj.keys():
128
+ if _key not in cls.__properties:
129
+ _obj.additional_properties[_key] = obj.get(_key)
130
+
131
+ return _obj
@@ -0,0 +1,112 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Binance Rebate REST API
5
+
6
+ OpenAPI Specification for the Binance Rebate REST API
7
+ The version of the OpenAPI document: 1.0.0
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """
12
+
13
+
14
+ from __future__ import annotations
15
+ import pprint
16
+ import re # noqa: F401
17
+ import json
18
+
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from typing import Set
22
+ from typing_extensions import Self
23
+
24
+
25
+ class GetSpotRebateHistoryRecordsResponseDataDataInner(BaseModel):
26
+ """
27
+ GetSpotRebateHistoryRecordsResponseDataDataInner
28
+ """ # noqa: E501
29
+
30
+ asset: Optional[StrictStr] = None
31
+ type: Optional[StrictInt] = None
32
+ amount: Optional[StrictStr] = None
33
+ update_time: Optional[StrictInt] = Field(default=None, alias="updateTime")
34
+ additional_properties: Dict[str, Any] = {}
35
+ __properties: ClassVar[List[str]] = ["asset", "type", "amount", "updateTime"]
36
+
37
+ model_config = ConfigDict(
38
+ populate_by_name=True,
39
+ validate_assignment=True,
40
+ protected_namespaces=(),
41
+ )
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def is_array(cls) -> bool:
54
+ return False
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of GetSpotRebateHistoryRecordsResponseDataDataInner from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ * Fields in `self.additional_properties` are added to the output dict.
71
+ """
72
+ excluded_fields: Set[str] = set(
73
+ [
74
+ "additional_properties",
75
+ ]
76
+ )
77
+
78
+ _dict = self.model_dump(
79
+ by_alias=True,
80
+ exclude=excluded_fields,
81
+ exclude_none=True,
82
+ )
83
+ # puts key-value pairs in additional_properties in the top level
84
+ if self.additional_properties is not None:
85
+ for _key, _value in self.additional_properties.items():
86
+ _dict[_key] = _value
87
+
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of GetSpotRebateHistoryRecordsResponseDataDataInner from a dict"""
93
+ if obj is None:
94
+ return None
95
+
96
+ if not isinstance(obj, dict):
97
+ return cls.model_validate(obj)
98
+
99
+ _obj = cls.model_validate(
100
+ {
101
+ "asset": obj.get("asset"),
102
+ "type": obj.get("type"),
103
+ "amount": obj.get("amount"),
104
+ "updateTime": obj.get("updateTime"),
105
+ }
106
+ )
107
+ # store additional fields in additional_properties
108
+ for _key in obj.keys():
109
+ if _key not in cls.__properties:
110
+ _obj.additional_properties[_key] = obj.get(_key)
111
+
112
+ return _obj
@@ -0,0 +1,119 @@
1
+ """
2
+ Binance Rebate REST API
3
+
4
+ OpenAPI Specification for the Binance Rebate 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
+ import requests
12
+ from typing import Optional, TypeVar
13
+ from binance_common.configuration import ConfigurationRestAPI
14
+ from binance_common.models import ApiResponse
15
+ from binance_common.signature import Signers
16
+ from binance_common.utils import send_request
17
+ from .api.rebate_api import RebateApi
18
+
19
+ from .models import GetSpotRebateHistoryRecordsResponse
20
+
21
+
22
+ T = TypeVar("T")
23
+
24
+
25
+ class RebateRestAPI:
26
+ def __init__(
27
+ self,
28
+ configuration: ConfigurationRestAPI,
29
+ ) -> None:
30
+ self.configuration = configuration
31
+ self._session = requests.Session()
32
+ self._signer = (
33
+ Signers.get_signer(
34
+ configuration.private_key, configuration.private_key_passphrase
35
+ )
36
+ if configuration.private_key is not None
37
+ else None
38
+ )
39
+
40
+ self._rebateApi = RebateApi(self.configuration, self._session, self._signer)
41
+
42
+ def send_request(
43
+ self, endpoint: str, method: str, params: Optional[dict] = None
44
+ ) -> ApiResponse[T]:
45
+ """
46
+ Sends an request to the Binance REST API.
47
+
48
+ Args:
49
+ endpoint (str): The API endpoint path to send the request to.
50
+ method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
51
+ params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
52
+
53
+ Returns:
54
+ ApiResponse[T]: The API response, where T is the expected response type.
55
+ """
56
+ return send_request[T](
57
+ self._session, self.configuration, method, endpoint, params
58
+ )
59
+
60
+ def send_signed_request(
61
+ self, endpoint: str, method: str, params: Optional[dict] = None
62
+ ) -> ApiResponse[T]:
63
+ """
64
+ Sends a signed request to the Binance REST API.
65
+
66
+ Args:
67
+ endpoint (str): The API endpoint path to send the request to.
68
+ method (str): The HTTP method to use for the request (e.g. "GET", "POST", "PUT", "DELETE").
69
+ params (Optional[dict]): The request payload as a dictionary, or None if no payload is required.
70
+
71
+ Returns:
72
+ ApiResponse[T]: The API response, where T is the expected response type.
73
+ """
74
+ return send_request[T](
75
+ self._session,
76
+ self.configuration,
77
+ method,
78
+ endpoint,
79
+ params,
80
+ is_signed=True,
81
+ signer=self._signer,
82
+ )
83
+
84
+ def get_spot_rebate_history_records(
85
+ self,
86
+ start_time: Optional[int] = None,
87
+ end_time: Optional[int] = None,
88
+ page: Optional[int] = None,
89
+ recv_window: Optional[int] = None,
90
+ ) -> ApiResponse[GetSpotRebateHistoryRecordsResponse]:
91
+ """
92
+ Get Spot Rebate History Records (USER_DATA)
93
+
94
+ Get Spot Rebate History Records
95
+
96
+ * The max interval between startTime and endTime is 30 days.
97
+ * If startTime and endTime are not sent, the recent 7 days' data will be returned.
98
+ * The earliest startTime is supported on June 10, 2020
99
+ * Return up to 200 records per request.
100
+
101
+ Weight: 12000
102
+
103
+ Args:
104
+ start_time (Optional[int]):
105
+ end_time (Optional[int]):
106
+ page (Optional[int]): Default 1
107
+ recv_window (Optional[int]):
108
+
109
+ Returns:
110
+ ApiResponse[GetSpotRebateHistoryRecordsResponse]
111
+
112
+ Raises:
113
+ RequiredError: If a required parameter is missing.
114
+
115
+ """
116
+
117
+ return self._rebateApi.get_spot_rebate_history_records(
118
+ start_time, end_time, page, recv_window
119
+ )