TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/bybit-api/llms.txt
Use this file to discover all available pages before exploring further.
bybit-api SDK supports three distinct trading environments — live, testnet, and demo trading — as well as a set of regional domain options for users subject to local regulatory requirements or who want lower-latency routing. Switching between them is a single constructor option change; no other code modifications are required.
Overview of Environments
| Environment | Config Option | Base URL | Credentials |
|---|---|---|---|
| Live (default) | (none) | api.bybit.com | Live API key & secret |
| Testnet | testnet: true | api-testnet.bybit.com | Separate testnet credentials |
| Demo Trading | demoTrading: true | api.bybit.com (demo header) | Live API key & secret |
Testnet and demo trading serve different purposes. Testnet has entirely different market data that does not reflect real conditions. Demo trading uses live market prices and order books — it is the recommended environment for strategy testing and simulation.
Live Environment
The live environment is the default. No additional configuration is required beyond providing your API credentials.Testnet
Settestnet: true to direct all requests to Bybit’s testnet environment. Testnet credentials are entirely separate from live credentials and must be created at testnet.bybit.com.
Testnet market data, order books, and liquidity are synthetic and unrelated to live conditions. If you are testing a trading strategy, use demo trading instead — it reflects real prices and real market microstructure.
Demo Trading
Demo trading uses your live API credentials but routes requests to Bybit’s demo environment, where all P&L is simulated. This is the recommended environment for strategy validation before going live.WebSocket API (order placement via WebSocket) is not supported in demo trading as of January 2025. Use the REST client for order placement in demo mode, and use the
WebsocketClient only for market data and account event streams.Full Demo Trading Example
The following shows REST and WebSocket working together in demo mode, including subscribing to private account topics:Regional Domains
Bybit operates regional domains for users in specific countries or regulatory jurisdictions. Use theapiRegion option on RestClientV5 to route REST API calls to the appropriate domain. All regional domains serve the same V5 API.
The
apiRegion option applies to RestClientV5 only. For WebsocketClient, use the wsUrl option to override the WebSocket endpoint when a regional endpoint is required.Supported Regions
apiRegion value | REST Base URL | Description |
|---|---|---|
'default' or omitted | https://api.bybit.com | Global default |
'bytick' | https://api.bytick.com | Alternative global domain |
'EU' | https://api.bybit.eu | Bybit EU (European regulatory domain) |
'NL' | https://api.bybit.nl | Netherlands |
'TK' | https://api.bybit-tr.com | Turkey |
'KZ' | https://api.bybit.kz | Kazakhstan |
'HK' | https://api.byhkbit.com | Hong Kong |
'GE' | https://api.bybitgeorgia.ge | Georgia |
'UAE' | https://api.bybit.ae | United Arab Emirates |
Regional Client Example
Custom Base URL
If your target domain is not yet in theapiRegion list, use baseUrl to fully override the REST endpoint:
baseUrl takes precedence over apiRegion when both are set. Please also open a GitHub issue if you need a new region added to the built-in apiRegion map.
Configuration
Full reference for all RestClientV5 and WebsocketClient options
Error Handling
Handle API errors and interpret response codes