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-wallet library.
-
Package Name:
The modularised Wallet Connector has been moved to a new package:Old:
binance-connector
New:binance-sdk-wallet -
Installation:
Uninstall the old package and install the new one:pip uninstall binance-connector pip install binance-sdk-wallet
-
Imports:
Update your import paths.Old:
from binance.spot import Spot as Client
New:
from binance_sdk_wallet.wallet import Wallet, ConfigurationRestAPI
-
Configuration and Client Initialization:
The new structure keeps the existing configuration options but modularizes clients intoWallet.Old:
from binance.spot import Spot as Client client = Client(api_key="your-key", api_secret="your-secret") response = client.coin_info() print(response)
New:
from binance_sdk_wallet.wallet import Wallet, ConfigurationRestAPI configuration = ConfigurationRestAPI( api_key="your-key", api_secret="your-secret" ) client = Wallet(config_rest_api=configuration) response = client.rest_api.all_coins_information()
-
Examples and Documentation:
Updated examples can be found in the new repository folders:- REST API:
examples/rest_api/ - WebSocket API:
examples/websocket_api/ - WebSocket Streams:
examples/websocket_streams/
- REST API:
Remove the old package from your project:
pip uninstall binance-connectorInstall the new Wallet-specific package:
pip install binance-sdk-walletReplace all occurrences of:
from binance.spot import Spot as ClientWith:
from binance_sdk_wallet.wallet import WalletAdjust your code to use the modularized structure. For example:
Old:
client = Client(apiKey='your-key', apiSecret='your-secret')New:
from binance_sdk_wallet.wallet import Wallet, ConfigurationRestAPI
configuration = ConfigurationRestAPI(
api_key="your-key",
api_secret="your-secret"
)
client = Wallet(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.