Skip to content

Latest commit

 

History

History
128 lines (87 loc) · 2.72 KB

File metadata and controls

128 lines (87 loc) · 2.72 KB

Migration Guide: Binance Algo Connector Modularization

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.).


Key Changes

  1. 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;
  1. Configuration and Client Initialization:
    The new structure keeps the existing configuration options but modularized clients into AlgoRestApi.

    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());
  1. Examples and Documentation:
    Updated examples can be found in the new repository folders:
    • REST API: examples/algo/

Migration Steps

1. Replace the composer dependency

Replace the composer dependency:

composer remove binance/binance-connector-php

by:

composer require binance/binance-connector-php

3. Update Import Paths

Replace all occurrences of:

use \Binance\Spot;

With:

use \Binance\Client\Algo\Api\AlgoRestApi;

4. Update Client Initialization

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());

5. Test and Verify

Run your application to ensure everything works as expected. Refer to the new documentation for any advanced features or configuration options.


Additional Notes

  • Future Modular Packages: Similar packages for other products (e.g., Wallet, Staking) will follow this pattern.

For more details, refer to the updated README and Examples.