With the transition to a modularized structure, the Binance Connector has been split into separate Python libraries, each focusing on a distinct product (e.g., Spot, Futures, etc.). This guide explains how to migrate from the monolithic binance-connector package to the new binance-sdk-pay library.
-
Package Name:
The modularised Pay Connector has been moved to a new package:Old:
binance-connector
New:binance-sdk-pay -
Installation:
Uninstall the old package and install the new one:pip uninstall binance-connector pip install binance-sdk-pay
-
Imports:
Update your import paths.Old:
from binance.spot import Spot as Client
New:
from binance_sdk_pay.pay import Pay, ConfigurationRestAPI
-
Configuration and Client Initialization:
The new structure keeps the existing configuration options but modularizes clients intoPay.Old:
from binance.spot import Spot as Client client = Client(api_key="your-key", api_secret="your-secret") response = client.pay_history(startTimestamp=1637186702000, limit=50) print(response)
New:
from binance_sdk_pay.pay import Pay, ConfigurationRestAPI configuration = ConfigurationRestAPI( api_key="your-key", api_secret="your-secret" ) client = Pay(config_rest_api=configuration) response = client.rest_api.get_pay_trade_history(startTimestamp=1637186702000, limit=50)
-
Examples and Documentation:
Updated examples can be found in the new repository folders:- REST API:
examples/rest_api/
- REST API:
Remove the old package from your project:
pip uninstall binance-connectorInstall the new Pay-specific package:
pip install binance-sdk-payReplace all occurrences of:
from binance.spot import Spot as ClientWith:
from binance_sdk_pay.pay import PayAdjust your code to use the modularized structure. For example:
Old:
client = Client(apiKey='your-key', apiSecret='your-secret')New:
from binance_sdk_pay.pay import Pay, ConfigurationRestAPI
configuration = ConfigurationRestAPI(
api_key="your-key",
api_secret="your-secret"
)
client = Pay(config_rest_api=configuration)Run your application to ensure everything works as expected. Refer to the new documentation for any advanced features or configuration options.
- Future Modular Packages: Similar packages for other products (e.g., Wallet, Staking) will follow this pattern.