Bot Integration with Bitget API

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1 servicesAll 1306 services
Bot Integration with Bitget API
Simple
~2-3 business days
FAQ
Blockchain Development Services
Blockchain Development Stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1214
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823

Bitget API Bot Integration

Bitget provides REST and WebSocket APIs for spot, futures, and copy-trading. Key feature: active focus on copy trading — they have a special API for trader profiles and follower management.

Bitget Authentication

Bitget uses HMAC-SHA256 with timestamp + method + path + body:

import hmac
import hashlib
import base64
import time
import json
import httpx

class BitgetClient:
    BASE_URL = "https://api.bitget.com"

    def __init__(self, api_key: str, secret_key: str, passphrase: str):
        self.api_key = api_key
        self.secret_key = secret_key
        self.passphrase = passphrase  # Bitget requires passphrase unlike Bybit

    def _sign(self, timestamp: str, method: str, path: str, body: str = "") -> str:
        prehash = timestamp + method.upper() + path + body
        signature = hmac.new(
            self.secret_key.encode('utf-8'),
            prehash.encode('utf-8'),
            hashlib.sha256
        ).digest()
        return base64.b64encode(signature).decode()

    def _get_headers(self, method: str, path: str, body: str = "") -> dict:
        timestamp = str(int(time.time() * 1000))
        return {
            "ACCESS-KEY": self.api_key,
            "ACCESS-SIGN": self._sign(timestamp, method, path, body),
            "ACCESS-TIMESTAMP": timestamp,
            "ACCESS-PASSPHRASE": self.passphrase,
            "Content-Type": "application/json",
            "locale": "en-US"
        }

Basic Trading Operations

async def place_spot_order(
    self,
    symbol: str,      # 'BTCUSDT_SPBL'
    side: str,        # 'buy' or 'sell'
    order_type: str,  # 'limit' or 'market'
    size: str,        # quantity
    price: str = None
) -> dict:
    path = "/api/spot/v1/trade/orders"
    payload = {
        "symbol": symbol,
        "side": side,
        "orderType": order_type,
        "force": "normal",  # GTC
        "size": size
    }
    if price:
        payload["price"] = price

    body = json.dumps(payload)
    headers = self._get_headers("POST", path, body)

    async with httpx.AsyncClient() as client:
        response = await client.post(
            f"{self.BASE_URL}{path}",
            content=body,
            headers=headers
        )
    return response.json()

async def get_account_info(self) -> dict:
    path = "/api/spot/v1/account/assets"
    headers = self._get_headers("GET", path)

    async with httpx.AsyncClient() as client:
        response = await client.get(
            f"{self.BASE_URL}{path}",
            headers=headers
        )
    return response.json()

Futures API (Mix)

Bitget calls the futures API "Mix". For USDT-M perpetuals:

async def place_futures_order(
    self,
    symbol: str,      # 'BTCUSDT_UMCBL'
    side: str,        # 'open_long', 'open_short', 'close_long', 'close_short'
    order_type: str,  # 'limit' or 'market'
    size: str,        # number of contracts
    price: str = None,
    margin_mode: str = 'crossed'  # 'crossed' or 'fixed'
) -> dict:
    path = "/api/mix/v1/order/placeOrder"
    payload = {
        "symbol": symbol,
        "marginCoin": "USDT",
        "size": size,
        "side": side,
        "orderType": order_type,
        "marginMode": margin_mode
    }
    if price:
        payload["price"] = price

    body = json.dumps(payload)
    headers = self._get_headers("POST", path, body)

    async with httpx.AsyncClient() as client:
        response = await client.post(f"{self.BASE_URL}{path}", content=body, headers=headers)
    return response.json()

WebSocket Subscriptions

class BitgetWebSocket:
    WS_URL = "wss://ws.bitget.com/spot/v1/stream"

    async def subscribe_ticker(self, symbols: list[str]):
        async with websockets.connect(self.WS_URL) as ws:
            sub_args = [{"instType": "sp", "channel": "ticker", "instId": s} for s in symbols]
            await ws.send(json.dumps({"op": "subscribe", "args": sub_args}))

            # Keepalive ping every 30 seconds
            async def ping():
                while True:
                    await asyncio.sleep(30)
                    await ws.send("ping")

            asyncio.create_task(ping())

            async for message in ws:
                if message == "pong":
                    continue
                data = json.loads(message)
                if "data" in data:
                    await self.on_ticker(data)

Symbols and Formats

Bitget uses non-standard symbol formats:

Type Format Example
Spot {BASE}{QUOTE}_SPBL BTCUSDT_SPBL
USDT-M Futures {BASE}{QUOTE}_UMCBL BTCUSDT_UMCBL
Inverse Futures {BASE}USD_DMCBL BTCUSD_DMCBL

This feature is the first thing you encounter during integration. Bitget sandbox is available at https://api-sandbox.bitget.com — identical production API with test funds.

Documentation: bitget.com/api-doc. Official Python SDK: pip install pybitget. For production, we recommend the official SDK as a wrapper — it already handles signature and basic retry logic.