https://github.com/openxapi/binance-py
Python client for Binance API
https://github.com/openxapi/binance-py
asyncapi binance cryptocurrency openapi python sdk
Last synced: 2 months ago
JSON representation
Python client for Binance API
- Host: GitHub
- URL: https://github.com/openxapi/binance-py
- Owner: openxapi
- License: mit
- Created: 2025-04-03T19:40:52.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-05-07T02:04:51.000Z (11 months ago)
- Last Synced: 2025-08-19T04:55:12.066Z (7 months ago)
- Topics: asyncapi, binance, cryptocurrency, openapi, python, sdk
- Language: Python
- Homepage:
- Size: 3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Python client for Binance API
[](https://pypi.org/project/openxapi-binance/)
This package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
Please do not edit the generated code manually, but rather regenerate it from [OpenXAPI](https://github.com/openxapi/openxapi).
## Supported APIs
| Product | Module | Sub Products |
|:---------:|-----------|--------|
| [Spot API](binance/spot_README.md) | `binance.spot` | ✅ [Spot Trading](https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-api-information)
✅ [Margin Trading](https://developers.binance.com/docs/margin_trading/Introduction)
✅ [Algo Trading](https://developers.binance.com/docs/algo/Introduction)
✅ [Wallet](https://developers.binance.com/docs/wallet/Introduction)
✅ [Copy Trading](https://developers.binance.com/docs/copy_trading/Introduction)
✅ [Convert](https://developers.binance.com/docs/convert/Introduction)
✅ [Sub Account](https://developers.binance.com/docs/sub_account/Introduction)
✅ [Binance Link](https://developers.binance.com/docs/binance_link/change-log)
✅ [Futures Data](https://developers.binance.com/docs/derivatives/futures-data/general-info)
✅ [Portfolio Margin Pro](https://developers.binance.com/docs/derivatives/portfolio-margin-pro/general-info)
✅ [Staking](https://developers.binance.com/docs/staking/Introduction)
✅ [Dual Investment](https://developers.binance.com/docs/dual_investment/Introduction)
✅ [Mining](https://developers.binance.com/docs/mining/Introduction)
✅ [Crypto Loan](https://developers.binance.com/docs/crypto_loan/Introduction)
✅ [VIP Loan](https://developers.binance.com/docs/vip_loan/Introduction)
✅ [C2C](https://developers.binance.com/docs/c2c/Introduction)
✅ [Fiat](https://developers.binance.com/docs/fiat/Introduction)
✅ [NFT](https://developers.binance.com/docs/nft/Introduction)
✅ [Gift Card](https://developers.binance.com/docs/gift_card/Introduction)
✅ [Rebate](https://developers.binance.com/docs/rebate/Introduction)
✅ [Simple Earn](https://developers.binance.com/docs/simple_earn/Introduction)
✅ [Binance Pay History](https://developers.binance.com/docs/pay/Introduction) |
| [USD-M Futures API](binance/umfutures_README.md) | `binance.umfutures` | ✅ [USDS Margined Futures](https://developers.binance.com/docs/derivatives/usds-margined-futures/general-info)
✅ [Binance Link](https://developers.binance.com/docs/binance_link/link-and-trade/futures) |
| [COIN-M Futures API](binance/cmfutures_README.md) | `binance.cmfutures` | ✅ [COIN Margined Futures](https://developers.binance.com/docs/derivatives/coin-margined-futures/general-info) |
| [Options API](binance/options_README.md) | `binance.options` | ✅ [Options](https://developers.binance.com/docs/derivatives/option/general-info) |
| [Portfolio Margin API](binance/pmargin_README.md) | `binance.pmargin` | ✅ [Portfolio Margin](https://developers.binance.com/docs/derivatives/portfolio-margin/general-info) |
## Requirements.
Python 3.8+
## Installation & Usage
```bash
pip install openxapi-binance
```
## Getting Started
In your own code, to use this library to connect and interact with spot,
you can run the following:
```python
import os
import time
from pprint import pprint
from binance import spot
from binance.spot.rest import ApiException
from binance.spot.auth import BinanceAuth
# Defining the host is optional and defaults to https://api.binance.com
# See configuration.py for a list of all supported configuration parameters.
configuration = spot.Configuration(
host = "https://api.binance.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
conf = spot.Configuration(
auth=BinanceAuth(
api_key=os.getenv("BINANCE_API_KEY"),
# secret_key=os.getenv("BINANCE_SECRET_KEY"), # if you want to use HMAC auth
private_key_path="/path/to/private_key.pem", # Automatically detects RSA/Ed25519 private keys
),
)
# Enter a context with an instance of the API client
with spot.ApiClient(conf) as api_client:
# Create an instance of the API class
api_instance = spot.SpotTradingApi(api_client)
try:
# Query Commission Rates (USER_DATA)
api_response = api_instance.get_account_v3(
timestamp=int(time.time() * 1000)
)
print("The response of AccountApi->get_account_v3:\n")
pprint(api_response)
except ApiException as e:
print("Exception when calling AccountApi->get_account_v3: %s\n" % e)
```