Layer 0: Bitget API Connection
No authentication required for market data. All endpoints below are public.
REST API
Base URL
https://api.bitget.com
Endpoints Used
| Endpoint | Purpose | Rate Limit |
|---|---|---|
GET /api/v2/mix/market/tickers?productType=USDT-FUTURES |
Universe (all coins + 24h stats) | ~20 req/s |
GET /api/v2/mix/market/candles?symbol={SYM}&granularity={G}&limit={N}&productType=USDT-FUTURES |
Historical candles | ~20 req/s |
Response Format (Tickers)
{
"code": "00000",
"data": [
{
"symbol": "BTCUSDT",
"lastPr": "65000.5",
"high24h": "67000.0",
"low24h": "64000.0",
"quoteVolume": "1500000000",
"usdtVolume": "1500000000",
"openInterest": "500000000",
"fundingRate": "0.0001"
}
]
}
Response Format (Candles)
{
"code": "00000",
"data": [
[1714224000000, "64000", "65000", "63900", "64500", "1000", "64000000"],
// [timestamp, open, high, low, close, volume, quoteVolume]
]
}
WebSocket API
Connection URL
wss://ws.bitget.com/v2/ws/public
Subscription Message
{
"op": "subscribe",
"args": [
{
"instType": "USDT-FUTURES",
"channel": "candle5m",
"instId": "BTCUSDT"
}
]
}
Message Format (Push)
{
"action": "update",
"arg": {
"instType": "USDT-FUTURES",
"channel": "candle5m",
"instId": "BTCUSDT"
},
"data": [
[1714224000000, "64000", "65000", "63900", "64500", "1000", "64000000"]
]
}
Supported Channels
| Channel | Granularity |
|———|————-|
| candle5m | 5 minutes |
| candle15m | 15 minutes |
| candle30m | 30 minutes |
| candle1H | 1 hour |
| candle4H | 4 hours |
| candle1Dutc | 1 day (UTC) |
Subscription Limits
- Per connection: ~100 subscriptions recommended
- SKYNET strategy: 4 connections × 50 symbols = 200 symbols
- Ping required: Every 20 seconds to keep alive
Rate Limiting Strategy
Problem
Bitget returns 429 when you hit rate limits. Hitting 429s on 200 symbols = scanners stall.
Solution: Multi-Layer Defense
- WebSocket first — Subscribe to real-time candles. Zero REST calls for live data.
- Cache fallback — If WS stale, read from disk cache (no API call).
- REST last resort — Only call REST if cache is cold AND stale.
- Exponential backoff — On 429, wait 2s → 4s → 8s before retry.
- Rate limit between calls — 80ms sleep between REST calls in a loop.
Code Pattern (from candle_cache_service.mjs)
// Subscribe via WebSocket (preferred)
ws.send(JSON.stringify({
op: "subscribe",
args: symbols.map(s => ({
instType: "USDT-FUTURES",
channel: "candle5m",
instId: s
}))
}));
// REST fallback with backoff (from scanners)
async function bitgetGet(path, retries = 2) {
return fetchWithRetry(`https://api.bitget.com${path}`, retries);
}
No Authentication Required
All market data endpoints are public. You only need API keys for:
- Trading (placing orders)
- Account info
- Private WebSocket channels
SKYNET scanners only read market data, so no API keys needed.