Skip to content

Latest commit

 

History

History
133 lines (86 loc) · 3 KB

File metadata and controls

133 lines (86 loc) · 3 KB

Migration Guide: Binance Convert Connector Modularization

With the transition to a modularized structure, the Binance Connector has been split into separate NPM libraries, each focusing on a distinct product (e.g., Convert, Futures, etc.). This guide explains how to migrate from the monolithic @binance/connector (or @binance/connector-typescript) package to the new @binance/convert library.


Key Changes

  1. Package Name:
    The modularised Convert Connector has been moved to a new package:

    Old: @binance/connector
    New: @binance/convert

  2. Installation:
    Uninstall the old package and install the new one:

    npm uninstall @binance/connector
    npm install @binance/convert
  3. Imports:
    Update your import paths.

    Old:

    import { Spot } from '@binance/connector';

    New:

    import { Convert } from '@binance/convert';
  4. Configuration and Client Initialization:
    The new structure keeps the existing configuration options but modularizes clients into ConvertRestAPI.

    Old:

    const client = new Spot({ apiKey: 'your-key', apiSecret: 'your-secret' });
    client.<method_name>().then(console.log);

    New:

    import { Convert, ConvertRestAPI } from '@binance/convert';
    
    
    const configurationRestAPI = {
        apiKey: 'your-key',
        apiSecret: 'your-secret',
    };
    const client = new Convert({ configurationRestAPI });
    
    client.restAPI.<method_name>().then(console.log);
  5. Examples and Documentation:
    Updated examples can be found in the new repository folders:

    • REST API: examples/rest-api/

Migration Steps

1. Uninstall the Old Package

Remove the old package from your project:

npm uninstall @binance/connector

2. Install the New Package

Install the new Convert-specific package:

npm install @binance/convert

3. Update Import Paths

Replace all occurrences of:

import { Spot } from '@binance/connector';

With:

import { Convert } from '@binance/convert';

4. Update Client Initialization

Adjust your code to use the modularized structure. For example:

Old:

const client = new Spot({ apiKey: 'your-key', apiSecret: 'your-secret' });

New:

import { Convert, ConvertRestAPI } from '@binance/convert';

const configurationRestAPI = {
    apiKey: 'your-key',
    apiSecret: 'your-secret',
};
const client = new Convert({ configurationRestAPI });

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.