Skip to content

Market data ​

Public prices and order books do not require API keys. These examples use BTCUSDT in the Spot market.

Read a ticker ​

ts
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;
});

Check retCode === 0 before reading result.list. Set category to select the market; BTCUSDT can exist in both Spot and derivatives.

Read an order book ​

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

async function main() {
  const client = new RestClientV5();
  const response = await client.getOrderbook({ category: 'spot', symbol: 'BTCUSDT', limit: 5 });
  if (response.retCode !== 0) throw new Error(`Bybit ${response.retCode}: ${response.retMsg}`);
  console.log('Best bid [price, size]:', response.result.b[0]);
  console.log('Best ask [price, size]:', response.result.a[0]);
}
main().catch((error) => {
  console.error(error instanceof Error ? error.message : 'Request failed. See the troubleshooting guide.');
  process.exitCode = 1;
});

Each bid and ask contains a price and quantity as decimal strings. The example returns undefined for an empty side.

For a live order book, use WebSocket updates and apply Bybit's snapshot and delta rules.

Choose the correct instrument ​

Query instrument information for the selected category and environment to get current symbols and trading filters.

API reference · Exchange documentation

Built by Siebly. Open source SDKs for exchange APIs.