Go client for the Bybit REST APIs. Typed as strongly as possible.
Domains:
- market
- order
- position
- pre-upgrade
- account
- asset
- user
- spread
- rfq
- spot-margin-uta
- new-crypto-loan
- crypto-loan
- otc
- broker
- earn
package main
import (
"context"
"fmt"
"os"
"github.com/fullpipe/bybit-go"
)
func main() {
ctx := context.Background()
apiKey := os.Getenv("BYBIT_API_KEY")
apiSecret := os.Getenv("BYBIT_API_SECRET")
client, err := bybit.NewBybitClient(apiKey, apiSecret, bybit.WithBaseURL(bybit.MAINNET))
if err != nil {
panic(err)
}
// Set current Leverage
err = client.SpotMarginTradeSetLeverage(ctx, bybit.SpotMarginTradeSetLeverageParams{Leverage: "5"})
if err != nil {
panic(err)
}
// Get MarkPriceKline
mk, err := client.GetMarketMarkPriceKline(ctx, bybit.MarketMarkPriceKlineQuery{
Category: bybit.CategoryLinear,
Symbol: bybit.SymbolBtcusdt,
Interval: bybit.Interval1,
Limit: 5,
})
if err != nil {
panic(err)
}
fmt.Println(mk)
}- websocket client
- parse types with
... (ms)in comments as int64, even its is string originaly - not all enums detected, like
AssetSettlementRecordListItem.Symbol - remove
github.com/google/go-querystring/querydep? - as I understand "price" field are strings because possible overflow of int64, parse them to
big.Intor add custom string type wrapper
Contributions are welcome!
- but if you found problem within
*_gen.gofiles please open issue first. - if some domain is missing also open issue first