---
title: "Binance REST Spot Demo JavaScript SDK Example | Siebly"
description: "Binance REST spot demo JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/Binance/Rest/Spot/rest-spot-demo"
robots: "index,follow"
---

# Binance REST Spot Demo JavaScript SDK Example

Binance REST spot demo JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [Binance](/examples/Binance) / [Rest](/examples/Binance/Rest) / [Spot](/examples/Binance/Rest/Spot) / [rest-spot-demo.ts](/examples/Binance/Rest/Spot/rest-spot-demo)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Binance/Rest/Spot/rest-spot-demo.ts)

[Open the Binance JavaScript SDK guide](/sdk/binance/javascript)

## rest-spot-demo.ts

```typescript
import { MainClient } from 'binance';

const key = process.env.API_KEY_COM || 'APIKEY';
const secret = process.env.API_SECRET_COM || 'APISECRET';

const client = new MainClient({
  api_secret: secret,
  api_key: key,
  beautifyResponses: true,
  /**
   * Demo trading uses real market data with simulated trading.
   * Perfect for testing strategies without risk.
   */
  demoTrading: true,
});

async function start() {
  try {
    // Get account information on demo trading
    const accountInfo = await client.getAccountInformation();
    console.log('Demo account info: ', accountInfo);

    // Place a test order on demo trading
    const result = await client.submitNewOrder({
      side: 'BUY',
      symbol: 'BTCUSDT',
      type: 'MARKET',
      quantity: 0.001,
    });

    console.log('Demo market buy result: ', result);
  } catch (e) {
    console.error('Demo trading request failed: ', e);
  }
}

start();
```
