Skip to content

Bybit API SDK ​

bybit-api provides JavaScript and TypeScript clients for Bybit REST and WebSocket APIs, covering market data, account queries and trading.

Build trading bots and automate your Bybit strategies in Node.js, or use real-time market data in a dashboard. Start with a public price request, then add authentication and order handling for your trading workflow.

JavaScript & TypeScript · v4.8.4 · MIT license

Installation ​

TypeScript definitions are included.

sh
npm install bybit-api
sh
pnpm add bybit-api
sh
yarn add bybit-api

Choose your setup ​

Start with the tools you already use. Each guide includes a complete project, setup commands, expected output and cleanup where applicable.

  • Node.js / JavaScript: run plain JavaScript with import or require, without a TypeScript compiler.
  • Node.js / TypeScript: type-check and compile a Node.js price and subscription script.
  • React: display live prices in a React component with effect cleanup, using Vite.
  • Vite (plain JavaScript): display prices in a browser page without React.
  • Next.js: return a price from a Node.js server Route Handler.
  • React Native / Expo: display prices and stop subscriptions on iOS and Android.
  • Bun and Deno: run a price and WebSocket script in your chosen runtime.

Each guide includes a downloadable starter generated from the maintained examples and runtime configuration. Runtime compatibility records tested versions and scope.

Usage ​

This request reads the BTCUSDT Spot price and requires no API key.

js
import { RestClientV5 } from 'bybit-api';

async function main() {
  const client = new RestClientV5();
  const response = await client.getTickers({ category: 'spot', symbol: 'BTCUSDT' });
  if (response.retCode !== 0) {
    throw new Error(`Bybit ${response.retCode}: ${response.retMsg}`);
  }
  const ticker = response.result.list[0];
  if (!ticker) throw new Error('BTCUSDT was not present in the ticker response.');
  console.log('BTCUSDT last price:', ticker.lastPrice);
}
main().catch((error) => {
  console.error(error instanceof Error ? error.message : 'Request failed. See the troubleshooting guide.');
  process.exitCode = 1;
});

The example checks retCode and prints the first ticker's price. See the Node.js quickstart to run it.

Choose a client ​

ClientPurpose
RestClientV5Current V5 market data, account queries and trading endpoints over HTTP.
WebsocketClientPublic and private subscriptions through subscribeV5(), with update events.
WebsocketAPIClientSupported awaitable operations over the Bybit WebSocket API.

Next steps ​

For a longer walkthrough, see the Bybit JavaScript tutorial on Siebly.io.

Built by Siebly. Open source SDKs for exchange APIs.