bybit is an bybit client for the Go programing language.
import "github.com/hirokisan/bybit/v2"
client := bybit.NewClient().WithAuth("your api key", "your api secret")
res, err := client.Future().InversePerpetual().Balance(bybit.CoinBTC)
// do as you want
for single use
import "github.com/hirokisan/bybit/v2"
wsClient := bybit.NewWebsocketClient()
svc, err := wsClient.Spot().V1().PublicV1()
if err != nil {
return err
}
_, err = svc.SubscribeTrade(bybit.SymbolSpotBTCUSDT, func(response bybit.SpotWebsocketV1PublicV1TradeResponse) error {
// do as you want
})
if err != nil {
return err
}
svc.Start(context.Background())
for multiple use
import "github.com/hirokisan/bybit/v2"
wsClient := bybit.NewWebsocketClient()
executors := []bybit.WebsocketExecutor{}
svcRoot := wsClient.Spot().V1()
{
svc, err := svcRoot.PublicV1()
if err != nil {
return err
}
_, err = svc.SubscribeTrade(bybit.SymbolSpotBTCUSDT, func(response bybit.SpotWebsocketV1PublicV1TradeResponse) error {
// do as you want
})
if err != nil {
return err
}
executors = append(executors, svc)
}
{
svc, err := svcRoot.PublicV2()
if err != nil {
return err
}
_, err = svc.SubscribeTrade(bybit.SymbolSpotBTCUSDT, func(response bybit.SpotWebsocketV1PublicV2TradeResponse) error {
// do as you want
})
if err != nil {
return err
}
executors = append(executors, svc)
}
wsClient.Start(context.Background(), executors)
The following API endpoints have been implemented
/v2/public/orderBook/L2Order Book/v2/public/kline/listQuery Kline/v2/public/tickersLatest Information for Symbol/v2/public/trading-recordsPublic Trading Records/v2/public/symbolsQuery Symbol/v2/public/mark-price-klineQuery Mark Price Kline/v2/public/index-price-klineQuery Index Price Kline/v2/public/premium-index-klineQuery Premium Index Kline/v2/public/open-interestOpen Interest/v2/public/big-dealLatest Big Deal/v2/public/account-ratioLong-Short Ratio
/v2/private/order/createPlace Active Order/v2/private/order/listGet Active Order/v2/private/order/cancelCancel Active Order/v2/private/position/listMy Position/v2/private/position/leverage/saveSet Leverage
/v2/private/wallet/balanceGet Wallet Balance
/v2/public/orderBook/L2Order Book/v2/public/tickersLatest Information for Symbol/v2/public/symbolsQuery Symbol/v2/public/open-interestOpen Interest/v2/public/big-dealLatest Big Deal/v2/public/account-ratioLong-Short Ratio
/private/linear/order/createPlace Active Order/private/linear/order/listGet Active Order/private/linear/order/cancelCancel Active Order/private/linear/order/cancel-allCancel All Active Orders/private/linear/position/listMy Position/private/linear/position/set-leverageSet Leverage/private/linear/trade/execution/listUser Trade Records
/v2/private/wallet/balanceGet Wallet Balance
/v2/public/orderBook/L2Order Book/v2/public/kline/listQuery Kline/v2/public/tickersLatest Information for Symbol/v2/public/trading-recordsPublic Trading Records/v2/public/symbolsQuery Symbol/v2/public/mark-price-klineQuery Index Price Kline/v2/public/index-price-klineQuery Index Price Kline/v2/public/open-interestOpen Interest/v2/public/big-dealLatest Big Deal/v2/public/account-ratioLong-Short Ratio
/v2/private/wallet/balanceGet Wallet Balance
/spot/v1/symbolsQuery Symbol/spot/quote/v1/depthOrder Book/spot/quote/v1/depth/mergedMerged Order Book/spot/quote/v1/tradesPublic Trading Records/spot/quote/v1/klineQuery Kline/spot/quote/v1/ticker/24hrLatest Information for Symbol/spot/quote/v1/ticker/priceLast Traded Price/spot/quote/v1/ticker/book_tickerBest Bid/Ask Price
/spot/v1/order- Place Active Order
- Get Active Order
- Cancel Active Order
- Fast Cancel Active Order
/spot/v1/order/fastFast Cancel Active Order/spot/order/batch-cancelBatch Cancel Active Order/spot/order/batch-fast-cancelBatch Fast Cancel Active Order/spot/order/batch-cancel-by-idsBatch Cancel Active Order By IDs/spot/v1/open-ordersOpen Orders
/spot/v1/accountGet Wallet Balance
- trade
- trade
- outboundAccountInfo
There are tests so that we can get to know the changes of bybit api response.
See below