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 { MainClient } from 'binance';

async function main() {
  const client = new MainClient();
  const result = await client.getSymbolPriceTicker({ symbol: 'BTCUSDT' });
  if (Array.isArray(result)) throw new Error('Expected a single-symbol ticker.');
  console.log('BTCUSDT last price:', result.price);
}
main().catch((error) => {
  console.error(error instanceof Error ? error.message : 'Request failed. See the troubleshooting guide.');
  process.exitCode = 1;
});

getSymbolPriceTicker() returns one ticker or an array, with prices as strings. The example handles both response shapes.

Read an order book ​

ts
import { MainClient } from 'binance';

async function main() {
  const client = new MainClient();
  const book = await client.getOrderBook({ symbol: 'BTCUSDT', limit: 5 });
  console.log('Best bid [price, quantity]:', book.bids[0]);
  console.log('Best ask [price, quantity]:', book.asks[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, combine this snapshot with WebSocket depth updates using Binance's update-ID rules.

Choose the correct instrument ​

Query exchange information for the selected product and environment to get current symbols and trading filters.

API reference · Exchange documentation

Built by Siebly. Open source SDKs for exchange APIs.