-
Notifications
You must be signed in to change notification settings - Fork 0
Market Data
The Market service exposes the SDK's implemented public REST endpoints. These calls do not require API credentials or request signatures, but they should still use contexts and handle rate limiting in production. 1 2
client := bitget.NewRestClient("", "", "")| Method | Signature | Returns | HTTP endpoint |
|---|---|---|---|
GetInstruments |
GetInstruments(ctx, category, symbol) |
[]models.Instrument |
GET /api/v3/market/instruments |
GetTickers |
GetTickers(ctx, category, symbol) |
[]models.Ticker |
GET /api/v3/market/tickers |
GetOrderBook |
GetOrderBook(ctx, category, symbol, limit) |
*models.OrderBook |
GET /api/v3/market/orderbook |
category is always sent by the first two methods and should normally be one of the exported models.Category* constants. For GetInstruments and GetTickers, an empty symbol requests the category-wide response. For GetOrderBook, provide both category and symbol; pass an empty limit to use Bitget's server default. 1 3
| Constant | API value |
|---|---|
models.CategorySpot |
SPOT |
models.CategoryMargin |
MARGIN |
models.CategoryUSDTFutures |
USDT-FUTURES |
models.CategoryCoinFutures |
COIN-FUTURES |
models.CategoryUSDCFutures |
USDC-FUTURES |
The model aliases are strings, not restrictive Go enums. The listed constants are convenient common values, while the string design allows compatibility with future categories introduced by Bitget. 3
Use GetInstruments before placing orders. An instrument response exposes constraints such as MinOrderQty, MaxOrderQty, PricePrecision, and QuantityPrecision, plus product status and leverage-related limits. Validate an order against these fields in application logic rather than assuming a symbol's trade size or tick behavior. 1 4
ctx := context.Background()
instruments, err := client.Market.GetInstruments(
ctx,
models.CategorySpot,
"BTCUSDT",
)
if err != nil {
return err
}
if len(instruments) == 0 {
return fmt.Errorf("BTCUSDT instrument not returned")
}
instrument := instruments[0]
fmt.Printf(
"min qty=%s price precision=%s quantity precision=%s\n",
instrument.MinOrderQty,
instrument.PricePrecision,
instrument.QuantityPrecision,
)GetTickers returns a slice, even when a single symbol is supplied. Each models.Ticker includes LastPrice, top-of-book values (Bid1Price, Ask1Price), 24-hour high/low/open data, volume, turnover, and—where applicable—derivatives data such as MarkPrice, FundingRate, and OpenInterest. All numeric data is represented as string. 1 4
tickers, err := client.Market.GetTickers(ctx, models.CategorySpot, "BTCUSDT")
if err != nil {
return err
}
for _, ticker := range tickers {
fmt.Printf(
"%s last=%s bid=%s ask=%s change=%s\n",
ticker.Symbol,
ticker.LastPrice,
ticker.Bid1Price,
ticker.Ask1Price,
ticker.Price24hPcnt,
)
}GetOrderBook returns a snapshot with bid and ask levels. Each models.OrderBookLevel is a two-string array where index 0 is price and index 1 is quantity. Check a slice's length before accessing its first element. 1 4
book, err := client.Market.GetOrderBook(
ctx,
models.CategorySpot,
"BTCUSDT",
"5",
)
if err != nil {
return err
}
if len(book.Bids) > 0 && len(book.Asks) > 0 {
bestBid := book.Bids[0]
bestAsk := book.Asks[0]
fmt.Printf("best bid: price=%s qty=%s\n", bestBid[0], bestBid[1])
fmt.Printf("best ask: price=%s qty=%s\n", bestAsk[0], bestAsk[1])
}The source implementation documents a default depth of 5 and a maximum limit of 1000 for this endpoint. Consult Bitget's endpoint documentation for the live parameter rules and rate limit before raising polling frequency. 1 5
Use WebSocket streams rather than aggressive REST polling when an application needs continuously changing tickers or order books. Bitget recommends WebSocket for market information and provides separate connection, subscription, and message-rate limits. 2
See WebSocket Streaming for connection lifecycle and subscription patterns.