Bybit JavaScript SDK
Use bybit-api to read Bybit market data, manage orders, and consume streams from Node.js. JavaScript and TypeScript use the same clients; request and response types are included.
Choose a client
- RestClientV5
- Current REST API client
- WebsocketClient
- Public and private streams
- WebsocketAPIClient
- Awaitable WebSocket API commands
- SpotClientV3
- Legacy compatibility only
Bybit API setup guides
Make your first public price request in the framework or runtime you use.
Runtime compatibility- Mobile
- React Native with ExpoiOS and Android
Make a first public request
In a Node.js project, install the package once. The REST, WebSocket, and WebSocket API examples below use .mjs files so Node.js can run their imports directly.
npm install bybit-api
REST walkthrough
Read public BTCUSDT linear-contract data with RestClientV5. These public requests require no credentials.
Save the code as rest-public.mjs and run:
node rest-public.mjs
import { RestClientV5 } from 'bybit-api'; const client = new RestClientV5(); async function main() { const serverTime = await client.getServerTime(); const instruments = await client.getInstrumentsInfo({ category: 'linear', symbol: 'BTCUSDT', }); const ticker = await client.getTickers({ category: 'linear', symbol: 'BTCUSDT', }); const orderBook = await client.getOrderbook({ category: 'linear', symbol: 'BTCUSDT', limit: 50, }); const candles = await client.getKline({ category: 'linear', symbol: 'BTCUSDT', interval: '1', limit: 5, }); console.log({ serverTime, instrument: instruments.result.list[0]?.symbol, ticker: ticker.result.list[0], orderBook, candles, });} main().catch(console.error);Expected response
Market values change on each run. These are the fields to check in the logged output.
| Field | Expected result |
|---|---|
| serverTime | The full response envelope. retCode: 0 means success; result.timeSecond and result.timeNano are decimal strings. |
| instrument / ticker | BTCUSDT and its ticker object. Prices and sizes are decimal strings. |
| orderBook / candles | Response envelopes with data under result. The order book has b and a levels; candles are under result.list. |
WebSocket walkthrough
Subscribe to public market-data streams without API credentials. The program logs connection events and incoming updates. It keeps running until you press Ctrl+C.
Save the code as ws-public.mjs and run:
node ws-public.mjs
import { WebsocketClient, isWsOrderbookEventV5 } from 'bybit-api';
const ws = new WebsocketClient();
ws.on('open', (data) => console.log('connected', data.wsKey, data.wsUrl));
ws.on('response', (data) => console.log('response', JSON.stringify(data)));
ws.on('update', (data) => {
if (isWsOrderbookEventV5(data)) {
console.log('orderbook update', data.data.s, data.type);
return;
}
console.log('stream update', JSON.stringify(data));
});
ws.on('reconnect', (data) => console.log('reconnecting', data.wsKey));
ws.on('reconnected', (data) => console.log('reconnected', data.wsKey));
ws.on('exception', console.error);
ws.subscribeV5(['orderbook.50.BTCUSDT', 'tickers.BTCUSDT', 'publicTrade.BTCUSDT'], 'linear');WebSocket API walkthrough
WebSocket API commands require API credentials. Set the environment variables shown in the code using credentials for the live environment. This example only constructs the client; it sends no request and places no order. Continue with the maintained example below for supported commands and connection handling.
Save the code as ws-api-setup.mjs and run:
node ws-api-setup.mjs
import { WebsocketAPIClient } from 'bybit-api';
const credentials = {
key: process.env.BYBIT_API_KEY,
secret: process.env.BYBIT_API_SECRET,
};
if (Object.values(credentials).some((value) => !value)) {
throw new Error('Set BYBIT_API_KEY, BYBIT_API_SECRET before running.');
}
const wsApi = new WebsocketAPIClient(credentials);
console.log('Client configured. No request sent.');Bybit API JavaScript Tutorial
A practical JavaScript guide to using bybit-api across the Bybit REST API, category-based Spot and derivatives routing, public and private streams, demo trading, testnet, regional routing, proxies, and WebSocket API commands.
Your app / service
bot, dashboard, worker
bybit-api
RestClientV5, WebsocketClient, WebsocketAPIClient
Bybit API
REST API, market data streams, account streams, WebSocket API
Common Bybit implementation tasks
Start from the behavior you need, not just from REST or WebSocket as a transport. Market-data driven systems should be event driven. Backfill via the REST API once and let WebSockets passively stream new data to you, as it becomes available.
Bybit API tutorial
Use the focused tutorial for RestClientV5, private WebSockets, demo trading, retCode checks, triggerDirection stops, and orderLinkId reconciliation.
Open Bybit tutorialCandle-Close Pipeline with Bybit APIs & WebSockets
Use the task guide for getKline backfill, subscribeV5 kline streams, response acknowledgement, confirm=true execution, reconnect resync, and shutdown.
Open candle pipeline guidePosition Management with Bybit APIs & WebSockets
Use the private-account guide for REST hydration, private order/execution/position/wallet streams, DCA/TP/SL dry-run intents, retCode gates, and triggerDirection stops.
Open position manager guideBackfill endpoint lookup
Use the endpoint reference to verify current REST API method names, request shapes, response fields, and category-specific naming before coding.
Open endpoint referenceReconnect-safe consumer
Tell the agent to treat transport reconnect as separate from application correctness, then resync through REST before re-enabling event-driven workflows.
Open agent guidanceFor coding agents
Give these files to an agent before implementation so it can find the package, examples, task guidance, and safety rules from the normal SDK-page flow.
AI prompt framework
Prompt generator and task recipes for exchange API projects.
llms.txt
Compact discovery file for agents choosing where to start.
llms-full.txt
Full route and implementation guidance index for machine readers.
SDK catalog
Machine-readable package, docs, examples, and task guidance.
Agent skill
Reusable workflow rules for coding agents using exchange APIs.
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.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| 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 | |
| getInstrumentSummary() | GET | /v5/market/instrument-summary | |
| getOrderbook() | GET | /v5/market/orderbook | |
| getFullDepthOrderbook() | GET | /v5/market/full_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 | |
| getOptionBaseCoins() | GET | /v5/market/option-base-coins | |
| getCorporateActions() | GET | /v5/market/corporate-action | |
| 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 |
| createStrategyOrder() | 🔐 | POST | /v5/strategy/create |
| getStrategyList() | 🔐 | GET | /v5/strategy/list |
| getStrategyOrderList() | 🔐 | GET | /v5/strategy/order-list |
| stopStrategy() | 🔐 | POST | /v5/strategy/stop |
| getPositionInfo() | 🔐 | GET | /v5/position/list |
| getFuturesLeverage() | 🔐 | GET | /v5/position/symbol-info |
| 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 |
| submitDepositOriginatorInfo() | 🔐 | POST | /v5/asset/travel-rule/deposit/submit |
| 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 |
| createTaxBatchExport() | 🔐 | POST | /v5/fht/compliance/tax/private/batch_create |
| getTaxBatchExport() | 🔐 | GET | /v5/fht/compliance/tax/private/batch_query |
| getAffiliateUserList() | 🔐 | GET | /v5/affiliate/aff-user-list |
| getAffiliateSubAffiliateList() | 🔐 | GET | /v5/affiliate/affiliate-sub-list |
| getAffiliateUserInfo() | 🔐 | GET | /v5/user/aff-customer-info |
| getFriendReferrals() | 🔐 | GET | /v5/user/invitation/referrals |
| getReferralCode() | 🔐 | GET | /v5/user/invitation/code |
| getReferralCommissionRecords() | 🔐 | POST | /v5/referral/commission/records |
| getReferralCampaignRewards() | 🔐 | POST | /v5/referral/campaign/rewards |
| getReferralUserIdentityProfile() | 🔐 | POST | /v5/referral/user/identity-profile |
| getReferralUserInvitations() | 🔐 | POST | /v5/referral/user/invitations |
| 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 |
| getAlphaPredictionEngineStatus() | 🔐 | GET | /v5/alpha/prediction/engine-status |
| getAlphaPredictionPayTokenList() | 🔐 | GET | /v5/alpha/prediction/pay-token-list |
| getAlphaPredictionEventDetail() | 🔐 | POST | /v5/alpha/prediction/event-detail |
| getAlphaPredictionOrderEstimate() | 🔐 | POST | /v5/alpha/prediction/order-estimate |
| executeAlphaPredictionBuy() | 🔐 | POST | /v5/alpha/prediction/buy |
| executeAlphaPredictionSell() | 🔐 | POST | /v5/alpha/prediction/sell |
| getAlphaPredictionOrderList() | 🔐 | POST | /v5/alpha/prediction/order-list |
| getAlphaPredictionOrderBook() | 🔐 | POST | /v5/alpha/prediction/order-book |
| getAlphaPredictionTokenPrice() | 🔐 | POST | /v5/alpha/prediction/token-price |
| getAlphaPredictionPriceHistory() | 🔐 | POST | /v5/alpha/prediction/price-history |
| getAlphaPredictionPositionList() | 🔐 | POST | /v5/alpha/prediction/position-list |
| getAlphaPredictionPositionHistory() | 🔐 | POST | /v5/alpha/prediction/position-history |
| getAlphaPredictionPortfolioSummary() | 🔐 | POST | /v5/alpha/prediction/portfolio-summary |
| getAlphaPredictionSideMarketList() | 🔐 | POST | /v5/alpha/prediction/side-market-list |
| getAlphaPredictionSportsMatchList() | 🔐 | POST | /v5/alpha/prediction/sports/match-list |
| getAlphaPredictionSportsTimelineStages() | 🔐 | GET | /v5/alpha/prediction/sports/timeline-stages |
| getAlphaPredictionSportsGroupStageDetail() | 🔐 | POST | /v5/alpha/prediction/sports/group-stage-detail |
| getAlphaLPPoolList() | 🔐 | POST | /v5/alpha/lp/pool-list |
| getAlphaLPPoolInfo() | 🔐 | POST | /v5/alpha/lp/pool-info |
| executeAlphaLPStake() | 🔐 | POST | /v5/alpha/lp/stake |
| executeAlphaLPRedeem() | 🔐 | POST | /v5/alpha/lp/redeem |
| getAlphaLPOrderList() | 🔐 | POST | /v5/alpha/lp/order-list |
| getAlphaLPPayTokenList() | 🔐 | POST | /v5/alpha/lp/pay-token-list |
| getAlphaLPPayTokenPrice() | 🔐 | POST | /v5/alpha/lp/pay-token-price |
| getAlphaLPPositionList() | 🔐 | POST | /v5/alpha/lp/position-list |
| 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 |
| getTradeAutoRepay() | 🔐 | GET | /v5/spot-margin-trade/get-trade-auto-repay |
| setTradeAutoRepay() | 🔐 | POST | /v5/spot-margin-trade/set-trade-auto-repay |
| 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 |
| getFixedRateBorrowInterestAccrued() | 🔐 | GET | /v5/spot-margin-trade/fixedborrow-interest-accrued |
| cancelFixedRateBorrowOrder() | 🔐 | POST | /v5/spot-margin-trade/fixedborrow-order-cancel |
| getFlexibleAvailableInventory() | 🔐 | GET | /v5/spot-margin-trade/flexible-available-inventory |
| getFixedRateAvailableInventory() | 🔐 | GET | /v5/spot-margin-trade/fixed-available-inventory |
| 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 |
| getFlexibleLoanAvailableInventory() | 🔐 | GET | /v5/crypto-loan-flexible/available-inventory |
| 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 |
| getFixedLoanAvailableInventory() | 🔐 | GET | /v5/crypto-loan-fixed/available-inventory |
| getInstitutionalLendingProductInfo() | GET | /v5/ins-loan/product-infos | |
| getInstitutionalLendingCoinDeltaAmount() | 🔐 | GET | /v5/ins-loan/coin-delta-amount |
| getInstitutionalLendingDelayLiquidationStatus() | 🔐 | GET | /v5/ins-loan/delay-liq-status |
| 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 | |
| getFlexibleSavingAutoSavings() | 🔐 | GET | /v5/earn/flexible-saving/auto-savings |
| setFlexibleSavingAutoSavings() | 🔐 | POST | /v5/earn/flexible-saving/auto-savings |
| getEarnCouponList() | 🔐 | GET | /v5/earn/coupons |
| getRWAProductList() | GET | /v5/earn/rwa/product | |
| placeRWAOrder() | 🔐 | POST | /v5/earn/rwa/place-order |
| getRWAPositionList() | 🔐 | GET | /v5/earn/rwa/position |
| getRWAOrderList() | 🔐 | GET | /v5/earn/rwa/order |
| getRWANavChart() | GET | /v5/earn/rwa/nav-chart | |
| getHoldToEarnAirdropProducts() | GET | /v5/earn/hold-to-earn/product | |
| getAdvanceEarnProduct() | GET | /v5/earn/advance/product | |
| getLiquidityMiningProduct() | GET | /v5/earn/liquidity-mining/product | |
| reinvestLiquidityMining() | 🔐 | POST | /v5/earn/liquidity-mining/reinvest |
| 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 |
| getHoldToEarnAirdropYieldHistory() | 🔐 | GET | /v5/earn/hold-to-earn/yield-history |
| 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 | |
| getPwmInvestmentPlanList() | 🔐 | GET | /v5/earn/pwm/investment-plan/list |
| getPwmInvestmentPlanDetail() | 🔐 | GET | /v5/earn/pwm/investment-plan/detail |
| getPwmPendingInvestmentPlanDetail() | 🔐 | GET | /v5/earn/pwm/investment-plan/new-plan |
| claimPwmWithdrawableFunds() | 🔐 | POST | /v5/earn/pwm/investment-plan/claim |
| getPwmInvestmentPlanAssetTrend() | 🔐 | GET | /v5/earn/pwm/investment-plan/asset-trend |
| getPwmFundHistoricalNav() | 🔐 | GET | /v5/earn/pwm/investment-plan/fund-nav |
| subscribePwmInvestmentPlan() | 🔐 | POST | /v5/earn/pwm/investment-plan/subscribe |
| investMorePwmInvestmentPlan() | 🔐 | POST | /v5/earn/pwm/investment-plan/invest-more |
| redeemPwmInvestmentPlan() | 🔐 | POST | /v5/earn/pwm/investment-plan/redeem |
| getPwmInvestmentPlanOrders() | 🔐 | GET | /v5/earn/pwm/investment-plan/order |
| getPwmSubscribableProductInfo() | GET | /v5/earn/pwm/customize-plan/product | |
| createPwmCustomizeInvestmentPlan() | 🔐 | POST | /v5/earn/pwm/customize-plan/create |
| getPwmAllFunds() | 🔐 | GET | /v5/earn/pwm/asset-manager/all-funds |
| settlePwmFundProfit() | 🔐 | POST | /v5/earn/pwm/asset-manager/settle-profit |
| createPwmFund() | 🔐 | POST | /v5/earn/pwm/asset-manager/create-fund |
| createPwmAssetManagerInvestmentPlan() | 🔐 | POST | /v5/earn/pwm/asset-manager/create-investment-plan |
| getPwmAssetManagerInvestmentPlans() | 🔐 | GET | /v5/earn/pwm/asset-manager/get-investment-plan |
| managePwmAssetManagerInvestmentPlan() | 🔐 | POST | /v5/earn/pwm/asset-manager/manage-investment-plan |
| getPwmAllFundOrders() | 🔐 | GET | /v5/earn/pwm/asset-manager/all-order |
| managePwmFundOrder() | 🔐 | POST | /v5/earn/pwm/asset-manager/manage-order |
| createPwmFundSubAccount() | 🔐 | POST | /v5/earn/pwm/asset-manager/create-sub-account |
| pwmFundTransfer() | 🔐 | POST | /v5/earn/pwm/fund-transfer |
| getPwmFundTransferRecords() | 🔐 | GET | /v5/earn/pwm/query-fund-transfer-result |
| 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 |
| getRFQDetails() | 🔐 | GET | /v5/rfq/rfq-detail-list |
| 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 |
| reviewP2PSellerCancelOrderApply() | 🔐 | POST | /v5/p2p/order/buyer/examine/sellerCancelOrderApply |
| sendP2POrderMessage() | 🔐 | POST | /v5/p2p/order/message/send |
| getP2PChatSessions() | 🔐 | POST | /v5/p2p/chat/session/list_v1 |
| getP2PChatSessionId() | 🔐 | POST | /v5/p2p/chat/session/getSessionId |
| sendP2PChatMessage() | 🔐 | POST | /v5/p2p/chat/message/send_v1 |
| getP2PChatMessages() | 🔐 | POST | /v5/p2p/chat/message/listpage_v1 |
| 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 |
| getLaunchpoolProjectList() | GET | /v5/spot-x/launchpool/project/list | |
| getLaunchpoolUserActivityLog() | 🔐 | POST | /v5/spot-x/launchpool/user/activity-log |
| getLaunchpoolCurrentStaking() | 🔐 | GET | /v5/spot-x/launchpool/user/current-staking |
| getLaunchpoolUserHistory() | 🔐 | POST | /v5/spot-x/launchpool/user/history |
| getPuzzleProjectList() | GET | /v5/spot-x/puzzle/project/list | |
| getTokenSplashProjectList() | GET | /v5/spot-x/token-splash/project/list | |
| getTokenSplashUserActivityParams() | 🔐 | GET | /v5/spot-x/token-splash/user/activity-params |
| getEventInstrumentsInfo() | GET | /v5/event/instruments-info | |
| getEventOrderbook() | GET | /v5/event/orderbook | |
| getEventOrderHistory() | 🔐 | GET | /v5/event/order-list |
| getEventActiveOrders() | 🔐 | GET | /v5/event/order-realtime |
| getEventPositionInfo() | 🔐 | GET | /v5/event/positions |
| getEventTradeHistory() | 🔐 | GET | /v5/event/trades |
| getEventSettlementRecords() | 🔐 | GET | /v5/event/settlements |
| submitEventQuote() | 🔐 | POST | /v5/event/quotes |
| cancelEventQuote() | 🔐 | POST | /v5/event/cancel |
| cancelAllEventQuotes() | 🔐 | POST | /v5/event/cancel-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.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| submitNewOrder() | 🔐 | WS | order.create |
| amendOrder() | 🔐 | WS | order.amend |
| cancelOrder() | 🔐 | WS | order.cancel |
| batchSubmitOrders() | 🔐 | WS | order.create-batch |
| batchAmendOrder() | 🔐 | WS | order.amend-batch |
| batchCancelOrder() | 🔐 | WS | order.cancel-batch |
Bybit JavaScript FAQ
What does the Bybit JavaScript SDK cover?
Bybit supports Spot, Futures, Margin, Options, WebSockets, and WebSocket API workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.
How do I authenticate private Bybit API calls in JavaScript?
The public REST example above needs no credentials. For private calls, follow the authentication setup for bybit-api in the full tutorial, including the credentials or signer required by your exchange.
Bybit authentication and setupDoes the Bybit JavaScript 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 below for JavaScript and TypeScript-compatible request, authentication, WebSocket, and Node.js service patterns.