Blog
Bybit accountsAPI migration

Checking Bybit Unified Account Compatibility

Check Bybit account generation, margin mode, product category, and wallet response fields before migrating a Node.js application to a Unified Trading Account.

Siebly.io2 min readMarkdown

Inspect the Existing Account

A Bybit request with the right signature can still target the wrong account model. A worker expecting one wallet layout may receive another layout, or request a product that is not available under the account's current configuration.

Account mode, margin mode, and product category need separate configuration. Calling all three unified hides the differences that determine which request is valid.

RestClientV5.getAccountInfo() exposes fields including unifiedMarginStatus and marginMode. Bybit documents their current meaning in account information and the linked account-status enumeration.

This example uses credentials created for Bybit testnet:

bybit-account-mode.mjs

JavaScript
import { RestClientV5 } from 'bybit-api';

if (!process.env.BYBIT_TESTNET_KEY || !process.env.BYBIT_TESTNET_SECRET) {
  throw new Error('Set both Bybit testnet credentials');
}
const client = new RestClientV5({
  testnet: true,
  key: process.env.BYBIT_TESTNET_KEY,
  secret: process.env.BYBIT_TESTNET_SECRET,
});
const response = await client.getAccountInfo();
if (response.retCode !== 0) throw new Error(response.retMsg);
console.log({
  unifiedMarginStatus: response.result.unifiedMarginStatus,
  marginMode: response.result.marginMode,
});

A production startup check should compare those values with a documented configuration supported by the application. Unknown values should become a visible compatibility failure, not an assumed default.

Separate the Configuration Fields

Field or decisionWhat it selects
Account statusThe account generation reported by the exchange.
Margin modeThe account's reported margin arrangement.
Product categoryThe product requested by a particular method, such as spot, linear, or inverse.
Wallet accountTypeThe account representation requested by the wallet endpoint.
Position modeHow the supported derivative position slots are represented.

The table is a list of distinct questions, not a compatibility matrix. Use the current endpoint documentation to determine valid combinations for the actual account. Do not infer a category from the presence of USDT in a balance response.

Migrate the Consumer

Save representative responses from the supported old configuration. Update wallet, order, and position consumers against responses from the new configuration, including absent or inapplicable fields. Missing data is not a zero balance.

Private streams do not necessarily initialize the whole account. Account initialization must identify the initial reads each consumer requires and how incoming updates interact with those reads.

An account upgrade is an explicit account operation. Keep it outside routine client construction so restarting a service cannot change the account model used by another worker. After an intentional migration, recheck the required reads, subscriptions, and order-request shapes before enabling that workflow.

Related articles

Continue from here

Related Siebly resources

All articles

Subscribe on Substack

Complete the Substack form below to join our newsletter. Substack handles all subscriber data directly.