Skip to the content.

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


Rate Limiting Strategy

Problem

Bitget returns 429 when you hit rate limits. Hitting 429s on 200 symbols = scanners stall.

Solution: Multi-Layer Defense

  1. WebSocket first — Subscribe to real-time candles. Zero REST calls for live data.
  2. Cache fallback — If WS stale, read from disk cache (no API call).
  3. REST last resort — Only call REST if cache is cold AND stale.
  4. Exponential backoff — On 429, wait 2s → 4s → 8s before retry.
  5. 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:

SKYNET scanners only read market data, so no API keys needed.