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.
-
Package Name:
The modularised Convert Connector has been moved to a new package:Old:
@binance/connector
New:@binance/convert -
Installation:
Uninstall the old package and install the new one:npm uninstall @binance/connector npm install @binance/convert
-
Imports:
Update your import paths.Old:
import { Spot } from '@binance/connector';
New:
import { Convert } from '@binance/convert';
-
Configuration and Client Initialization:
The new structure keeps the existing configuration options but modularizes clients intoConvertRestAPI.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);
-
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:
npm uninstall @binance/connectorInstall the new Convert-specific package:
npm install @binance/convertReplace all occurrences of:
import { Spot } from '@binance/connector';With:
import { Convert } from '@binance/convert';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 });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.