bitget_rs
Bitget V2 Futures SDK crate used by crypto_exc_all.
Current coverage:
- Public common/notice:
GET /api/v2/public/timeGET /api/v2/public/annoucements
- Futures market:
GET /api/v2/mix/market/tickerGET /api/v2/mix/market/tickersGET /api/v2/mix/market/contractsGET /api/v2/mix/market/orderbookGET /api/v2/mix/market/merge-depthGET /api/v2/mix/market/candlesGET /api/v2/mix/market/history-candlesGET /api/v2/mix/market/symbol-priceGET /api/v2/mix/market/current-fund-rateGET /api/v2/mix/market/history-fund-rateGET /api/v2/mix/market/open-interestGET /api/v2/mix/market/oi-limitGET /api/v2/mix/market/query-position-leverGET /api/v2/mix/market/vip-fee-rateGET /api/v2/mix/market/long-shortGET /api/v2/mix/market/account-long-shortGET /api/v2/mix/market/taker-buy-sellGET /api/v2/mix/market/exchange-rate
- Futures account/position:
GET /api/v2/mix/account/accountsGET /api/v2/mix/account/accountGET /api/v2/mix/account/billGET /api/v2/mix/account/sub-account-assetsGET /api/v2/mix/position/all-positionGET /api/v2/mix/position/history-positionPOST /api/v2/mix/account/set-leveragePOST /api/v2/mix/account/set-margin-modePOST /api/v2/mix/account/set-position-modePOST /api/v2/mix/account/set-marginPOST /api/v2/mix/account/set-asset-modeGET /api/v2/common/trade-rate
- Futures trade:
POST /api/v2/mix/order/place-orderPOST /api/v2/mix/order/batch-place-orderPOST /api/v2/mix/order/cancel-orderPOST /api/v2/mix/order/cancel-batch-ordersPOST /api/v2/mix/order/cancel-all-ordersPOST /api/v2/mix/order/modify-orderPOST /api/v2/mix/order/close-positionsPOST /api/v2/mix/order/place-plan-orderPOST /api/v2/mix/order/place-tpsl-orderPOST /api/v2/mix/order/place-pos-tpslPOST /api/v2/mix/order/modify-plan-orderPOST /api/v2/mix/order/modify-tpsl-orderPOST /api/v2/mix/order/cancel-plan-orderGET /api/v2/mix/order/detailGET /api/v2/mix/order/orders-pendingGET /api/v2/mix/order/orders-historyGET /api/v2/mix/order/orders-plan-pendingGET /api/v2/mix/order/orders-plan-historyGET /api/v2/mix/order/plan-sub-orderGET /api/v2/mix/order/fills
- Spot wallet/asset:
GET /api/v2/spot/public/coinsGET /api/v2/spot/wallet/deposit-addressGET /api/v2/spot/wallet/deposit-recordsGET /api/v2/spot/wallet/withdrawal-recordsGET /api/v2/spot/wallet/transfer-coin-infoPOST /api/v2/spot/wallet/transferPOST /api/v2/spot/wallet/withdrawal
- WebSocket:
- V2 public/private URL config
- login signing with
timestamp + GET + /user/verify - string
ping/pong - subscribe / unsubscribe payload builders
place-order/cancel-ordertrade payload builders and trade ack parser- base typed event parser with raw fallback
- typed DTOs for
ticker,orders,account,positions,books*,trade,candle*,fill,orders-algo,adl-noti, andpositions-historypushes - WebSocket session with SOCKS5/SOCKS5h proxy support
- reconnect manager with public/private client split, unified message forwarding, pending/active subscription registry, runtime subscribe/unsubscribe, timed ping, private login replay with ack gate, inbound stall timeout, connected-session failure limits, granular connection states, metrics, and subscription replay
- HMAC-SHA256 + Base64 request signing
- SOCKS/HTTP proxy configuration
- Mocked request, signature header, and response mapping tests
Environment
BITGET_API_KEY=...
BITGET_API_SECRET=...
BITGET_PASSPHRASE=...
BITGET_API_URL=https://api.bitget.com
BITGET_API_TIMEOUT_MS=5000
BITGET_PROXY_URL=socks5h://127.0.0.1:7897
BITGET_WS_PUBLIC_URL=wss://ws.bitget.com/v2/ws/public
BITGET_WS_PRIVATE_URL=wss://ws.bitget.com/v2/ws/private
Lowercase key names are also accepted for compatibility with existing .env files:
bitget_api_key=...
bitget_api_secret=...
bitget_passphrase=...
bitget_PASSPHRASE=...
Example
use ;
async
WebSocket Example
use ;
use Config;
async
Public and private smoke examples are also available:
websocket_public_smoke subscribes to public ticker and books5 and waits for one market data push. websocket_private_smoke logs in with BITGET_API_KEY / BITGET_API_SECRET / BITGET_PASSPHRASE, subscribes to account and orders, and does not place orders.