Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/bybit-api/llms.txt

Use this file to discover all available pages before exploring further.

bybit-api is a professional Node.js, JavaScript, and TypeScript SDK for Bybit’s trading platform. It provides complete coverage of Bybit’s V5 REST APIs, public and private WebSocket streams, and the WebSocket API — all through a single npm package with a modern, promise-driven interface.

What bybit-api covers

The SDK wraps every surface of the Bybit API that a trading integration needs:
  • All V5 REST endpoints — market data, account management, order placement, positions, wallet, asset transfers, Earn, Broker, P2P, RFQ, spread trading, and more.
  • Public WebSocket streams — real-time order books, trades, klines, tickers, funding rates, and liquidations across Spot, Linear, Inverse, and Options markets.
  • Private WebSocket streams — live account events including orders, executions, positions, wallet changes, and greeks.
  • WebSocket API — submit, amend, and cancel orders over a persistent WebSocket connection, either with promise-driven methods or event-driven callbacks.

Client classes

The SDK ships four client classes. For new integrations, start with RestClientV5 for REST calls and WebsocketClient for streaming.
ClassDescription
RestClientV5Unified V5 all-in-one REST client. Covers every V5 REST endpoint including market data, trading, account, asset, and specialty APIs.
WebsocketClientManages all WebSocket connectivity — public market streams, private account streams, and raw WebSocket API commands via sendWSAPIRequest(...).
WebsocketAPIClientPromise-driven wrapper over WebsocketClient for the WebSocket API. Call methods like submitNewOrder(...) and await responses, similar to a REST API.
SpotClientV3Legacy Spot V3 REST client. Retained for backward compatibility. New integrations should use RestClientV5 instead.

Key benefits

All API requests made with this SDK are automatically subject to significantly higher rate limits — 400 requests per second, which is higher than the highest Bybit VIP tier. This is automatic for every API call, for every user, with no additional configuration required. Additionally, this SDK enables a lower minimum order notional value of 1(versusthestandard1 (versus the standard 5 minimum).
  • TypeScript-first — thorough type declarations for request parameters and API responses across REST and WebSocket APIs, including the WebSocket API.
  • Automatic HMAC & RSA authentication — pass your credentials once; the SDK signs every private request. RSA keys are auto-detected when the secret contains a PEM header.
  • Smart WebSocket persistence — automatic heartbeat monitoring, silent-disconnect detection, reconnection, and topic resubscription without any manual handling.
  • Multi-environment support — live, testnet, demo trading, and nine regional API domains (EU, NL, TK, KZ, HK, GE, UAE, bytick, default) are all configurable.
  • Proxy support — pass standard axios options for proxy and custom HTTP agent configuration.
  • JavaScript compatible — TypeScript is not required. The published npm package is a compiled JavaScript module with bundled type declarations.

Exported constants and utilities

The package also exports several constants and utilities that are useful for advanced integrations:
  • WS_KEY_MAP — a constant map of every WebSocket connection key (v5SpotPublic, v5LinearPublic, v5InversePublic, v5OptionPublic, v5Private, v5PrivateTrade). Use these values to identify which connection an event came from when handling WebSocket events.
  • API_ERROR_CODE — a constant map of Bybit API error codes and their meanings. Useful for catching and branching on specific API-level errors in your error-handling logic.
  • DefaultLogger — the default logger object used internally by the SDK. Spread or extend it to add custom log handling (for example, enabling trace-level output) without replacing the full logger.
  • WS_AUTH_ON_CONNECT_KEYS — the list of WebSocket keys that require authentication on connect (private and trade channels).

Installation

Install bybit-api from npm using your preferred package manager:
npm install bybit-api

Minimal example

The following snippet shows the complete setup for making both public and private REST API calls. No extra configuration is needed beyond providing your API credentials.
import { RestClientV5 } from 'bybit-api';

// Public client — no credentials needed for market data
const publicClient = new RestClientV5();

publicClient
  .getOrderbook({ category: 'linear', symbol: 'BTCUSDT' })
  .then((result) => {
    console.log('Orderbook:', result);
  });

// Authenticated client — credentials auto-sign every private request
const privateClient = new RestClientV5({
  key: process.env.BYBIT_API_KEY,
  secret: process.env.BYBIT_API_SECRET,
});

privateClient
  .getAccountInfo()
  .then((result) => {
    console.log('Account info:', result);
  })
  .catch((err) => {
    console.error('Error:', err);
  });

Explore the documentation

Quickstart

Install the SDK, set up API keys, and make your first REST and WebSocket calls in under five minutes.

Authentication

Configure HMAC or RSA authentication and learn how the SDK auto-signs every private request.

REST API

Full reference for all RestClientV5 methods — market data, orders, positions, wallet, and more.

WebSockets

Subscribe to real-time streams and send WebSocket API commands with automatic reconnection.

Build docs developers (and LLMs) love