Skip to content

Testnet and demo trading ​

Available environments ​

  • Testnet: a separate testing service with its own account and credentials.
  • Demo trading: a demo account created from your mainnet account, with simulated orders and production public market data.

These are different services. Do not create a demo account on Testnet for the configuration below. Production is the default when both flags are false or omitted.

Testnet ​

Create credentials in Bybit Testnet API management. Set testnet: true and demoTrading: false on each RestClientV5, WebsocketClient or supported WebsocketAPIClient you use. Pass Testnet credentials through key and secret.

Demo trading ​

Switch your mainnet account to Demo Trading and create an API key there. Set demoTrading: true and testnet: false on each REST and subscription client, with that demo key and secret:

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

function requiredEnv(name: string): string {
  const value = process.env[name];
  if (!value) throw new Error(`Set ${name} in your server environment.`);
  return value;
}

// Configure clients only. No requests, subscriptions or orders are sent.
const options = {
  key: requiredEnv('BYBIT_DEMO_API_KEY'),
  secret: requiredEnv('BYBIT_DEMO_API_SECRET'),
  testnet: false,
  demoTrading: true,
};

export const rest = new RestClientV5(options);
export const ws = new WebsocketClient(options);

This example only constructs clients; it does not send requests or place orders. Keep credentials in server-side environment variables and exclude .env files from version control.

Coverage and limitations ​

Demo REST and private subscriptions use demo endpoints; public subscriptions use mainnet market data. Only the endpoints listed in Bybit's demo documentation are available. Demo trading does not support the WebSocket Trade API: use REST for supported demo order commands, not WebsocketAPIClient.

Do not enable testnet and demoTrading together. In this SDK, that combination can select demo for REST/private streams but Testnet for public streams. Check Bybit's integration guide for current environment and key requirements.

What these environments can prove ​

Use test environments to check request formats, credentials, order handling and reconnect recovery within the features they support. Testnet liquidity, prices, fills, fees and availability can differ substantially from production. Accounts, balances and order history may also be reset.

Testnet is not a reliable place to evaluate strategy performance. Demo trading may use production market data, but simulated fills do not establish live profitability, slippage, execution quality or capacity. Treat both as integration tests, not evidence that a strategy will succeed with real funds. See the CEX testnet overview for the distinction between testnet and demo trading.

Before switching environments ​

  • Keep credentials and configuration separate for each account, product and environment. Never fall back to live credentials when a test key is missing.
  • Configure every REST, subscription and WebSocket API client separately. Changing one client does not reconfigure another.
  • Check the selected environment's supported endpoints and instruments before sending a request. Similar method signatures do not imply identical availability.
  • Keep authenticated requests on your server. Confirm the destination and account before enabling any write operation.

Production remains the default. Selecting a test environment is an explicit choice for each client; it is not a global SDK setting.

Configuration · Authentication · Production usage

Built by Siebly. Open source SDKs for exchange APIs.