Bybit JavaScript SDK
Build with the Bybit REST API & WebSockets with our JavaScript SDK, TypeScript-first package declarations, and Node.js-compatible runtime patterns. Discover installation, common examples, a detailed endpoint-to-function map, and the REST API/WebSocket patterns shared across our Siebly SDK family.
Use the same TypeScript-first REST API and WebSocket clients from plain JavaScript or TypeScript in Node.js-compatible runtimes.
Package surfaces
Explore the following API capabilities are covered by our Bybit SDK:
- Spot
- Futures
- Options
- WebSockets
- WebSocket API
- WebSocket clients with:
- Built-in heartbeats.
- Automatic reconnection.
- Automatic reauthentication and resubscribe where the exchange supports it.
- Promise-wrapped WebSocket API commands you can await like a REST API.
- Typed requests and responses for Node.js, JavaScript, and TypeScript IDEs.
- Framework-neutral JavaScript snippets that stay approachable in Node.js-compatible runtimes.
- TypeScript-first package declarations for stricter services, shared libraries, and editor-assisted integrations.
Install Bybit SDK
# Via your favourite package manager, e.g. npm:
npm install bybit-api
# or pnpm:
pnpm install bybit-api
# or yarn:
yarn add bybit-apiQuickstart Examples with the Bybit JavaScript SDK
Get started with just a few lines of JavaScript. TypeScript, while not required, is absolutely recommended. TypeScript declarations are included with all our SDKs and provide convenient definitions on request & response fields, WebSocket payloads, and generally safer integrations.
Quickstart snippets are currently unavailable for this SDK and language combination.
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, WebSocket streams 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
Bybit JavaScript FAQ
What does the Bybit JavaScript SDK cover?
Bybit supports Spot, Futures, 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?
Install bybit-api from npm & pass API credentials into the SDK client options, as shown in the Bybit JavaScript examples above. The SDK handles the exchange-specific signing requirements for private requests.
Does 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.