Use this file to discover all available pages before exploring further.
Bitget provides a simulated demo trading environment that lets you test strategies, verify order logic, and validate integrations without risking real funds. The bitget-api SDK supports demo trading natively — pass a single demoTrading: true flag when constructing any client and all REST requests and WebSocket connections are automatically routed to Bitget’s demo endpoints. Because demo trading mirrors the live API surface exactly, every SDK method, subscription topic, and response shape works identically in both environments.
Demo trading uses completely separate API keys from live trading. Never share credentials between the two environments — a live API key will not authenticate against demo endpoints, and vice versa.
Log in to your Bitget account and navigate to the demo trading dashboard to generate a dedicated set of API credentials (key, secret, and passphrase). Store them in environment variables separate from your live keys — for example, DEMO_API_KEY, DEMO_API_SECRET, and DEMO_API_PASS.
2
Enable demo mode on a REST client
Pass demoTrading: true to RestClientV3 or RestClientV2. This flag is part of RestClientOptions and routes all HTTP requests to Bitget’s demo REST base URL:
import { RestClientV3 } from 'bitget-api';const client = new RestClientV3({ apiKey: process.env.DEMO_API_KEY, apiSecret: process.env.DEMO_API_SECRET, apiPass: process.env.DEMO_API_PASS, demoTrading: true,});// All calls now hit the demo trading environmentconst account = await client.getFuturesAccountAssets({ productType: 'USDT-FUTURES',});console.log('Demo account assets:', account);
3
Enable demo mode on a WebSocket client
Pass demoTrading: true to WebsocketClientV3 or WebsocketClientV2. All WebSocket connections, including private authenticated channels, are routed to the demo WebSocket URLs:
demoTrading is a field on the RestClientOptions interface and is supported by all five client classes in the SDK:
Client class
Import
RestClientV3
import { RestClientV3 } from 'bitget-api'
RestClientV2
import { RestClientV2 } from 'bitget-api'
WebsocketClientV3
import { WebsocketClientV3 } from 'bitget-api'
WebsocketClientV2
import { WebsocketClientV2 } from 'bitget-api'
WebsocketAPIClient
import { WebsocketAPIClient } from 'bitget-api'
When demoTrading: true is set on a REST client, it overrides the base URL to point to Bitget’s demo REST API. When set on a WebSocket client, all WebSocket connections (both public and private) connect to the demo WebSocket endpoints.
Demo trading mirrors the live API surface completely — all endpoints, parameters, response shapes, and WebSocket topics are identical. Any code that works in demo will work in production once you swap in live credentials and remove the demoTrading flag.
Always develop and validate your full strategy in demo trading before switching to live credentials. This includes order placement, cancellation, position management, WebSocket subscription handling, and error recovery paths.