OKX JavaScript SDK
Use okx-api to read OKX 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
- RestClient
- Public and private REST API
- WebsocketClient
- Public, private, and business streams
- WebsocketAPIClient
- Awaitable WebSocket API commands
Make a first public request
In a Node.js project, install the package once. The REST and WebSocket API examples below use .mjs files so Node.js can run their imports directly.
npm install okx-api
REST walkthrough
Read public BTC-USDT Spot data with RestClient. These public requests require no credentials.
Save the code as rest-public.mjs and run:
node rest-public.mjs
import { RestClient } from 'okx-api'; const client = new RestClient(); async function main() { try { const serverTime = await client.getSystemTime({}); console.log('Server time:', serverTime[0]?.ts); } catch (error) { console.error('Failed to get server time:', error); } try { const instruments = await client.getInstruments({ instType: 'SPOT', instId: 'BTC-USDT', }); console.log('Instrument:', instruments[0]?.instId); } catch (error) { console.error('Failed to get instruments:', error); } try { const ticker = await client.getTicker({ instId: 'BTC-USDT' }); console.log('Last price:', ticker[0]?.last); } catch (error) { console.error('Failed to get ticker:', error); } try { const orderBook = await client.getOrderBook({ instId: 'BTC-USDT', sz: '5', }); console.log('Best bid:', orderBook[0]?.bids[0]); } catch (error) { console.error('Failed to get order book:', error); } try { const candles = await client.getCandles({ instId: 'BTC-USDT', bar: '1m', limit: '5', }); console.log('Latest candle:', candles[0]); } catch (error) { console.error('Failed to get candles:', error); }} main();Expected response
Market values change on each run. These are the fields to check in the logged output.
| Field | Expected result |
|---|---|
| Server time / Instrument | A Unix-millisecond timestamp string and BTC-USDT. |
| Last price / Best bid | A decimal-string price and an order-book level array. |
| Latest candle | An array starting with timestamp, open, high, low, close, and volume. Its final confirmation flag is 0 while the candle is open. |
WebSocket walkthrough
Connecting to OKX's WebSocket streams is straightforward with the WebsocketClient.
- Install the OKX JavaScript SDK via NPM:
npm install okx-api. - Import the WebsocketClient (General WebSocket wrapper for all available OKX 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 demonstrate how you can easily subscribe to one or more available channels via the instanced WebsocketClient across all available topics and product groups.
This setup allows you to receive real-time updates on any activity on the exchange, 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.
import { DefaultLogger, WebsocketClient } from 'okx-api'; // Optional: Inject a custom logger.// This example overrides the default logger to also log "trace" (super verbose) messages, which are disabled by defaultconst logger = { ...DefaultLogger, // trace: (...params) => console.log('trace', ...params),}; // For private events, all 3 of the following are required (per account):const API_KEY = process.env.API_KEY_COM;const API_SECRET = process.env.API_SECRET_COM;const API_PASSPHRASE = process.env.API_PASSPHRASE_COM; // If running from CLI in unix, you can pass env vars as such:// API_KEY_COM='lkm12n3-2ba3-1mxf-fn13-lkm12n3a' API_SECRET_COM='035B2B9637E1BDFFEE2646BFBDDB8CE4' API_PASSPHRASE_COM='ComplexPa$$!23$5^' ts-node examples/ws-private.ts // note the single quotes, preventing special characters such as $ from being incorrectly passed if (!API_KEY) { throw new Error('API_KEY is missing');} if (!API_SECRET) { throw new Error('API_SECRET is missing');} if (!API_PASSPHRASE) { throw new Error('API_PASSPHRASE is missing');} const wsClient = new WebsocketClient( { // For Global users (www.okx.com), you don't need to set the market. // It will use global by default. // Not needed: market: 'GLOBAL', // For EEA users (my.okx.com), set market to "EEA": // market: 'EEA', // For US users (app.okx.com), set market to "US": // market: 'US', accounts: [ // For private topics, include one or more accounts in an array. Otherwise only public topics will work { apiKey: API_KEY, apiSecret: API_SECRET, apiPass: API_PASSPHRASE, }, // { // apiKey: 'yourApiKeyHere', // apiSecret: 'yourApiSecretHere', // apiPass: 'yourApiPassHere', // }, // { // apiKey: 'anotherAccountKey', // apiSecret: 'anotherAccountSecret', // apiPass: 'anotherAccountPass', // }, ], }, logger,); // Raw data will arrive on the 'update' eventwsClient.on('update', (data) => { // console.log('ws update (raw data received)', JSON.stringify(data, null, 2)); console.log('ws update (raw data received)', JSON.stringify(data));}); wsClient.on('open', (data) => { console.log('connection opened open:', data.wsKey);}); // Replies (e.g. authenticating or subscribing to channels) will arrive on the 'response' eventwsClient.on('response', (data) => { // console.log('ws response: ', JSON.stringify(data, null, 2)); console.log('ws response: ', JSON.stringify(data));}); 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);}); // Optional, connect before subscribing:// wsClient.connectPrivate(); // This is optional though. The wsclient will automatically open and subscribe if the connection doesn't exist yet. /** * # Subscribing to channels * * Subscribe to channels using the inner "args" part of the subscription request described in the OKX API docs. * * For example, if the docs state your request should look as such: { op: "subscribe", args: [ { channel: "account" } ] } * * You should call the wsClient.subscribe function using only the "args". * * Either of these examples is correct (one channel vs one or more channels in an array): wsClient.subscribe({ channel: 'account' }); wsClient.subscribe([ { channel: "account" } ]) */ // Subscribe one event at a time:wsClient.subscribe({ channel: 'account',}); // OR, combine multiple subscription events into one request using an array instead of an object:wsClient.subscribe([ { channel: 'account', }, { channel: 'positions', instType: 'ANY', },]); /** * Examples for each private channel listed in the API docs: * https://www.okx.com/docs-v5/en/#websocket-api-private-channel */ // Account events for all symbolswsClient.subscribe({ channel: 'account',}); // Account events for specific symbol onlywsClient.subscribe({ channel: 'account', ccy: 'BTC',}); // Withdrawal events for specific symbol onlywsClient.subscribe({ channel: 'withdrawal-info', ccy: 'BTC',}); // Position events on any instrument typewsClient.subscribe({ channel: 'positions', instType: 'ANY',}); // Position events on specific instrumentswsClient.subscribe({ channel: 'positions', instType: 'SWAP', instFamily: 'ETH-USD', instId: 'ETH-USD-SWAP',}); // Balance & position channelwsClient.subscribe({ channel: 'balance_and_position',}); // Order channelwsClient.subscribe({ channel: 'orders', instType: 'ANY',}); // Order channel with extra argswsClient.subscribe({ channel: 'orders', instType: 'FUTURES', instFamily: 'BTC-USD',}); // Algo orders channelwsClient.subscribe({ channel: 'orders-algo', instType: 'ANY',}); // Advance algo orders channelwsClient.subscribe({ channel: 'algo-advance', instType: 'ANY',}); // Position risk warning channelwsClient.subscribe({ channel: 'liquidation-warning', instType: 'ANY',}); // Account greeks channelwsClient.subscribe({ channel: 'account-greeks',}); // Spot grid algo orders channelwsClient.subscribe({ channel: 'grid-orders-spot', instType: 'SPOT',}); // Contract grid orders channelwsClient.subscribe({ channel: 'grid-orders-contract', instType: 'ANY',}); // Moon grid orders channelwsClient.subscribe({ channel: 'grid-orders-moon', instType: 'ANY',}); // Moon grid orders channelwsClient.subscribe({ channel: 'grid-orders-moon', instType: 'ANY',}); // Grid positions channelwsClient.subscribe({ channel: 'grid-positions', algoId: '449327675342323712',}); // Grid sub orders channelwsClient.subscribe({ channel: 'grid-sub-orders', algoId: '449327675342323712',});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 'okx-api'; const credentials = { apiKey: process.env.OKX_API_KEY, apiSecret: process.env.OKX_API_SECRET, apiPass: process.env.OKX_API_PASSPHRASE,}; if (Object.values(credentials).some((value) => !value)) { throw new Error('Set OKX_API_KEY, OKX_API_SECRET, OKX_API_PASSPHRASE before running.');} const wsApi = new WebsocketAPIClient(credentials);console.log('Client configured. No request sent.');OKX API JavaScript Tutorial
A practical JavaScript guide to using okx-api across the OKX REST API, public and private streams, business channels, demo trading, regional API groups, proxies, and WebSocket API commands.
Your app / service
bot, dashboard, worker
okx-api
RestClient, WebsocketClient, WebsocketAPIClient
OKX API
REST API, public streams, private streams, business streams, WebSocket API
Common OKX 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.
REST API hydration or backfill
Start from the REST API quickstart and endpoint reference, then normalize exchange-specific IDs, timestamps, symbols, and product scope.
Open endpoint referenceWebSocket consumer
Start from the WebSocket quickstart that matches the task boundary, verify subscription acknowledgement semantics, and keep reconnect handling explicit.
Open WebSocket quickstartAgent prompt recipe
Use the AI prompt generator when the task combines REST API hydration, live streams, in-memory state, operational outputs, or strategy code.
Build an agent promptFor 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.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.ts.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| getAccountInstruments() | 🔐 | GET | /api/v5/account/instruments |
| getBalance() | 🔐 | GET | /api/v5/account/balance |
| getPositions() | 🔐 | GET | /api/v5/account/positions |
| getPositionsHistory() | 🔐 | GET | /api/v5/account/positions-history |
| getAccountPositionRisk() | 🔐 | GET | /api/v5/account/account-position-risk |
| getBills() | 🔐 | GET | /api/v5/account/bills |
| getBillsArchive() | 🔐 | GET | /api/v5/account/bills-archive |
| getAccountBillSubtypes() | 🔐 | GET | /api/v5/account/subtypes |
| requestBillsHistoryDownloadLink() | 🔐 | POST | /api/v5/account/bills-history-archive |
| getRequestedBillsHistoryLink() | 🔐 | GET | /api/v5/account/bills-history-archive |
| getAccountConfiguration() | 🔐 | GET | /api/v5/account/config |
| setPositionMode() | 🔐 | POST | /api/v5/account/set-position-mode |
| setSettleCurrency() | 🔐 | POST | /api/v5/account/set-settle-currency |
| setFeeType() | 🔐 | POST | /api/v5/account/set-fee-type |
| setLeverage() | 🔐 | POST | /api/v5/account/set-leverage |
| getMaxBuySellAmount() | 🔐 | GET | /api/v5/account/max-size |
| getMaxAvailableTradableAmount() | 🔐 | GET | /api/v5/account/max-avail-size |
| changePositionMargin() | 🔐 | POST | /api/v5/account/position/margin-balance |
| movePositions() | 🔐 | POST | /api/v5/account/move-positions |
| getMovePositionsHistory() | 🔐 | GET | /api/v5/account/move-positions-history |
| getLeverage() | 🔐 | GET | /api/v5/account/leverage-info |
| getLeverageV2() | 🔐 | GET | /api/v5/account/leverage-info |
| getLeverageEstimatedInfo() | 🔐 | GET | /api/v5/account/adjust-leverage-info |
| getMaxLoan() | 🔐 | GET | /api/v5/account/max-loan |
| getFeeRates() | 🔐 | GET | /api/v5/account/trade-fee |
| getInterestAccrued() | 🔐 | GET | /api/v5/account/interest-accrued |
| getInterestRate() | 🔐 | GET | /api/v5/account/interest-rate |
| setGreeksDisplayType() | 🔐 | POST | /api/v5/account/set-greeks |
| setIsolatedMode() | 🔐 | POST | /api/v5/account/set-isolated-mode |
| getMaxWithdrawals() | 🔐 | GET | /api/v5/account/max-withdrawal |
| getAccountRiskState() | 🔐 | GET | /api/v5/account/risk-state |
| setAccountCollateralAssets() | 🔐 | POST | /api/v5/account/set-collateral-assets |
| getAccountCollateralAssets() | 🔐 | GET | /api/v5/account/collateral-assets |
| submitQuickMarginBorrowRepay() | 🔐 | POST | /api/v5/account/quick-margin-borrow-repay |
| getQuickMarginBorrowRepayHistory() | 🔐 | GET | /api/v5/account/quick-margin-borrow-repay-history |
| borrowRepayVIPLoan() | 🔐 | POST | /api/v5/account/borrow-repay |
| getVIPLoanBorrowRepayHistory() | 🔐 | GET | /api/v5/account/borrow-repay-history |
| getVIPInterestAccrued() | 🔐 | GET | /api/v5/account/vip-interest-accrued |
| getVIPInterestDeducted() | 🔐 | GET | /api/v5/account/vip-interest-deducted |
| getVIPLoanOrders() | 🔐 | GET | /api/v5/account/vip-loan-order-list |
| getVIPLoanOrder() | 🔐 | GET | /api/v5/account/vip-loan-order-detail |
| getBorrowInterestLimits() | 🔐 | GET | /api/v5/account/interest-limits |
| getFixedLoanBorrowLimit() | 🔐 | GET | /api/v5/account/fixed-loan/borrowing-limit |
| getFixedLoanBorrowQuote() | 🔐 | GET | /api/v5/account/fixed-loan/borrowing-quote |
| submitFixedLoanBorrowOrder() | 🔐 | POST | /api/v5/account/fixed-loan/borrowing-order |
| updateFixedLoanBorrowOrder() | 🔐 | POST | /api/v5/account/fixed-loan/amend-borrowing-order |
| manualRenewFixedLoanBorrowOrder() | 🔐 | POST | /api/v5/account/fixed-loan/manual-reborrow |
| repayFixedLoanBorrowOrder() | 🔐 | POST | /api/v5/account/fixed-loan/repay-borrowing-order |
| convertFixedLoanToMarketLoan() | 🔐 | POST | /api/v5/account/fixed-loan/convert-to-market-loan |
| reduceFixedLoanLiabilities() | 🔐 | POST | /api/v5/account/fixed-loan/reduce-liabilities |
| getFixedLoanBorrowOrders() | 🔐 | GET | /api/v5/account/fixed-loan/borrowing-orders-list |
| manualBorrowRepay() | 🔐 | POST | /api/v5/account/spot-manual-borrow-repay |
| setAutoRepay() | 🔐 | POST | /api/v5/account/set-auto-repay |
| getBorrowRepayHistory() | 🔐 | GET | /api/v5/account/spot-borrow-repay-history |
| positionBuilder() | 🔐 | POST | /api/v5/account/position-builder |
| updateRiskOffsetAmount() | 🔐 | POST | /api/v5/account/set-riskOffset-amt |
| getGreeks() | 🔐 | GET | /api/v5/account/greeks |
| getPMLimitation() | 🔐 | GET | /api/v5/account/position-tiers |
| updateRiskOffsetType() | 🔐 | POST | /api/v5/account/set-riskOffset-type |
| activateOption() | 🔐 | POST | /api/v5/account/activate-option |
| activateFeature() | 🔐 | POST | /api/v5/account/activate-feature |
| setAutoLoan() | 🔐 | POST | /api/v5/account/set-auto-loan |
| presetAccountLevelSwitch() | 🔐 | POST | /api/v5/account/account-level-switch-preset |
| getAccountSwitchPrecheck() | 🔐 | GET | /api/v5/account/set-account-switch-precheck |
| setAccountMode() | 🔐 | POST | /api/v5/account/set-account-level |
| resetMMPStatus() | 🔐 | POST | /api/v5/account/mmp-reset |
| setMMPConfig() | 🔐 | POST | /api/v5/account/mmp-config |
| getMMPConfig() | 🔐 | GET | /api/v5/account/mmp-config |
| setTradingConfig() | 🔐 | POST | /api/v5/account/set-trading-config |
| precheckSetDeltaNeutral() | 🔐 | GET | /api/v5/account/precheck-set-delta-neutral |
| submitOrder() | 🔐 | POST | /api/v5/trade/order |
| submitMultipleOrders() | 🔐 | POST | /api/v5/trade/batch-orders |
| cancelOrder() | 🔐 | POST | /api/v5/trade/cancel-order |
| cancelMultipleOrders() | 🔐 | POST | /api/v5/trade/cancel-batch-orders |
| amendOrder() | 🔐 | POST | /api/v5/trade/amend-order |
| amendMultipleOrders() | 🔐 | POST | /api/v5/trade/amend-batch-orders |
| closePositions() | 🔐 | POST | /api/v5/trade/close-position |
| getOrderDetails() | 🔐 | GET | /api/v5/trade/order |
| getOrderList() | 🔐 | GET | /api/v5/trade/orders-pending |
| getOrderHistory() | 🔐 | GET | /api/v5/trade/orders-history |
| getOrderHistoryArchive() | 🔐 | GET | /api/v5/trade/orders-history-archive |
| getFills() | 🔐 | GET | /api/v5/trade/fills |
| getFillsHistory() | 🔐 | GET | /api/v5/trade/fills-history |
| getEasyConvertCurrencies() | 🔐 | GET | /api/v5/trade/easy-convert-currency-list |
| submitEasyConvert() | 🔐 | POST | /api/v5/trade/easy-convert |
| getEasyConvertHistory() | 🔐 | GET | /api/v5/trade/easy-convert-history |
| getOneClickRepayCurrencyList() | 🔐 | GET | /api/v5/trade/one-click-repay-currency-list |
| submitOneClickRepay() | 🔐 | POST | /api/v5/trade/one-click-repay |
| getOneClickRepayHistory() | 🔐 | GET | /api/v5/trade/one-click-repay-history |
| cancelMassOrder() | 🔐 | POST | /api/v5/trade/mass-cancel |
| cancelAllAfter() | 🔐 | POST | /api/v5/trade/cancel-all-after |
| getAccountRateLimit() | 🔐 | GET | /api/v5/trade/account-rate-limit |
| submitOrderPrecheck() | 🔐 | POST | /api/v5/trade/order-precheck |
| placeAlgoOrder() | 🔐 | POST | /api/v5/trade/order-algo |
| cancelAlgoOrder() | 🔐 | POST | /api/v5/trade/cancel-algos |
| amendAlgoOrder() | 🔐 | POST | /api/v5/trade/amend-algos |
| cancelAdvanceAlgoOrder() | 🔐 | POST | /api/v5/trade/cancel-advance-algos |
| getAlgoOrderDetails() | 🔐 | GET | /api/v5/trade/order-algo |
| getAlgoOrderList() | 🔐 | GET | /api/v5/trade/orders-algo-pending |
| getAlgoOrderHistory() | 🔐 | GET | /api/v5/trade/orders-algo-history |
| placeGridAlgoOrder() | 🔐 | POST | /api/v5/tradingBot/grid/order-algo |
| amendGridAlgoOrder() | 🔐 | POST | /api/v5/tradingBot/grid/amend-order-algo |
| stopGridAlgoOrder() | 🔐 | POST | /api/v5/tradingBot/grid/stop-order-algo |
| closeGridContractPosition() | 🔐 | POST | /api/v5/tradingBot/grid/close-position |
| cancelGridContractCloseOrder() | 🔐 | POST | /api/v5/tradingBot/grid/cancel-close-order |
| instantTriggerGridAlgoOrder() | 🔐 | POST | /api/v5/tradingBot/grid/order-instant-trigger |
| getGridAlgoOrderList() | 🔐 | GET | /api/v5/tradingBot/grid/orders-algo-pending |
| getGridAlgoOrderHistory() | 🔐 | GET | /api/v5/tradingBot/grid/orders-algo-history |
| getGridAlgoOrderDetails() | 🔐 | GET | /api/v5/tradingBot/grid/orders-algo-details |
| getGridAlgoSubOrders() | 🔐 | GET | /api/v5/tradingBot/grid/sub-orders |
| getGridAlgoOrderPositions() | 🔐 | GET | /api/v5/tradingBot/grid/positions |
| spotGridWithdrawIncome() | 🔐 | POST | /api/v5/tradingBot/grid/withdraw-income |
| computeGridMarginBalance() | 🔐 | POST | /api/v5/tradingBot/grid/compute-margin-balance |
| adjustGridMarginBalance() | 🔐 | POST | /api/v5/tradingBot/grid/margin-balance |
| adjustGridInvestment() | 🔐 | POST | /api/v5/tradingBot/grid/adjust-investment |
| getGridAIParameter() | GET | /api/v5/tradingBot/grid/ai-param | |
| computeGridMinInvestment() | POST | /api/v5/tradingBot/grid/min-investment | |
| getRSIBackTesting() | GET | /api/v5/tradingBot/public/rsi-back-testing | |
| getMaxGridQuantity() | GET | /api/v5/tradingBot/grid/grid-quantity | |
| createSignal() | 🔐 | POST | /api/v5/tradingBot/signal/create-signal |
| getSignals() | 🔐 | GET | /api/v5/tradingBot/signal/signals |
| createSignalBot() | 🔐 | POST | /api/v5/tradingBot/signal/order-algo |
| cancelSignalBots() | 🔐 | POST | /api/v5/tradingBot/signal/stop-order-algo |
| updateSignalMargin() | 🔐 | POST | /api/v5/tradingBot/signal/margin-balance |
| updateSignalTPSL() | 🔐 | POST | /api/v5/tradingBot/signal/amendTPSL |
| setSignalInstruments() | 🔐 | POST | /api/v5/tradingBot/signal/set-instruments |
| getSignalBotOrder() | 🔐 | GET | /api/v5/tradingBot/signal/orders-algo-details |
| getActiveSignalBot() | 🔐 | GET | /api/v5/tradingBot/signal/orders-algo-details |
| getSignalBotHistory() | 🔐 | GET | /api/v5/tradingBot/signal/orders-algo-history |
| getSignalBotPositions() | 🔐 | GET | /api/v5/tradingBot/signal/positions |
| getSignalBotPositionHistory() | 🔐 | GET | /api/v5/tradingBot/signal/positions-history |
| closeSignalBotPosition() | 🔐 | POST | /api/v5/tradingBot/signal/close-position |
| placeSignalBotSubOrder() | 🔐 | POST | /api/v5/tradingBot/signal/sub-order |
| cancelSubOrder() | 🔐 | POST | /api/v5/tradingBot/signal/cancel-sub-order |
| getSignalBotSubOrders() | 🔐 | GET | /api/v5/tradingBot/signal/sub-orders |
| getSignalBotEventHistory() | 🔐 | GET | /api/v5/tradingBot/signal/event-history |
| submitRecurringBuyOrder() | 🔐 | POST | /api/v5/tradingBot/recurring/order-algo |
| amendRecurringBuyOrder() | 🔐 | POST | /api/v5/tradingBot/recurring/amend-order-algo |
| stopRecurringBuyOrder() | 🔐 | POST | /api/v5/tradingBot/recurring/stop-order-algo |
| getRecurringBuyOrders() | 🔐 | GET | /api/v5/tradingBot/recurring/orders-algo-pending |
| getRecurringBuyOrderHistory() | 🔐 | GET | /api/v5/tradingBot/recurring/orders-algo-history |
| getRecurringBuyOrderDetails() | 🔐 | GET | /api/v5/tradingBot/recurring/orders-algo-details |
| getRecurringBuySubOrders() | 🔐 | GET | /api/v5/tradingBot/recurring/sub-orders |
| getCopytradingSubpositions() | 🔐 | GET | /api/v5/copytrading/current-subpositions |
| getCopytradingSubpositionsHistory() | 🔐 | GET | /api/v5/copytrading/subpositions-history |
| submitCopytradingAlgoOrder() | 🔐 | POST | /api/v5/copytrading/algo-order |
| closeCopytradingSubposition() | 🔐 | POST | /api/v5/copytrading/close-subposition |
| getCopytradingInstruments() | 🔐 | GET | /api/v5/copytrading/instruments |
| setCopytradingInstruments() | 🔐 | POST | /api/v5/copytrading/set-instruments |
| getCopytradingProfitDetails() | 🔐 | GET | /api/v5/copytrading/profit-sharing-details |
| getCopytradingTotalProfit() | 🔐 | GET | /api/v5/copytrading/total-profit-sharing |
| getCopytradingUnrealizedProfit() | 🔐 | GET | /api/v5/copytrading/unrealized-profit-sharing-details |
| getCopytradingTotalUnrealizedProfit() | 🔐 | GET | /api/v5/copytrading/total-unrealized-profit-sharing |
| applyCopytradingLeadTrading() | 🔐 | POST | /api/v5/copytrading/apply-lead-trading |
| stopCopytradingLeadTrading() | 🔐 | POST | /api/v5/copytrading/stop-lead-trading |
| updateCopytradingProfitSharing() | 🔐 | POST | /api/v5/copytrading/amend-profit-sharing-ratio |
| getCopytradingAccount() | 🔐 | GET | /api/v5/copytrading/config |
| setCopytradingFirstCopy() | 🔐 | POST | /api/v5/copytrading/first-copy-settings |
| updateCopytradingCopySettings() | 🔐 | POST | /api/v5/copytrading/amend-copy-settings |
| stopCopytradingCopy() | 🔐 | POST | /api/v5/copytrading/stop-copy-trading |
| getCopytradingCopySettings() | 🔐 | GET | /api/v5/copytrading/copy-settings |
| getCopytradingBatchLeverageInfo() | 🔐 | GET | /api/v5/copytrading/batch-leverage-info |
| setCopytradingBatchLeverage() | 🔐 | POST | /api/v5/copytrading/batch-set-leverage |
| getCopytradingMyLeadTraders() | 🔐 | GET | /api/v5/copytrading/current-lead-traders |
| getCopytradingLeadTradersHistory() | 🔐 | GET | /api/v5/copytrading/lead-traders-history |
| getCopytradingConfig() | GET | /api/v5/copytrading/public-config | |
| getCopytradingLeadRanks() | GET | /api/v5/copytrading/public-lead-traders | |
| getCopytradingLeadWeeklyPnl() | GET | /api/v5/copytrading/public-weekly-pnl | |
| getCopytradingLeadDailyPnl() | GET | /api/v5/copytrading/public-pnl | |
| getCopytradingLeadStats() | GET | /api/v5/copytrading/public-stats | |
| getCopytradingLeadPreferences() | GET | /api/v5/copytrading/public-preference-currency | |
| getCopytradingLeadOpenPositions() | GET | /api/v5/copytrading/public-current-subpositions | |
| getCopytradingLeadPositionHistory() | GET | /api/v5/copytrading/public-subpositions-history | |
| getCopyTraders() | GET | /api/v5/copytrading/public-copy-traders | |
| getCopytradingLeadPrivateRanks() | 🔐 | GET | /api/v5/copytrading/lead-traders |
| getCopytradingLeadPrivateWeeklyPnl() | 🔐 | GET | /api/v5/copytrading/weekly-pnl |
| getCopytradingPLeadPrivateDailyPnl() | 🔐 | GET | /api/v5/copytrading/pnl |
| geCopytradingLeadPrivateStats() | 🔐 | GET | /api/v5/copytrading/stats |
| getCopytradingLeadPrivatePreferences() | 🔐 | GET | /api/v5/copytrading/preference-currency |
| getCopytradingLeadPrivateOpenPositions() | 🔐 | GET | /api/v5/copytrading/performance-current-subpositions |
| getCopytradingLeadPrivatePositionHistory() | 🔐 | GET | /api/v5/copytrading/performance-subpositions-history |
| getCopyTradersPrivate() | 🔐 | GET | /api/v5/copytrading/copy-traders |
| getTickers() | GET | /api/v5/market/tickers | |
| getTicker() | GET | /api/v5/market/ticker | |
| getOrderBook() | GET | /api/v5/market/books | |
| getRpiOrderBook() | GET | /api/v5/market/books-rpi | |
| getFullOrderBook() | GET | /api/v5/market/books-full | |
| getCandles() | GET | /api/v5/market/candles | |
| getHistoricCandles() | GET | /api/v5/market/history-candles | |
| getTrades() | GET | /api/v5/market/trades | |
| getHistoricTrades() | GET | /api/v5/market/history-trades | |
| getOptionTradesByInstrument() | GET | /api/v5/market/option/instrument-family-trades | |
| getOptionTrades() | GET | /api/v5/public/option-trades | |
| get24hrTotalVolume() | GET | /api/v5/market/platform-24-volume | |
| getBlockCounterParties() | 🔐 | GET | /api/v5/rfq/counterparties |
| createBlockRFQ() | 🔐 | POST | /api/v5/rfq/create-rfq |
| cancelBlockRFQ() | 🔐 | POST | /api/v5/rfq/cancel-rfq |
| cancelMultipleBlockRFQs() | 🔐 | POST | /api/v5/rfq/cancel-batch-rfqs |
| cancelAllRFQs() | 🔐 | POST | /api/v5/rfq/cancel-all-rfqs |
| executeBlockQuote() | 🔐 | POST | /api/v5/rfq/execute-quote |
| getQuoteProducts() | 🔐 | GET | /api/v5/rfq/maker-instrument-settings |
| updateBlockQuoteProducts() | 🔐 | POST | /api/v5/rfq/maker-instrument-settings |
| resetBlockMmp() | 🔐 | POST | /api/v5/rfq/mmp-reset |
| updateBlockMmpConfig() | 🔐 | POST | /api/v5/rfq/mmp-config |
| getBlockMmpConfig() | 🔐 | GET | /api/v5/rfq/mmp-config |
| createBlockQuote() | 🔐 | POST | /api/v5/rfq/create-quote |
| cancelBlockQuote() | 🔐 | POST | /api/v5/rfq/cancel-quote |
| cancelMultipleBlockQuotes() | 🔐 | POST | /api/v5/rfq/cancel-batch-quotes |
| cancelAllBlockQuotes() | 🔐 | POST | /api/v5/rfq/cancel-all-quotes |
| cancelAllBlockAfter() | 🔐 | POST | /api/v5/rfq/cancel-all-after |
| getBlockRFQs() | 🔐 | GET | /api/v5/rfq/rfqs |
| getBlockQuotes() | 🔐 | GET | /api/v5/rfq/quotes |
| getBlockTrades() | 🔐 | GET | /api/v5/rfq/trades |
| getPublicRFQBlockTrades() | GET | /api/v5/rfq/public-trades | |
| getBlockTickers() | GET | /api/v5/market/block-tickers | |
| getBlockTicker() | GET | /api/v5/market/block-ticker | |
| getBlockPublicTrades() | GET | /api/v5/public/block-trades | |
| submitSpreadOrder() | 🔐 | POST | /api/v5/sprd/order |
| cancelSpreadOrder() | 🔐 | POST | /api/v5/sprd/cancel-order |
| cancelAllSpreadOrders() | 🔐 | POST | /api/v5/sprd/mass-cancel |
| updateSpreadOrder() | 🔐 | POST | /api/v5/sprd/amend-order |
| getSpreadOrder() | 🔐 | GET | /api/v5/sprd/order |
| getSpreadActiveOrders() | 🔐 | GET | /api/v5/sprd/orders-pending |
| getSpreadOrdersRecent() | 🔐 | GET | /api/v5/sprd/orders-history |
| getSpreadOrdersArchive() | 🔐 | GET | /api/v5/sprd/orders-history-archive |
| getSpreadTrades() | 🔐 | GET | /api/v5/sprd/trades |
| getSpreads() | GET | /api/v5/sprd/spreads | |
| getSpreadOrderBook() | GET | /api/v5/sprd/books | |
| getSpreadTicker() | GET | /api/v5/market/sprd-ticker | |
| getSpreadPublicTrades() | GET | /api/v5/sprd/public-trades | |
| getSpreadCandles() | GET | /api/v5/market/sprd-candles | |
| getSpreadHistoryCandles() | GET | /api/v5/market/sprd-history-candles | |
| cancelSpreadAllAfter() | 🔐 | POST | /api/v5/sprd/cancel-all-after |
| getInstruments() | GET | /api/v5/public/instruments | |
| getEventContractSeries() | GET | /api/v5/public/event-contract/series | |
| getEventContractEvents() | GET | /api/v5/public/event-contract/events | |
| getEventContractMarkets() | GET | /api/v5/public/event-contract/markets | |
| getDeliveryExerciseHistory() | GET | /api/v5/public/delivery-exercise-history | |
| getOpenInterest() | GET | /api/v5/public/open-interest | |
| getFundingRate() | GET | /api/v5/public/funding-rate | |
| getFundingRateHistory() | GET | /api/v5/public/funding-rate-history | |
| getMinMaxLimitPrice() | GET | /api/v5/public/price-limit | |
| getOptionMarketData() | GET | /api/v5/public/opt-summary | |
| getEstimatedDeliveryExercisePrice() | GET | /api/v5/public/estimated-price | |
| getDiscountRateAndInterestFreeQuota() | GET | /api/v5/public/discount-rate-interest-free-quota | |
| getSystemTime() | GET | /api/v5/public/time | |
| getHistoricalMarketData() | GET | /api/v5/public/market-data-history | |
| getMarkPrice() | GET | /api/v5/public/mark-price | |
| getPositionTiers() | GET | /api/v5/public/position-tiers | |
| getInterestRateAndLoanQuota() | GET | /api/v5/public/interest-rate-loan-quota | |
| getVIPInterestRateAndLoanQuota() | GET | /api/v5/public/vip-interest-rate-loan-quota | |
| getUnderlying() | GET | /api/v5/public/underlying | |
| getInsuranceFund() | GET | /api/v5/public/insurance-fund | |
| getMmInstrumentTypes() | GET | /api/v5/public/mm-instrument-types | |
| getDeltaHedgeCurrencies() | GET | /api/v5/public/delta-hedge-currencies | |
| getUnitConvert() | GET | /api/v5/public/convert-contract-coin | |
| getOptionTickBands() | GET | /api/v5/public/instrument-tick-bands | |
| getPremiumHistory() | GET | /api/v5/public/premium-history | |
| getIndexTickers() | GET | /api/v5/market/index-tickers | |
| getIndexCandles() | GET | /api/v5/market/index-candles | |
| getHistoricIndexCandles() | GET | /api/v5/market/history-index-candles | |
| getMarkPriceCandles() | GET | /api/v5/market/mark-price-candles | |
| getHistoricMarkPriceCandles() | GET | /api/v5/market/history-mark-price-candles | |
| getOracle() | GET | /api/v5/market/open-oracle | |
| getExchangeRate() | GET | /api/v5/market/exchange-rate | |
| getIndexComponents() | GET | /api/v5/market/index-components | |
| getEconomicCalendar() | 🔐 | GET | /api/v5/public/economic-calendar |
| getPublicBlockTrades() | GET | /api/v5/market/block-trades | |
| getSupportCoin() | GET | /api/v5/rubik/stat/trading-data/support-coin | |
| getOpenInterestHistory() | GET | /api/v5/rubik/stat/contracts/open-interest-history | |
| getTakerVolume() | GET | /api/v5/rubik/stat/taker-volume | |
| getContractTakerVolume() | GET | /api/v5/rubik/stat/taker-volume-contract | |
| getMarginLendingRatio() | GET | /api/v5/rubik/stat/margin/loan-ratio | |
| getTopTradersAccountRatio() | GET | /api/v5/rubik/stat/contracts/long-short-account-ratio-contract-top-trader | |
| getTopTradersContractPositionRatio() | GET | /api/v5/rubik/stat/contracts/long-short-position-ratio-contract-top-trader | |
| getLongShortContractRatio() | GET | /api/v5/rubik/stat/contracts/long-short-account-ratio-contract | |
| getLongShortRatio() | GET | /api/v5/rubik/stat/contracts/long-short-account-ratio | |
| getContractsOpenInterestAndVolume() | GET | /api/v5/rubik/stat/contracts/open-interest-volume | |
| getOptionsOpenInterestAndVolume() | GET | /api/v5/rubik/stat/option/open-interest-volume | |
| getPutCallRatio() | GET | /api/v5/rubik/stat/option/open-interest-volume-ratio | |
| getOpenInterestAndVolumeExpiry() | GET | /api/v5/rubik/stat/option/open-interest-volume-expiry | |
| getOpenInterestAndVolumeStrike() | GET | /api/v5/rubik/stat/option/open-interest-volume-strike | |
| getTakerFlow() | GET | /api/v5/rubik/stat/option/taker-block-volume | |
| getCurrencies() | 🔐 | GET | /api/v5/asset/currencies |
| getBalances() | 🔐 | GET | /api/v5/asset/balances |
| getNonTradableAssets() | 🔐 | GET | /api/v5/asset/non-tradable-assets |
| getAccountAssetValuation() | 🔐 | GET | /api/v5/asset/asset-valuation |
| fundsTransfer() | 🔐 | POST | /api/v5/asset/transfer |
| getFundsTransferState() | 🔐 | GET | /api/v5/asset/transfer-state |
| getAssetBillsDetails() | 🔐 | GET | /api/v5/asset/bills |
| getAssetBillsHistoric() | 🔐 | GET | /api/v5/asset/bills-history |
| getLightningDeposits() | 🔐 | GET | /api/v5/asset/deposit-lightning |
| getDepositAddress() | 🔐 | GET | /api/v5/asset/deposit-address |
| getDepositHistory() | 🔐 | GET | /api/v5/asset/deposit-history |
| submitWithdraw() | 🔐 | POST | /api/v5/asset/withdrawal |
| submitWithdrawLightning() | 🔐 | POST | /api/v5/asset/withdrawal-lightning |
| cancelWithdrawal() | 🔐 | POST | /api/v5/asset/cancel-withdrawal |
| getWithdrawalHistory() | 🔐 | GET | /api/v5/asset/withdrawal-history |
| getDepositWithdrawStatus() | 🔐 | GET | /api/v5/asset/deposit-withdraw-status |
| getExchanges() | GET | /api/v5/asset/exchange-list | |
| applyForMonthlyStatement() | 🔐 | POST | /api/v5/asset/monthly-statement |
| getMonthlyStatement() | 🔐 | GET | /api/v5/asset/monthly-statement |
| getConvertCurrencies() | 🔐 | GET | /api/v5/asset/convert/currencies |
| getConvertCurrencyPair() | 🔐 | GET | /api/v5/asset/convert/currency-pair |
| estimateConvertQuote() | 🔐 | POST | /api/v5/asset/convert/estimate-quote |
| convertTrade() | 🔐 | POST | /api/v5/asset/convert/trade |
| getConvertHistory() | 🔐 | GET | /api/v5/asset/convert/history |
| getSubAccountList() | 🔐 | GET | /api/v5/users/subaccount/list |
| resetSubAccountAPIKey() | 🔐 | POST | /api/v5/users/subaccount/modify-apikey |
| getSubAccountBalances() | 🔐 | GET | /api/v5/account/subaccount/balances |
| getSubAccountFundingBalances() | 🔐 | GET | /api/v5/asset/subaccount/balances |
| getSubAccountMaxWithdrawal() | 🔐 | GET | /api/v5/account/subaccount/max-withdrawal |
| getSubAccountTransferHistory() | 🔐 | GET | /api/v5/asset/subaccount/bills |
| getManagedSubAccountTransferHistory() | 🔐 | GET | /api/v5/asset/subaccount/managed-subaccount-bills |
| transferSubAccountBalance() | 🔐 | POST | /api/v5/asset/subaccount/transfer |
| setSubAccountTransferOutPermission() | 🔐 | POST | /api/v5/users/subaccount/set-transfer-out |
| getSubAccountCustodyTradingList() | 🔐 | GET | /api/v5/users/entrust-subaccount-list |
| setSubAccountLoanAllocation() | 🔐 | POST | /api/v5/account/subaccount/set-loan-allocation |
| getSubAccountBorrowInterestAndLimit() | 🔐 | GET | /api/v5/account/subaccount/interest-limits |
| getStakingOffers() | 🔐 | GET | /api/v5/finance/staking-defi/offers |
| submitStake() | 🔐 | POST | /api/v5/finance/staking-defi/purchase |
| redeemStake() | 🔐 | POST | /api/v5/finance/staking-defi/redeem |
| cancelStakingRequest() | 🔐 | POST | /api/v5/finance/staking-defi/cancel |
| getActiveStakingOrders() | 🔐 | GET | /api/v5/finance/staking-defi/orders-active |
| getStakingOrderHistory() | 🔐 | GET | /api/v5/finance/staking-defi/orders-history |
| getETHStakingProductInfo() | GET | /api/v5/finance/staking-defi/eth/product-info | |
| getSOLStakingProductInfo() | GET | /api/v5/finance/staking-defi/sol/product-info | |
| purchaseETHStaking() | 🔐 | POST | /api/v5/finance/staking-defi/eth/purchase |
| redeemETHStaking() | 🔐 | POST | /api/v5/finance/staking-defi/eth/redeem |
| getETHStakingBalance() | 🔐 | GET | /api/v5/finance/staking-defi/eth/balance |
| getETHStakingHistory() | 🔐 | GET | /api/v5/finance/staking-defi/eth/purchase-redeem-history |
| cancelRedeemETHStaking() | 🔐 | POST | /api/v5/finance/staking-defi/eth/cancel-redeem |
| getAPYHistory() | GET | /api/v5/finance/staking-defi/eth/apy-history | |
| getSavingBalance() | 🔐 | GET | /api/v5/finance/savings/balance |
| savingsPurchaseRedemption() | 🔐 | POST | /api/v5/finance/savings/purchase-redempt |
| setLendingRate() | 🔐 | POST | /api/v5/finance/savings/set-lending-rate |
| getLendingHistory() | 🔐 | GET | /api/v5/finance/savings/lending-history |
| getPublicBorrowInfo() | GET | /api/v5/finance/savings/lending-rate-summary | |
| getPublicBorrowHistory() | GET | /api/v5/finance/savings/lending-rate-history | |
| getLendingOffers() | GET | /api/v5/finance/fixed-loan/lending-offers | |
| getLendingAPYHistory() | GET | /api/v5/finance/fixed-loan/lending-apy-history | |
| getLendingVolume() | GET | /api/v5/finance/fixed-loan/pending-lending-volume | |
| placeLendingOrder() | 🔐 | POST | /api/v5/finance/fixed-loan/lending-order |
| amendLendingOrder() | 🔐 | POST | /api/v5/finance/fixed-loan/amend-lending-order |
| getLendingOrders() | 🔐 | GET | /api/v5/finance/fixed-loan/lending-orders-list |
| getLendingSubOrders() | 🔐 | GET | /api/v5/finance/fixed-loan/lending-sub-orders |
| getBorrowableCurrencies() | GET | /api/v5/finance/flexible-loan/borrow-currencies | |
| getCollateralAssets() | GET | /api/v5/finance/flexible-loan/collateral-assets | |
| getMaxLoanAmount() | 🔐 | POST | /api/v5/finance/flexible-loan/max-loan |
| adjustCollateral() | 🔐 | POST | /api/v5/finance/flexible-loan/adjust-collateral |
| getLoanInfo() | 🔐 | GET | /api/v5/finance/flexible-loan/loan-info |
| getLoanHistory() | 🔐 | GET | /api/v5/finance/flexible-loan/loan-history |
| getAccruedInterest() | 🔐 | GET | /api/v5/finance/flexible-loan/interest-accrued |
| getDcdCurrencyPairs() | 🔐 | GET | /api/v5/finance/sfp/dcd/currency-pair |
| getDcdProducts() | 🔐 | GET | /api/v5/finance/sfp/dcd/products |
| requestDcdQuote() | 🔐 | POST | /api/v5/finance/sfp/dcd/quote |
| submitDcdTrade() | 🔐 | POST | /api/v5/finance/sfp/dcd/trade |
| requestDcdRedeemQuote() | 🔐 | POST | /api/v5/finance/sfp/dcd/redeem-quote |
| submitDcdRedeem() | 🔐 | POST | /api/v5/finance/sfp/dcd/redeem |
| getDcdOrderStatus() | 🔐 | GET | /api/v5/finance/sfp/dcd/order-status |
| getDcdOrderHistory() | 🔐 | GET | /api/v5/finance/sfp/dcd/order-history |
| getStableRewardsProductInfo() | 🔐 | GET | /api/v5/finance/stable-rewards/product-info |
| requestStableRewardsQuote() | 🔐 | POST | /api/v5/finance/stable-rewards/quote |
| submitStableRewardsTrade() | 🔐 | POST | /api/v5/finance/stable-rewards/trade |
| getStableRewardsBalance() | 🔐 | GET | /api/v5/finance/stable-rewards/balance |
| getStableRewardsApyHistory() | GET | /api/v5/finance/stable-rewards/apy-history | |
| getStableRewardsSubscribeRedeemHistory() | 🔐 | GET | /api/v5/finance/stable-rewards/subscribe-redeem-history |
| getOkusdLimits() | 🔐 | GET | /api/v5/finance/okusd/limits |
| subscribeOkusd() | 🔐 | POST | /api/v5/finance/okusd/subscribe |
| redeemOkusd() | 🔐 | POST | /api/v5/finance/okusd/redeem |
| getGlpTodayPerformance() | 🔐 | GET | /api/v5/users/glp/today-performance |
| getGlpHistoricalPerformance() | 🔐 | GET | /api/v5/users/glp/historical-performance |
| getAffiliatePerformanceSummary() | 🔐 | GET | /api/v5/affiliate/performance/summary |
| getInviteeDetail() | 🔐 | GET | /api/v5/affiliate/invitee/detail |
| getAffiliateInviteeList() | 🔐 | GET | /api/v5/affiliate/invitee/list |
| getAffiliateLinkList() | 🔐 | GET | /api/v5/affiliate/link/list |
| getAffiliateCoInviterLinkList() | 🔐 | GET | /api/v5/affiliate/co-inviter/list |
| getAffiliateSubAffiliateList() | 🔐 | GET | /api/v5/affiliate/sub-affiliate/list |
| getAffiliateRebateInfo() | 🔐 | GET | /api/v5/users/partner/if-rebate |
| getSystemStatus() | GET | /api/v5/system/status | |
| getAnnouncements() | GET | /api/v5/support/announcements | |
| getAnnouncementTypes() | GET | /api/v5/support/announcement-types | |
| createSubAccount() | 🔐 | POST | /api/v5/broker/nd/create-subaccount |
| deleteSubAccount() | 🔐 | POST | /api/v5/broker/nd/delete-subaccount |
| createSubAccountAPIKey() | 🔐 | POST | /api/v5/broker/nd/subaccount/apikey |
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 OKX API via a WebSocket connection.
| Function | AUTH | HTTP Method | Endpoint |
|---|---|---|---|
| submitNewOrder() | 🔐 | WS | order |
| submitMultipleOrders() | 🔐 | WS | batch-orders |
| cancelOrder() | 🔐 | WS | cancel-order |
| cancelMultipleOrders() | 🔐 | WS | batch-cancel-orders |
| amendOrder() | 🔐 | WS | amend-order |
| amendMultipleOrders() | 🔐 | WS | batch-amend-orders |
| massCancelOrders() | 🔐 | WS | mass-cancel |
| submitSpreadOrder() | 🔐 | WS | sprd-order |
| amendSpreadOrder() | 🔐 | WS | sprd-amend-order |
| cancelSpreadOrder() | 🔐 | WS | sprd-cancel-order |
| massCancelSpreadOrders() | 🔐 | WS | sprd-mass-cancel |
OKX JavaScript FAQ
What does the OKX JavaScript SDK cover?
OKX 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 OKX API calls in JavaScript?
The public REST example above needs no credentials. For private calls, follow the authentication setup for okx-api in the full tutorial, including the credentials or signer required by your exchange.
OKX authentication and setupDoes the OKX 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 OKX 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.