With the move towards modularization, Binance connectors are now split into smaller, product-specific libraries. This guide explains how to migrate from the monolithic @binance/connector (or @binance/connector-typescript) for Spot and @binance/futures-connector for Futures to the new modular connectors.
| Feature | Monolithic Connector | Modular Connector |
|---|---|---|
| Package Name | @binance/connector, @binance/connector-typescript, or @binance/futures-connector |
@binance/<product> |
| API Coverage | All Binance APIs | Individual APIs (Spot, Futures, Wallet, Algo Trading, Mining etc.) |
| Imports | Single package import | Separate package per product |
| Code Structure | One large client | Smaller, focused clients |
If you were using the old connector, remove it from your project:
npm uninstall @binance/connector @binance/connector-typescript @binance/futures-connectorInstall the required connector(s):
For Spot (Spot package):
npm install @binance/spotFor Futures (COIN-M Futures package):
npm install @binance/derivatives-trading-coin-futuresUpdate your import paths:
Old (Spot):
import { Spot } from '@binance/connector';New (Spot):
import { Spot } from '@binance/spot';Old (CMFutures):
import { CMFutures } from '@binance/futures-connector';New (COIN-M Futures):
import { DerivativesTradingCoinFutures } from '@binance/derivatives-trading-coin-futures';The new structure introduces a more modular approach to client initialization.
Old (Spot - Monolithic Connector):
const client = new Spot(apiKey, apiSecret);
client.account().then(console.log);New (Spot - Modular Connector):
import { Spot } from '@binance/spot';
const configurationRestAPI = {
apiKey: 'your-key',
apiSecret: 'your-secret',
};
const client = new Spot({ configurationRestAPI });
client.restAPI.getAccount().then(console.log);Old (Futures - Monolithic Connector):
const client = new CMFutures(apiKey, apiSecret);
client.getAccountInformation().then(console.log);New (Futures - Modular Connector):
import { DerivativesTradingCoinFutures } from '@binance/derivatives-trading-coin-futures';
const configurationRestAPI = {
apiKey: 'your-key',
apiSecret: 'your-secret',
};
const client = new DerivativesTradingCoinFutures({ configurationRestAPI });
client.restAPI.accountInformation().then(console.log);Some function names or response structures may have changed. Refer to the modular connector's documentation for details.
- If a modular connector is not yet available for your use case, continue using the monolithic connector (
@binance/connector,@binance/connector-typescript, or@binance/futures-connector). - The monolithic connector will remain available, but it is recommended to migrate when modular versions are released.
You can continue using the monolithic connector until the modular version is released.
Critical bug fixes will be provided, but feature updates will focus on the modular connectors.
Check the modular connector's documentation for detailed examples.