With the transition to a modularized structure, the Binance Connector has been split into separate composer libraries, each focusing on a distinct product (e.g., Auto Invest, Futures, etc.).
-
Package Name:
The modularised Algo Connector has been moved to a new package:Old:
binance/binance-connector-php: "*"New:
binance/binance-connector-php: "*"2Imports:
Update your import paths.
Old:
use \Binance\Spot;New:
use \Binance\Client\Algo\Api\AlgoRestApi;-
Configuration and Client Initialization:
The new structure keeps the existing configuration options but modularized clients intoAlgoRestApi.Old:
$key = ''; # api key is also required
$privateKey = 'file:///path/to/rsa/private/key.pem';
$client = new \Binance\Spot([
'key' => $key,
'privateKey' => $privateKey, # pass the key file directly
'baseURL' => 'https://testnet.binance.vision'
]);New:
$configurationBuilder = AlgoRestApiUtil::getConfigurationBuilder();
$configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key');
$api = new AlgoRestApi($configurationBuilder->build());- Examples and Documentation:
Updated examples can be found in the new repository folders:- REST API:
examples/algo/
- REST API:
Replace the composer dependency:
composer remove binance/binance-connector-phpby:
composer require binance/binance-connector-phpReplace all occurrences of:
use \Binance\Spot;With:
use \Binance\Client\Algo\Api\AlgoRestApi;Adjust your code to use the modularized structure. For example:
Old:
$client = new \Binance\Spot([
'key' => $key,
'privateKey' => $privateKey, # pass the key file directly
'baseURL' => 'https://testnet.binance.vision'
]);New:
$configurationBuilder = AlgoRestApiUtil::getConfigurationBuilder();
$configurationBuilder->apiKey('apiKey')->privateKey('file:///path/to/private.key');
$api = new AlgoRestApi($configurationBuilder->build());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.