Bybit TypeScript SDK

Installation and integration guidance for the Bybit SDK in TypeScript.

TypeScript SDK Usage

Use typed requests, responses, and event flows in stricter TypeScript services and shared libraries.

In TypeScript, use the package types to check request shapes, response fields, WebSocket payloads, and refactors around exchange-specific code.

What This SDK Covers

  • Complete Bybit REST API integrations for exchange-specific workflows.
  • Robust Bybit WebSocket support for market and account stream handling.
  • TypeScript-friendly usage patterns for production integration work.
  • Adaptable TypeScript examples & guides under /examples for implementation reference.
  • Type-rich examples that emphasize request and response shapes, editor hints, and safer refactors.
  • Implementation patterns for larger TypeScript services, shared libraries, and stricter TypeScript application code.

Install Package

npm install bybit-api
# or
pnpm install bybit-api
yarn add bybit-api

Quickstart REST API Walkthrough

Easily start calling Bybit's V5 REST APIs in JavaScript.

  • Install the Bybit JavaScript SDK via NPM: npm install bybit-api.
  • Import the RestClientV5 class (REST API wrapper for Bybit's V5 REST APIs).
  • Create an instance with your API credentials (different key types are automatically detected & handled).
  • Call the desired REST API methods as functions and await the promise containing the response.

In this example, we:

  • Call the endpoint to query a list of linear perpetual futures positions on your Bybit account, and log the response to console.
  • Submit a basic linear futures market buy order, and log the result to console.
  • Submit a basic linear futurse market sell order, and log the results to console.
  • Note: the example assumes one-way position mode. For hedge-mode, you will need to indicate the position side with your order (via positionIdx:1 for the long side or positionIdx:2 for the short side).

For a full map of available REST API methods, check out the endpoint reference below.

Quickstart REST API Example

import { RestClientV5 } from 'bybit-api';

const key = process.env.API_KEY_COM;
const secret = process.env.API_SECRET_COM;

const client = new RestClientV5({
  key: key,
  secret: secret,
});

(async () => {
  try {
    /** Simple examples for private REST API calls with bybit's V5 REST APIs */
    const response = await client.getPositionInfo({
      category: 'linear',
      symbol: 'BTCUSDT',
    });

    console.log('response:', response);

    // Trade USDT linear perps
    const buyOrderResult = await client.submitOrder({
      category: 'linear',
      symbol: 'BTCUSDT',
      orderType: 'Market',
      qty: '1',
      side: 'Buy',
    });
    console.log('buyOrderResult:', buyOrderResult);

    const sellOrderResult = await client.submitOrder({
      category: 'linear',
      symbol: 'BTCUSDT',
      orderType: 'Market',
      qty: '1',
      side: 'Sell',
    });
    console.log('sellOrderResult:', sellOrderResult);
  } catch (e) {
    console.error('request failed: ', e);
  }
})();

Quickstart WebSocket Walkthrough

Connecting to Bybit's WebSocket streams is straightforward with the WebsocketClient.

  • Install the Bybit JavaScript SDK via NPM: npm install bybit-api.
  • Import the WebsocketClient (General WebSocket wrapper for all available Bybit WebSocket streams)
  • Create an instance of the WebsocketClient (API credentials not required unless you want to consume private topics).
  • Configure event handlers for the emitted events you are interested in. The minimum recommended handlers are 'exception', 'update' and 'reconnected'. The latter informs you if a connection dropped and was successfully re-established by the client.
  • Call the subscribe method for the desired channels and handle incoming events.

In this example, we:

  • Subscribe to position, order, wallet and execution streams for the linear futures portion of this account.
  • Print a list of subscribed topics after a 5 second delay, for demonstration purposes.

This setup allows you to receive real-time updates on any account activity, a much faster alternative to polling REST endpoints for the same data.

The WebsocketClient handles most of the complexity for you:

  • Automatically opens connections to Bybit's WebSocket streams.
  • Automatically authenticates as needed.
  • Tracks the topics you've subscribed to.
  • Automatically detects if a connected stream becomes faulty.
  • Automatically tears down the faulty stream, before replacing it with a fresh connection and automatically resubscribing to the topics you were subscribed to before.

Quickstart WebSocket Example

/* eslint-disable @typescript-eslint/no-empty-function */
import { DefaultLogger, WebsocketClient, WS_KEY_MAP } from 'bybit-api';

// Create & inject a custom logger to enable the trace logging level (empty function)
const logger = {
  ...DefaultLogger,
  // trace: (...params) => console.log('trace', ...params),
};

const key = process.env.API_KEY_COM;
const secret = process.env.API_SECRET_COM;

/**
 * Prepare an instance of the WebSocket client. This client handles all aspects of connectivity for you:
 * - Connections are opened when you subscribe to topics
 * - If key & secret are provided, authentication is handled automatically
 * - If you subscribe to topics from different v5 products (e.g. spot and linear perps),
 *    subscription events are automatically routed to the different ws endpoints on bybit's side
 * - Heartbeats/ping/pong/reconnects are all handled automatically.
 *    If a connection drops, the client will clean it up, respawn a fresh connection and resubscribe for you.
 */
const wsClient = new WebsocketClient(
  {
    key: key,
    secret: secret,
    // testnet: false,
    // demoTrading: false, // set testnet to false, if you plan on using demo trading
  },
  logger,
);

wsClient.on('update', (data) => {
  console.log('raw message received ', JSON.stringify(data));
  // console.log('raw message received ', JSON.stringify(data, null, 2));
});

wsClient.on('open', (data) => {
  console.log('connection opened open:', data.wsKey);
});
wsClient.on('response', (data) => {
  console.log('log response: ', JSON.stringify(data, null, 2));
});
wsClient.on('reconnect', ({ wsKey }) => {
  console.log('ws automatically reconnecting.... ', wsKey);
});
wsClient.on('reconnected', (data) => {
  console.log('ws has reconnected ', data?.wsKey);
});
wsClient.on('exception', (data) => {
  console.error('ws exception: ', data);
});

/**
 * For private V5 topics, us the subscribeV5() method on the ws client or use the original subscribe() method.
 *
 * Note: for private endpoints the "category" field is ignored since there is only one private endpoint
 * (compared to one public one per category).
 * The "category" is only needed for public topics since bybit has one endpoint for public events per category.
 */

wsClient.subscribeV5('position', 'linear');
wsClient.subscribeV5(['order', 'wallet'], 'linear');

wsClient.subscribeV5('execution', 'linear');
// wsClient.subscribeV5('execution.fast', 'linear');
// wsClient.subscribeV5('execution.fast.linear', 'linear');

/**
 * The following has the same effect as above, since there's only one private endpoint for V5 account topics:
 */
// wsClient.subscribe('position');
// wsClient.subscribe('execution');
// wsClient.subscribe(['order', 'wallet', 'greek']);

// To unsubscribe from topics (after a 5 second delay, in this example):
// setTimeout(() => {
//   console.log('unsubscribing');
//   wsClient.unsubscribeV5('execution', 'linear');
// }, 5 * 1000);

// Topics are tracked per websocket type
// Get a list of subscribed topics (e.g. for public v3 spot topics) (after a 5 second delay)
setTimeout(() => {
  const activePrivateTopics = wsClient
    .getWsStore()
    .getTopics(WS_KEY_MAP.v5Private);
  console.log('Active private v5 topics: ', activePrivateTopics);

  const activePublicLinearTopics = wsClient
    .getWsStore()
    .getTopics(WS_KEY_MAP.v5LinearPublic);
  console.log('Active public linear v5 topics: ', activePublicLinearTopics);

  const activePublicSpotTopis = wsClient
    .getWsStore()
    .getTopics(WS_KEY_MAP.v5SpotPublic);
  console.log('Active public spot v5 topics: ', activePublicSpotTopis);

  const activePublicOptionsTopics = wsClient
    .getWsStore()
    .getTopics(WS_KEY_MAP.v5OptionPublic);
  console.log('Active public option v5 topics: ', activePublicOptionsTopics);
}, 5 * 1000);

Quickstart WebSocket API Walkthrough

Bybit's WebSocket API (WS-API) is a powerful tool to send commands over a persisted and pre-authenticated WebSocket connection, allowing for lower latency interactions with the exchange compared to REST API calls.

The WS-API supports a wide range of commands, including order submission and cancellation, making it ideal for latency sensitive integrations.

To use the WebSocket API:

  • Import the dedicated WebsocketAPIClient (a specialised wrapper around the WebsocketClient)
  • Create an instance of the WebsocketAPIClient with credentials.
  • Call the dedicated functions to send WS-API commands and await the responses.

Note that:

  • Authentication is automatic.
  • Connectivity is persistent with automatic failover.
  • All WS-API commands are wrapped in promises, allowing you to await individual Websocket API commands as if it were a REST API call.

Quickstart WebSocket API Example

import { DefaultLogger, WebsocketAPIClient } from 'bybit-api';

// const { DefaultLogger, WebsocketAPIClient } = require('bybit-api');

const key = process.env.API_KEY_COM;
const secret = process.env.API_SECRET_COM;

// function attachEventHandlers<TWSClient extends WebsocketClient>(
//   wsClient: TWSClient,
// ): void {
//   wsClient.on('update', (data) => {
//     console.log('raw message received ', JSON.stringify(data));
//   });
//   wsClient.on('open', (data) => {
//     console.log('ws connected', data.wsKey);
//   });
//   wsClient.on('reconnect', ({ wsKey }) => {
//     console.log('ws automatically reconnecting.... ', wsKey);
//   });
//   wsClient.on('reconnected', (data) => {
//     console.log('ws has reconnected ', data?.wsKey);
//   });
//   wsClient.on('authenticated', (data) => {
//     console.log('ws has authenticated ', data?.wsKey);
//   });
// }

async function main() {
  // Optional
  const logger = {
    ...DefaultLogger,
    // For a more detailed view of the WebsocketClient, enable the `trace` level by uncommenting the below line:
    // trace: (...params) => console.log('trace', ...params),
  };

  const wsClient = new WebsocketAPIClient(
    {
      key: key,
      secret: secret,
      // testnet: true, // Whether to use the testnet environment: https://testnet.bybit.com/app/user/api-management

      // Whether to use the livenet demo trading environment
      // Note: As of Jan 2025, demo trading only supports consuming events, it does
      // NOT support the WS API.
      // demoTrading: false,

      // If you want your own event handlers instead of the default ones with logs,
      // disable this setting and see the `attachEventHandlers` example below:
      // attachEventListeners: false
    },
    logger, // Optional: inject a custom logger
  );

  // Optional, see above "attachEventListeners". Attach basic event handlers, so nothing is left unhandled
  // attachEventHandlers(wsClient.getWSClient());

  // Optional, if you see RECV Window errors, you can use this to manage time issues.
  // ! However, make sure you sync your system clock first!
  // https://github.com/tiagosiebler/awesome-crypto-examples/wiki/Timestamp-for-this-request-is-outside-of-the-recvWindow
  // wsClient.setTimeOffsetMs(-5000);

  // Optional: prepare the WebSocket API connection in advance.
  // This happens automatically but you can do this early before making any API calls, to prevent delays from a cold start.
  // await wsClient.getWSClient().connectWSAPI();

  try {
    const response = await wsClient.submitNewOrder({
      category: 'linear',
      symbol: 'BTCUSDT',
      orderType: 'Limit',
      qty: '0.001',
      side: 'Buy',
      price: '50000',
    });
    console.log('submitNewOrder response: ', response);
  } catch (e) {
    console.log('submitNewOrder error: ', e);
  }

  try {
    const response = await wsClient.amendOrder({
      category: 'linear',
      symbol: 'BTCUSDT',
      orderId: 'b4b9e205-793c-4777-8112-0bf3c2d26b6e',
      qty: '0.001',
      price: '60000',
    });
    console.log('amendOrder response: ', response);
  } catch (e) {
    console.log('amendOrder error: ', e);
  }

  try {
    const response = await wsClient.cancelOrder({
      category: 'linear',
      symbol: 'BTCUSDT',
      orderId: 'b4b9e205-793c-4777-8112-0bf3c2d26b6e',
    });
    console.log('cancelOrder response: ', response);
  } catch (e) {
    console.log('cancelOrder error: ', e);
  }

  try {
    const response = await wsClient.batchSubmitOrders('linear', [
      {
        symbol: 'BTCUSDT',
        orderType: 'Limit',
        qty: '0.001',
        side: 'Buy',
        price: '50000',
      },
      {
        symbol: 'BTCUSDT',
        orderType: 'Limit',
        qty: '0.001',
        side: 'Buy',
        price: '60000',
      },
      {
        symbol: 'BTCUSDT',
        orderType: 'Limit',
        qty: '0.001',
        side: 'Buy',
        price: '70000',
      },
    ]);
    console.log('batchSubmitOrders response: ', response);
  } catch (e) {
    console.log('batchSubmitOrders error: ', e);
  }

  try {
    const response = await wsClient.batchAmendOrder('linear', [
      {
        symbol: 'BTCUSDT',
        orderId: '2473ee58',
        price: '80000',
      },
      {
        symbol: 'BTCUSDT',
        orderId: 'b4b9e205-793c-4777-8112-0bf3c2d26b6e',
        price: '80000',
      },
    ]);
    console.log('batchAmendOrder response: ', response);
  } catch (e) {
    console.log('batchAmendOrder error: ', e);
  }

  try {
    const response = await wsClient.batchCancelOrder('linear', [
      {
        symbol: 'BTCUSDT',
        orderId: '2473ee58',
      },
      {
        symbol: 'BTCUSDT',
        orderId: 'b4b9e205-793c-4777-8112-0bf3c2d26b6e',
      },
    ]);
    console.log('batchCancelOrder response: ', response);
  } catch (e) {
    console.log('batchCancelOrder error: ', e);
  }
}

main();

Endpoint Function Reference

Endpoint maps

Each REST client is a JavaScript class, which provides functions individually mapped to each endpoint available in the exchange's API offering.

The following table shows all methods available in each REST client, whether the method requires authentication (automatically handled if API keys are provided), as well as the exact endpoint each method is connected to.

This can be used to easily find which method to call, once you have found which endpoint you're looking to use.

All REST clients are in the src folder. For usage examples, make sure to check the examples folder.

List of clients:

If anything is missing or wrong, please open an issue or let us know in our Node.js Traders telegram group!

How to use table

Table consists of 4 parts:

  • Function name
  • AUTH
  • HTTP Method
  • Endpoint

Function name is the name of the function that can be called through the SDK. Check examples folder in the repo for more help on how to use them!

AUTH is a boolean value that indicates if the function requires authentication - which means you need to pass your API key and secret to the SDK.

HTTP Method shows HTTP method that the function uses to call the endpoint. Sometimes endpoints can have same URL, but different HTTP method so you can use this column to differentiate between them.

Endpoint is the URL that the function uses to call the endpoint. Best way to find exact function you need for the endpoint is to search for URL in this table and find corresponding function name.

rest-client-v5.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in rest-client-v5.ts.

FunctionAUTHHTTP MethodEndpoint
getSystemStatus()🔐GET/v5/system/status
getServerTime()GET/v5/market/time
requestDemoTradingFunds()🔐POST/v5/account/demo-apply-money
createDemoAccount()🔐POST/v5/user/create-demo-member
getSpreadInstrumentsInfo()GET/v5/spread/instrument
getSpreadOrderbook()GET/v5/spread/orderbook
getSpreadTickers()GET/v5/spread/tickers
getSpreadRecentTrades()GET/v5/spread/recent-trade
getSpreadMaxQty()🔐GET/v5/spread/max-qty
submitSpreadOrder()🔐POST/v5/spread/order/create
amendSpreadOrder()🔐POST/v5/spread/order/amend
cancelSpreadOrder()🔐POST/v5/spread/order/cancel
cancelAllSpreadOrders()🔐POST/v5/spread/order/cancel-all
getSpreadOpenOrders()🔐GET/v5/spread/order/realtime
getSpreadOrderHistory()🔐GET/v5/spread/order/history
getSpreadTradeHistory()🔐GET/v5/spread/execution/list
getKline()GET/v5/market/kline
getMarkPriceKline()GET/v5/market/mark-price-kline
getIndexPriceKline()GET/v5/market/index-price-kline
getPremiumIndexPriceKline()GET/v5/market/premium-index-price-kline
getInstrumentsInfo()GET/v5/market/instruments-info
getOrderbook()GET/v5/market/orderbook
getRPIOrderbook()GET/v5/market/rpi_orderbook
getTickers()GET/v5/market/tickers
getFundingRateHistory()GET/v5/market/funding/history
getPublicTradingHistory()GET/v5/market/recent-trade
getOpenInterest()GET/v5/market/open-interest
getHistoricalVolatility()GET/v5/market/historical-volatility
getInsurance()GET/v5/market/insurance
getRiskLimit()GET/v5/market/risk-limit
getOptionDeliveryPrice()GET/v5/market/delivery-price
getDeliveryPrice()GET/v5/market/delivery-price
getNewDeliveryPrice()GET/v5/market/new-delivery-price
getLongShortRatio()GET/v5/market/account-ratio
getIndexPriceComponents()GET/v5/market/index-price-components
getOrderPriceLimit()GET/v5/market/price-limit
getADLAlert()GET/v5/market/adlAlert
getFeeGroupStructure()GET/v5/market/fee-group-info
submitOrder()🔐POST/v5/order/create
amendOrder()🔐POST/v5/order/amend
cancelOrder()🔐POST/v5/order/cancel
getActiveOrders()🔐GET/v5/order/realtime
cancelAllOrders()🔐POST/v5/order/cancel-all
getHistoricOrders()🔐GET/v5/order/history
getExecutionList()🔐GET/v5/execution/list
batchSubmitOrders()🔐POST/v5/order/create-batch
batchAmendOrders()🔐POST/v5/order/amend-batch
batchCancelOrders()🔐POST/v5/order/cancel-batch
getSpotBorrowCheck()🔐GET/v5/order/spot-borrow-check
setDisconnectCancelAllWindow()🔐POST/v5/order/disconnected-cancel-all
setDisconnectCancelAllWindowV2()🔐POST/v5/order/disconnected-cancel-all
preCheckOrder()🔐POST/v5/order/pre-check
getPositionInfo()🔐GET/v5/position/list
setLeverage()🔐POST/v5/position/set-leverage
switchIsolatedMargin()🔐POST/v5/position/switch-isolated
setTPSLMode()🔐POST/v5/position/set-tpsl-mode
switchPositionMode()🔐POST/v5/position/switch-mode
setRiskLimit()🔐POST/v5/position/set-risk-limit
setTradingStop()🔐POST/v5/position/trading-stop
setAutoAddMargin()🔐POST/v5/position/set-auto-add-margin
addOrReduceMargin()🔐POST/v5/position/add-margin
getClosedPnL()🔐GET/v5/position/closed-pnl
getClosedOptionsPositions()🔐GET/v5/position/get-closed-positions
movePosition()🔐POST/v5/position/move-positions
getMovePositionHistory()🔐GET/v5/position/move-history
confirmNewRiskLimit()🔐POST/v5/position/confirm-pending-mmr
getPreUpgradeOrderHistory()🔐GET/v5/pre-upgrade/order/history
getPreUpgradeTradeHistory()🔐GET/v5/pre-upgrade/execution/list
getPreUpgradeClosedPnl()🔐GET/v5/pre-upgrade/position/closed-pnl
getPreUpgradeTransactions()🔐GET/v5/pre-upgrade/account/transaction-log
getPreUpgradeOptionDeliveryRecord()🔐GET/v5/pre-upgrade/asset/delivery-record
getPreUpgradeUSDCSessionSettlements()🔐GET/v5/pre-upgrade/asset/settlement-record
getWalletBalance()🔐GET/v5/account/wallet-balance
getTransferableAmount()🔐GET/v5/account/withdrawal
getAccountInstrumentsInfo()🔐GET/v5/account/instruments-info
upgradeToUnifiedAccount()🔐POST/v5/account/upgrade-to-uta
getBorrowHistory()🔐GET/v5/account/borrow-history
repayLiability()🔐POST/v5/account/quick-repayment
manualRepay()🔐POST/v5/account/repay
setCollateralCoin()🔐POST/v5/account/set-collateral-switch
batchSetCollateralCoin()🔐POST/v5/account/set-collateral-switch-batch
getCollateralInfo()🔐GET/v5/account/collateral-info
getCoinGreeks()🔐GET/v5/asset/coin-greeks
getFeeRate()🔐GET/v5/account/fee-rate
getAccountInfo()🔐GET/v5/account/info
getDCPInfo()🔐GET/v5/account/query-dcp-info
getTransactionLog()🔐GET/v5/account/transaction-log
getClassicTransactionLogs()🔐GET/v5/account/contract-transaction-log
getSMPGroup()🔐GET/v5/account/smp-group
setMarginMode()🔐POST/v5/account/set-margin-mode
setSpotHedging()🔐POST/v5/account/set-hedging-mode
setLimitPriceAction()🔐POST/v5/account/set-limit-px-action
getLimitPriceAction()🔐GET/v5/account/user-setting-config
setDeltaNeutralMode()🔐POST/v5/account/set-delta-mode
setMMP()🔐POST/v5/account/mmp-modify
resetMMP()🔐POST/v5/account/mmp-reset
getMMPState()🔐GET/v5/account/mmp-state
getOptionAssetInfo()🔐GET/v5/account/option-asset-info
getPayInfo()🔐GET/v5/account/pay-info
getTradeInfoForAnalysis()🔐GET/v5/account/trade-info-for-analysis
getAssetOverview()🔐GET/v5/asset/asset-overview
getPortfolioMarginInfo()🔐GET/v5/asset/portfolio-margin
getTotalMembersAssets()🔐GET/v5/asset/total-members-assets
getFundingAccountTransactionHistory()🔐GET/v5/asset/fundinghistory
getDeliveryRecord()🔐GET/v5/asset/delivery-record
getSettlementRecords()🔐GET/v5/asset/settlement-record
getCoinExchangeRecords()🔐GET/v5/asset/exchange/order-record
getCoinInfo()🔐GET/v5/asset/coin/query-info
getSubUID()🔐GET/v5/asset/transfer/query-sub-member-list
getAssetInfo()🔐GET/v5/asset/transfer/query-asset-info
getAllCoinsBalance()🔐GET/v5/asset/transfer/query-account-coins-balance
getCoinBalance()🔐GET/v5/asset/transfer/query-account-coin-balance
getWithdrawableAmount()🔐GET/v5/asset/withdraw/withdrawable-amount
getTransferableCoinList()🔐GET/v5/asset/transfer/query-transfer-coin-list
createInternalTransfer()🔐POST/v5/asset/transfer/inter-transfer
getInternalTransferRecords()🔐GET/v5/asset/transfer/query-inter-transfer-list
enableUniversalTransferForSubUIDs()🔐POST/v5/asset/transfer/save-transfer-sub-member
createUniversalTransfer()🔐POST/v5/asset/transfer/universal-transfer
getUniversalTransferRecords()🔐GET/v5/asset/transfer/query-universal-transfer-list
getAllowedDepositCoinInfo()🔐GET/v5/asset/deposit/query-allowed-list
setDepositAccount()🔐POST/v5/asset/deposit/deposit-to-account
getDepositRecords()🔐GET/v5/asset/deposit/query-record
getSubAccountDepositRecords()🔐GET/v5/asset/deposit/query-sub-member-record
getInternalDepositRecords()🔐GET/v5/asset/deposit/query-internal-record
getMasterDepositAddress()🔐GET/v5/asset/deposit/query-address
getSubDepositAddress()🔐GET/v5/asset/deposit/query-sub-member-address
querySubMemberAddress()🔐GET/v5/asset/deposit/query-sub-member-address
getWithdrawalRecords()🔐GET/v5/asset/withdraw/query-record
getWithdrawalAddressList()🔐GET/v5/asset/withdraw/query-address
getExchangeEntities()🔐GET/v5/asset/withdraw/vasp/list
submitWithdrawal()🔐POST/v5/asset/withdraw/create
cancelWithdrawal()🔐POST/v5/asset/withdraw/cancel
getConvertCoins()🔐GET/v5/asset/exchange/query-coin-list
requestConvertQuote()🔐POST/v5/asset/exchange/quote-apply
confirmConvertQuote()🔐POST/v5/asset/exchange/convert-execute
getConvertStatus()🔐GET/v5/asset/exchange/convert-result-query
getConvertHistory()🔐GET/v5/asset/exchange/query-convert-history
getSmallBalanceList()🔐GET/v5/asset/covert/small-balance-list
getFiatTradingPairList()🔐GET/v5/fiat/query-coin-list
createSubMember()🔐POST/v5/user/create-sub-member
createSubUIDAPIKey()🔐POST/v5/user/create-sub-api
getSubUIDList()🔐GET/v5/user/query-sub-members
getSubUIDListUnlimited()🔐GET/v5/user/submembers
setSubUIDFrozenState()🔐POST/v5/user/frozen-sub-member
getQueryApiKey()🔐GET/v5/user/query-api
getSubAccountAllApiKeys()🔐GET/v5/user/sub-apikeys
getUIDWalletType()🔐GET/v5/user/get-member-type
updateMasterApiKey()🔐POST/v5/user/update-api
updateSubApiKey()🔐POST/v5/user/update-sub-api
deleteSubMember()🔐POST/v5/user/del-submember
deleteMasterApiKey()🔐POST/v5/user/delete-api
deleteSubApiKey()🔐POST/v5/user/delete-sub-api
getAffiliateUserList()🔐GET/v5/affiliate/aff-user-list
getAffiliateUserInfo()🔐GET/v5/user/aff-customer-info
getFriendReferrals()🔐GET/v5/user/invitation/referrals
signAgreement()🔐POST/v5/user/agreement
getAlphaTradeQuote()🔐POST/v5/alpha/trade/quote
executeAlphaTradePurchase()🔐POST/v5/alpha/trade/purchase
executeAlphaTradeRedeem()🔐POST/v5/alpha/trade/redeem
getAlphaPayTokenList()🔐POST/v5/alpha/trade/pay-token-list
getAlphaTradeOrderList()🔐POST/v5/alpha/trade/order-list
getAlphaBizTokenList()🔐POST/v5/alpha/trade/biz-token-list
getAlphaBizTokenPriceList()🔐POST/v5/alpha/trade/biz-token-price-list
getAlphaBizTokenDetails()🔐POST/v5/alpha/trade/biz-token-details
getAlphaAssetList()🔐POST/v5/alpha/trade/asset-list
getAlphaAssetDetail()🔐POST/v5/alpha/trade/asset-detail
getVIPMarginData()GET/v5/spot-margin-trade/data
getHistoricalInterestRate()🔐GET/v5/spot-margin-trade/interest-rate-history
getSpotMarginCurrencyData()🔐GET/v5/spot-margin-trade/currency-data
toggleSpotMarginTrade()🔐POST/v5/spot-margin-trade/switch-mode
setSpotMarginLeverage()🔐POST/v5/spot-margin-trade/set-leverage
setSpotMarginLeverageV2()🔐POST/v5/spot-margin-trade/set-leverage
getSpotMarginState()🔐GET/v5/spot-margin-trade/state
manualBorrow()🔐POST/v5/account/borrow
getMaxBorrowableAmount()🔐GET/v5/spot-margin-trade/max-borrowable
getPositionTiers()🔐GET/v5/spot-margin-trade/position-tiers
getCoinState()🔐GET/v5/spot-margin-trade/coinstate
getAvailableAmountToRepay()🔐GET/v5/spot-margin-trade/repayment-available-amount
manualRepayWithoutConversion()🔐POST/v5/account/no-convert-repay
getAutoRepayMode()🔐GET/v5/spot-margin-trade/get-auto-repay-mode
setAutoRepayMode()🔐POST/v5/spot-margin-trade/set-auto-repay-mode
getSpotMarginLiability()🔐GET/v5/spot-margin-trade/liability
submitFixedRateBorrow()🔐POST/v5/spot-margin-trade/fixedborrow
getFixedRateBorrowOrderInfo()🔐GET/v5/spot-margin-trade/fixedborrow-order-info
getFixedRateBorrowContractInfo()🔐GET/v5/spot-margin-trade/fixedborrow-contract-info
getFixedRateBorrowOrderQuote()🔐GET/v5/spot-margin-trade/fixedborrow-order-quote
renewFixedRateBorrow()🔐POST/v5/spot-margin-trade/fixedborrow-renew
getSpotMarginCoinInfo()🔐GET/v5/spot-cross-margin-trade/pledge-token
getSpotMarginBorrowableCoinInfo()🔐GET/v5/spot-cross-margin-trade/borrow-token
getSpotMarginInterestAndQuota()🔐GET/v5/spot-cross-margin-trade/loan-info
getSpotMarginLoanAccountInfo()🔐GET/v5/spot-cross-margin-trade/account
spotMarginBorrow()🔐POST/v5/spot-cross-margin-trade/loan
spotMarginRepay()🔐POST/v5/spot-cross-margin-trade/repay
getSpotMarginBorrowOrderDetail()🔐GET/v5/spot-cross-margin-trade/orders
getSpotMarginRepaymentOrderDetail()🔐GET/v5/spot-cross-margin-trade/repay-history
toggleSpotCrossMarginTrade()🔐POST/v5/spot-cross-margin-trade/switch
getCollateralCoins()GET/v5/crypto-loan/collateral-data
getBorrowableCoins()GET/v5/crypto-loan/loanable-data
getAccountBorrowCollateralLimit()🔐GET/v5/crypto-loan/borrowable-collateralisable-number
borrowCryptoLoan()🔐POST/v5/crypto-loan/borrow
repayCryptoLoan()🔐POST/v5/crypto-loan/repay
getUnpaidLoanOrders()🔐GET/v5/crypto-loan/ongoing-orders
getRepaymentHistory()🔐GET/v5/crypto-loan/repayment-history
getCompletedLoanOrderHistory()🔐GET/v5/crypto-loan/borrow-history
getMaxAllowedReductionCollateralAmount()🔐GET/v5/crypto-loan/max-collateral-amount
adjustCollateralAmount()🔐POST/v5/crypto-loan/adjust-ltv
getLoanLTVAdjustmentHistory()🔐GET/v5/crypto-loan/adjustment-history
getLoanBorrowableCoins()GET/v5/crypto-loan-common/loanable-data
getLoanCollateralCoins()GET/v5/crypto-loan-common/collateral-data
getMaxCollateralAmount()🔐GET/v5/crypto-loan-common/max-collateral-amount
getMaxLoanAmount()🔐POST/v5/crypto-loan-common/max-loan
updateCollateralAmount()🔐POST/v5/crypto-loan-common/adjust-ltv
getCollateralAdjustmentHistory()🔐GET/v5/crypto-loan-common/adjustment-history
getCryptoLoanPosition()🔐GET/v5/crypto-loan-common/position
borrowFlexible()🔐POST/v5/crypto-loan-flexible/borrow
repayFlexible()🔐POST/v5/crypto-loan-flexible/repay
repayCollateralFlexible()🔐POST/v5/crypto-loan-flexible/repay-collateral
getOngoingFlexibleLoans()🔐GET/v5/crypto-loan-flexible/ongoing-coin
getBorrowHistoryFlexible()🔐GET/v5/crypto-loan-flexible/borrow-history
getRepaymentHistoryFlexible()🔐GET/v5/crypto-loan-flexible/repayment-history
getSupplyOrderQuoteFixed()GET/v5/crypto-loan-fixed/supply-order-quote
getBorrowOrderQuoteFixed()GET/v5/crypto-loan-fixed/borrow-order-quote
createBorrowOrderFixed()🔐POST/v5/crypto-loan-fixed/borrow
createSupplyOrderFixed()🔐POST/v5/crypto-loan-fixed/supply
cancelBorrowOrderFixed()🔐POST/v5/crypto-loan-fixed/borrow-order-cancel
cancelSupplyOrderFixed()🔐POST/v5/crypto-loan-fixed/supply-order-cancel
getBorrowContractInfoFixed()🔐GET/v5/crypto-loan-fixed/borrow-contract-info
getSupplyContractInfoFixed()🔐GET/v5/crypto-loan-fixed/supply-contract-info
getBorrowOrderInfoFixed()🔐GET/v5/crypto-loan-fixed/borrow-order-info
getSupplyOrderInfoFixed()🔐GET/v5/crypto-loan-fixed/supply-order-info
repayFixed()🔐POST/v5/crypto-loan-fixed/fully-repay
repayCollateralFixed()🔐POST/v5/crypto-loan-flexible/repay-collateral
getRepaymentHistoryFixed()🔐GET/v5/crypto-loan-fixed/repayment-history
renewBorrowOrderFixed()🔐POST/v5/crypto-loan-fixed/renew
getRenewOrderInfoFixed()🔐GET/v5/crypto-loan-fixed/renew-info
getInstitutionalLendingProductInfo()GET/v5/ins-loan/product-infos
getInstitutionalLendingMarginCoinInfo()GET/v5/ins-loan/ensure-tokens
getInstitutionalLendingMarginCoinInfoWithConversionRate()GET/v5/ins-loan/ensure-tokens-convert
getInstitutionalLendingLoanOrders()🔐GET/v5/ins-loan/loan-order
getInstitutionalLendingRepayOrders()🔐GET/v5/ins-loan/repaid-history
getInstitutionalLendingLTV()🔐GET/v5/ins-loan/ltv
getInstitutionalLendingLTVWithLadderConversionRate()🔐GET/v5/ins-loan/ltv-convert
bindOrUnbindUID()🔐POST/v5/ins-loan/association-uid
repayInstitutionalLoan()🔐POST/v5/ins-loan/repay-loan
getExchangeBrokerEarnings()🔐GET/v5/broker/earnings-info
getExchangeBrokerAccountInfo()🔐GET/v5/broker/account-info
getBrokerSubAccountDeposits()🔐GET/v5/broker/asset/query-sub-member-deposit-record
getBrokerVoucherSpec()🔐POST/v5/broker/award/info
issueBrokerVoucher()🔐POST/v5/broker/award/distribute-award
getBrokerIssuedVoucher()🔐POST/v5/broker/award/distribution-record
setBrokerRateLimit()🔐POST/v5/broker/apilimit/set
getBrokerRateLimitCap()🔐GET/v5/broker/apilimit/query-cap
getAllBrokerRateLimits()🔐GET/v5/broker/apilimit/query-all
getEarnProduct()GET/v5/earn/product
getAdvanceEarnProduct()GET/v5/earn/advance/product
getLiquidityMiningProduct()GET/v5/earn/liquidity-mining/product
getFixedTermEarnProduct()GET/v5/earn/fixed-term/product
getAdvanceEarnProductExtraInfo()GET/v5/earn/advance/product-extra-info
submitAdvanceEarnPlaceOrder()🔐POST/v5/earn/advance/place-order
getAdvanceEarnPosition()🔐GET/v5/earn/advance/position
getAdvanceEarnOrder()🔐GET/v5/earn/advance/order
submitFixedTermEarnOrder()🔐POST/v5/earn/fixed-term/place-order
redeemFixedTermEarn()🔐POST/v5/earn/fixed-term/redeem
getFixedTermEarnPosition()🔐GET/v5/earn/fixed-term/position
getFixedTermEarnOrder()🔐GET/v5/earn/fixed-term/order
setFixedTermEarnAutoInvest()🔐POST/v5/earn/fixed-term/position/auto-invest
submitStakeRedeem()🔐POST/v5/earn/place-order
getEarnOrderHistory()🔐GET/v5/earn/order
getEarnPosition()🔐GET/v5/earn/position
modifyEarnPosition()🔐POST/v5/earn/position/modify
getEarnYieldHistory()🔐GET/v5/earn/yield
getEarnHourlyYieldHistory()🔐GET/v5/earn/hourly-yield
getEarnAprHistory()GET/v5/earn/apr-history
getEarnTokenProduct()GET/v5/earn/token/product
submitEarnTokenOrder()🔐POST/v5/earn/token/place-order
getEarnTokenOrders()🔐GET/v5/earn/token/order
getEarnTokenPosition()🔐GET/v5/earn/token/position
getEarnTokenDailyYield()🔐GET/v5/earn/token/yield
getEarnTokenHourlyYield()🔐GET/v5/earn/token/hourly-yield
getEarnTokenHistoryApr()GET/v5/earn/token/history-apr
queryCardAssetRecords()🔐POST/v5/card/transaction/query-asset-records
queryCardPointsBalance()🔐POST/v5/card/reward/points/balance
queryCardPointsRecords()🔐POST/v5/card/reward/points/records
queryCardPointsTier()🔐POST/v5/card/reward/points/tier
queryCardMallItemList()🔐POST/v5/card/reward/mall/item/list
queryCardPointCashbackDetail()🔐POST/v5/card/reward/point/cashback/detail
createRFQ()🔐POST/v5/rfq/create-rfq
getRFQConfig()🔐GET/v5/rfq/config
cancelRFQ()🔐POST/v5/rfq/cancel-rfq
cancelAllRFQ()🔐POST/v5/rfq/cancel-all-rfq
createRFQQuote()🔐POST/v5/rfq/create-quote
executeRFQQuote()🔐POST/v5/rfq/execute-quote
cancelRFQQuote()🔐POST/v5/rfq/cancel-quote
cancelAllRFQQuotes()🔐POST/v5/rfq/cancel-all-quotes
getRFQRealtimeInfo()🔐GET/v5/rfq/rfq-realtime
getRFQHistory()🔐GET/v5/rfq/rfq-list
getRFQRealtimeQuote()🔐GET/v5/rfq/quote-realtime
getRFQHistoryQuote()🔐GET/v5/rfq/quote-list
getRFQTrades()🔐GET/v5/rfq/trade-list
getRFQPublicTrades()🔐GET/v5/rfq/public-trades
acceptNonLPQuote()🔐POST/v5/rfq/accept-other-quote
getP2PAccountCoinsBalance()🔐GET/v5/asset/transfer/query-account-coins-balance
getP2POnlineAds()🔐POST/v5/p2p/item/online
createP2PAd()🔐POST/v5/p2p/item/create
cancelP2PAd()🔐POST/v5/p2p/item/cancel
updateP2PAd()🔐POST/v5/p2p/item/update
getP2PPersonalAds()🔐POST/v5/p2p/item/personal/list
getP2PAdDetail()🔐POST/v5/p2p/item/info
getP2POrders()🔐POST/v5/p2p/order/simplifyList
getP2POrderDetail()🔐POST/v5/p2p/order/info
getP2PPendingOrders()🔐POST/v5/p2p/order/pending/simplifyList
markP2POrderAsPaid()🔐POST/v5/p2p/order/pay
releaseP2POrder()🔐POST/v5/p2p/order/finish
sendP2POrderMessage()🔐POST/v5/p2p/order/message/send
getP2POrderMessages()🔐POST/v5/p2p/order/message/listpage
getP2PUserInfo()🔐POST/v5/p2p/user/personal/info
getP2PCounterpartyUserInfo()🔐POST/v5/p2p/user/order/personal/info
getP2PUserPayments()🔐POST/v5/p2p/user/payment/list
setApiRateLimit()🔐POST/v5/apilimit/set
queryApiRateLimit()🔐GET/v5/apilimit/query
getRateLimitCap()🔐GET/v5/apilimit/query-cap
getAllRateLimits()🔐GET/v5/apilimit/query-all

websocket-api-client.ts

This table includes all endpoints from the official Exchange API docs and corresponding SDK functions for each endpoint that are found in websocket-api-client.ts.

This client provides WebSocket API endpoints which allow for faster interactions with the Bybit API via a WebSocket connection.

FunctionAUTHHTTP MethodEndpoint
submitNewOrder()🔐WSorder.create
amendOrder()🔐WSorder.amend
cancelOrder()🔐WSorder.cancel
batchSubmitOrders()🔐WSorder.create-batch
batchAmendOrder()🔐WSorder.amend-batch
batchCancelOrder()🔐WSorder.cancel-batch

Source: View endpoint map source

Bybit TypeScript FAQ

What does the Bybit TypeScript SDK cover?

Bybit supports Spot, Futures, Options, WebSockets, and WebSocket API workflows. The TypeScript guide covers the main REST and WebSocket integration patterns.

How do I authenticate private Bybit API calls in TypeScript?

Install bybit-api from npm & pass API credentials into the SDK client options, as shown in the Bybit TypeScript examples above. The SDK handles the exchange-specific signing requirements for private requests.

Does the Bybit TypeScript SDK help with WebSocket connection management?

Yes. Use the SDK WebSocket client for subscriptions, reconnect handling, and stream lifecycle management instead of building raw socket flows yourself.

When should I use the Bybit WebSocket API instead of REST?

Use REST for standard request and response workflows such as account queries and order management. Use the WebSocket API flow when you want persistent low-latency interactions over a connected session.

Direct Example Files

Open the example files for typed patterns that translate well into shared interfaces, services, and stricter application code.

Reference Links