bybit is an bybit client for the Go programming 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
/derivatives/v3/public/order-book/L2Get Order Book/derivatives/v3/public/klineGet Kline/derivatives/v3/public/tickersGet Latest Information For Symbol/derivatives/v3/public/instruments-infoGet Instrument Info/derivatives/v3/public/mark-price-klineGet Mark Price Kline/derivatives/v3/public/index-price-klineGet Index Price Kline
/derivatives/v3/public/order-book/L2Get Order Book/derivatives/v3/public/klineGet Kline/derivatives/v3/public/tickersGet Latest Information For Symbol/derivatives/v3/public/instruments-infoGet Instrument Info/derivatives/v3/public/mark-price-klineGet Mark Price Kline/derivatives/v3/public/index-price-klineGet Index Price Kline
/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/order/cancelAllCancel All Active Orders/v2/private/orderQuery Active Order (real-time)/v2/private/stop-order/createPlace Conditional Order/v2/private/stop-order/listGet Conditional Order/v2/private/stop-order/cancelCancel Conditional Order/v2/private/stop-order/cancelAllCancel All Conditional Orders/v2/private/stop-orderQuery Conditional Order (real-time)/v2/private/position/listMy Position/v2/private/position/trading-stopSet Trading-Stop/v2/private/position/leverage/saveSet Leverage
/v2/private/wallet/balanceGet Wallet Balance
/v2/public/orderBook/L2Order Book/public/linear/klineQuery Kline/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/order/replaceReplace Active Order/private/linear/order/searchQuery Active Order (real-time)/private/linear/stop-order/createPlace Conditional Order/private/linear/stop-order/listGet Conditional Order/private/linear/stop-order/cancelCancel Conditional Order/private/linear/stop-order/cancel-allCancel All Conditional Orders/private/linear/stop-order/searchQuery Conditional Order (real-time)/private/linear/position/listMy Position/private/linear/position/set-leverageSet Leverage/private/linear/position/trading-stopSet Trading-Stop/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
/futures/private/order/createPlace Active Order/futures/private/order/listGet Active Order/futures/private/order/cancelCancel Active Order/futures/private/order/cancelAllCancel All Active Orders/futures/private/orderQuery Active Order (real-time)/futures/private/stop-order/createPlace Conditional Order/futures/private/stop-order/listGet Conditional Order/futures/private/stop-order/cancelCancel Conditional Order/futures/private/stop-order/cancelAllCancel All Conditional Orders/futures/private/stop-orderQuery Conditional Order (real-time)/futures/private/position/listMy Position/futures/private/position/trading-stopSet Trading-Stop/futures/private/position/leverage/saveSet Leverage
/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
I would like to cover Bybit API and contributions are always welcome. The calling pattern is established, so adding new methods is relatively straightforward. See some PRs like hirokisan#44.
To submit issues, PRs, and every other help is welcome.