-
Notifications
You must be signed in to change notification settings - Fork 0
Home
bitget-go is an idiomatic Go client for the Bitget Unified Trading Account (UTA) API v3. It provides typed REST access to the implemented market, account, and trade endpoints, alongside a reconnecting WebSocket client for public and private streams. The library keeps financial values as strings, uses context.Context on network calls, and exposes Go-native error inspection through errors.Is and errors.As. 1 2
Scope notice. This documentation describes the repository's current Phase 1 implementation. An endpoint or stream not listed in the coverage table is not implemented by the SDK, even if it exists in Bitget's wider UTA API. 1
Install the module, construct a RestClient, and call a public ticker endpoint:
go get github.com/tigusigalpa/bitget-gopackage main
import (
"context"
"fmt"
"log"
bitget "github.com/tigusigalpa/bitget-go"
"github.com/tigusigalpa/bitget-go/models"
)
func main() {
client := bitget.NewRestClient("", "", "")
tickers, err := client.Market.GetTickers(
context.Background(),
models.CategorySpot,
"BTCUSDT",
)
if err != nil {
log.Fatal(err)
}
if len(tickers) > 0 {
fmt.Println(tickers[0].LastPrice)
}
}Public market endpoints do not require API credentials. Private account, trade, and private WebSocket endpoints require an API key, secret key, and passphrase created in Bitget's API Key Management interface. 1 3
| Area | Client surface | Implemented operations |
|---|---|---|
| Market | client.Market |
GetInstruments, GetTickers, GetOrderBook
|
| Account | client.Account |
GetAssets, GetSettings, SetLeverage
|
| Trade | client.Trade |
PlaceOrder, ModifyOrder, CancelOrder, GetOpenOrders, GetOrderHistory, GetPositions
|
| WebSocket | WSClient |
Public/private connection, subscribe, unsubscribe, automatic reconnect and resubscription; typed fast-fill payload model |
The market service is public, while the account and trade services sign their requests automatically. The WebSocket transport is channel-agnostic: it can subscribe to Bitget channels through models.WSArg; however, fast-fill is the only currently supplied typed stream payload model. 1 2
| Page | Purpose |
|---|---|
| Getting Started | Install the SDK, manage credentials, make a first public and private call. |
| REST Client and Configuration | Configure timeout, HTTP transport, locale, logging, base URL, and demo trading. |
| Market Data | Retrieve instruments, 24-hour tickers, and order-book snapshots. |
| Account Management | Read UTA assets/settings and change leverage. |
| Trading | Place, amend, cancel, list, and inspect orders and positions. |
| WebSocket Streaming | Connect to real-time public or private streams and consume pushes safely. |
| Errors and Reliability | Handle transport errors, API errors, rate limits, and contexts. |
| Models and Numeric Precision | Use constants, models, and exact decimal handling correctly. |
| Development and Contributing | Run checks and add supported endpoint coverage. |
The SDK is intentionally small and explicit. It unpacks Bitget's response envelope into typed Go data, injects signing headers only for authenticated calls, and keeps price, quantity, PnL, and fee fields as string values rather than converting them to float64. This avoids silent IEEE-754 rounding at the SDK boundary while leaving the caller free to choose an exact-decimal representation. 1 2
For live trading automation, treat API credentials as secrets, use contexts with deadlines, validate behavior with Bitget Demo credentials first, and build explicit safeguards around order submission. Bitget's own guide specifies that REST demo requests use a Demo API key and the paptrading: 1 header; WithDemoTrading() enables that header for signed REST calls. 3 4