Bybit Testnet Setup Guide - 2025
Important Notes
⚠️ DO NOT deposit real funds to testnet - Any real money deposited to testnet will be permanently lost
⚠️ Testnet ≠ Mainnet - They are completely separate environments
✅ Testnet funds have no real value - You can test risk-free indefinitely
STEP 1: Register Testnet Account
- Open testnet in your browser: https://testnet.bybit.com
- Click "Sign Up" in the top right corner
- Choose registration method:
- Email address (recommended for bot automation)
- Phone number
- Enter your email/phone and create a password
- Complete 2FA security verification - enter the code sent to your email/SMS (expires in 5 minutes)
- ✅ Account created! You now have a testnet account separate from mainnet
STEP 2: Request Test Coins (Free Virtual Funds)
Once logged in to testnet:
- Click "Assets" in the top navigation
- Click "Assets Overview"
- Click "Request Test Coins" button
- Confirm the request in the popup
- ✅ You'll receive:
- 50,000 USDT (stablecoin)
- 50,000 USDC
- 1 BTC (Bitcoin)
- 1 ETH (Ethereum)
Can request once every 24 hours - Funds will replenish if equity drops below 10,000 USDT
STEP 3: Create API Key for Bot Integration
Access API Management
- Go to: https://testnet.bybit.com/app/user/api-management
- OR click your account icon (top right) → API
- Click "Create New Key" on the right side
In the popup, set the following permissions:
Required for Scalping Bot:
- ✅ Account Transfer - to check balance
- ✅ Order - to place/cancel orders (Place order, Cancel order, Modify order)
- ✅ Position - to monitor positions
- ✅ Market - read-only market data
Optional (for advanced features):
- ☐ Wallet - if you need deposit/withdrawal tracking
IP Whitelist (Security)
- Option 1: Add your server IP (recommended for production)
- Option 2: Leave empty for testing (⚠️ less secure)
- For local development: Use your current public IP (find it at https://ifconfig.me)
Complete Setup
- Enter your Google Authenticator 2FA code
- Click "Submit"
- Copy and save:
- API Key
- API Secret
- ⚠️ Store these securely - never share them
Option A: Using Environment Variables (Recommended)
# Linux/Mac
export BYBIT_TESTNET_API_KEY="your_api_key_here"
export BYBIT_TESTNET_API_SECRET="your_api_secret_here"
# Windows (Command Prompt)
set BYBIT_TESTNET_API_KEY=your_api_key_here
set BYBIT_TESTNET_API_SECRET=your_api_secret_here
# Windows (PowerShell)
$env:BYBIT_TESTNET_API_KEY="your_api_key_here"
$env:BYBIT_TESTNET_API_SECRET="your_api_secret_here"
Option B: Using application.yml
# application-testnet.yml
spring:
application:
name: scalping-bot
trading:
environment: testnet
apiKey: ${BYBIT_TESTNET_API_KEY}
apiSecret: ${BYBIT_TESTNET_API_SECRET}
baseUrl: https://api-testnet.bybit.com
wsUrl: wss://stream-testnet.bybit.com
# Risk settings - can be aggressive in testnet
maxConcurrentTrades: 10
maxLossPerSession: 500.0 # $500 virtual loss limit
volatilityThreshold: 0.10 # 10% volatility emergency stop
useMockApi: false
useTestnet: true
Option C: Using Properties File
# application-testnet.properties
trading.environment=testnet
trading.apiKey=${BYBIT_TESTNET_API_KEY}
trading.apiSecret=${BYBIT_TESTNET_API_SECRET}
trading.baseUrl=https://api-testnet.bybit.com
trading.wsUrl=wss://stream-testnet.bybit.com
trading.maxConcurrentTrades=10
trading.maxLossPerSession=500.0
trading.useTestnet=true
trading.useMockApi=false
STEP 5: Run Your Bot on Testnet
Start with correct Spring Profile
# Using Maven
mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=testnet"
# Using Java directly
java -jar scalping-bot.jar --spring.profiles.active=testnet
# Using Gradle
gradle bootRun --args='--spring.profiles.active=testnet'
Verify Connection
Your application logs should show:
[INFO] Environment set to: testnet
[INFO] Testnet client initialized
[INFO] Connecting to: https://api-testnet.bybit.com
[INFO] WebSocket connection to testnet established
[INFO] Account balance: 50000.00 USDT, 1.00 BTC
STEP 6: Test Your Bot
Testing Workflow
-
Place test orders (small amounts)
POST /api/bot/place-order?symbol=BTCUSDT&quantity=0.001&price=43000
-
Monitor order status
GET /api/bot/status
-
Check market data
GET /api/bot/market/BTCUSDT
-
View analytics & PnL
GET /api/bot/analytics
Common Test Scenarios
✅ Test order placement with various symbols:
- BTCUSDT (Bitcoin)
- ETHUSDT (Ethereum)
- SOLUSDT (Solana)
- XRPUSDT (Ripple)
✅ Test order cancellation
✅ Test risk management triggers
✅ Test crash recovery (kill app, restart, check recovered trades)
✅ Test extreme volatility emergency stop
✅ Test API connection failures (simulate with mock failures)
STEP 7: Monitor Your Bot
Real-time Dashboard
Watch your bot trading on testnet dashboard: https://testnet.bybit.com
Check Order History
- Navigate to Trading tab
- View Open Orders and Order History
- Verify bot-placed orders appear here
API Response Monitoring
View logs from your Java bot:
2025-11-26 14:32:15 [INFO] Market data - BTCUSDT: price=43250.50, volume=1000.0
2025-11-26 14:32:16 [INFO] Order placed: abc-123 - Symbol: BTCUSDT, Qty: 0.001, Price: 43000
2025-11-26 14:32:17 [INFO] Order cancelled: abc-123
2025-11-26 14:32:18 [INFO] Session loss updated: -10.50
STEP 8: Transition to Production (When Ready)
Before Going Live
⚠️ Checklist:
Switch to Mainnet
- Create API keys on mainnet: https://www.bybit.com/app/user/api-management
- Change Spring profile to
production
- Update environment variables:
export BYBIT_MAINNET_API_KEY="your_mainnet_key"
export BYBIT_MAINNET_API_SECRET="your_mainnet_secret"
- Start with minimal position sizes ($50-100 first trades)
API Endpoints Reference
Testnet URLs
REST API: https://api-testnet.bybit.com
WebSocket: wss://stream-testnet.bybit.com
Web Dashboard: https://testnet.bybit.com
Mainnet URLs (Production)
REST API: https://api.bybit.com
WebSocket: wss://stream.bybit.com
Web Dashboard: https://www.bybit.com
Troubleshooting
Issue: "API key not found"
- Wait 48 hours after account creation (new user restriction)
- Check API key has correct permissions
- Verify IP whitelist (if configured)
Issue: "Invalid API key signature"
- Verify API secret is copied correctly
- Check server time sync (must be within 5 seconds of Bybit server)
- Ensure you're using HMAC SHA256 signature
Issue: "No test coins received"
- Refresh the page (might take 1-2 seconds)
- Clear browser cache
- Try requesting again (24-hour cooldown)
Issue: "Connection refused"
- Verify you're using testnet URLs (not mainnet)
- Check firewall/VPN isn't blocking WebSocket
- Confirm internet connection
Issue: "Insufficient balance"
- Request more test coins (available every 24 hours)
- Reduce position size
- Verify you're using USDT pairs (not other assets)
Best Practices for Testnet Trading
- Test all edge cases - Push your bot to extremes
- Use small sizes - Verify logic before larger trades
- Run 24/7 if possible - Test overnight behavior
- Test network failures - Disconnect internet, resume connection
- Document trades - Note what worked, what didn't
- Keep logs - Archive for historical analysis
- Never automate production - Requires explicit confirmation
- Reset regularly - Request new test coins to keep balance high
Security Notes
🔐 Testnet API Key Security:
- Testnet funds are worthless, so it's less critical than mainnet
- Still practice good security habits (not in version control)
- Still enable IP whitelist if possible
🔐 Before Mainnet:
- Use encrypted credential storage (JCE Keystore recommended)
- Implement rate limiting on your bot
- Add monitoring/alerts for suspicious activity
- Test with read-only API key first
- Use IP whitelist on all API keys
Next Steps
- ✅ Register testnet account (Step 1)
- ✅ Request test coins (Step 2)
- ✅ Create API key (Step 3)
- ✅ Configure bot (Step 4)
- ✅ Run bot (Step 5)
- ✅ Test scenarios (Step 6)
- ✅ Monitor & iterate (Step 7)
- ⏱️ Go live when confident (Step 8)
Good luck with your scalping bot! 🚀