Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork85
Bybit client library for Go
License
hirokisan/bybit
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
bybit is a 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()iferr!=nil {returnerr}_,err=svc.SubscribeTrade(bybit.SymbolSpotBTCUSDT,func(response bybit.SpotWebsocketV1PublicV1TradeResponse)error {// do as you want})iferr!=nil {returnerr}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()iferr!=nil {returnerr}_,err=svc.SubscribeTrade(bybit.SymbolSpotBTCUSDT,func(response bybit.SpotWebsocketV1PublicV1TradeResponse)error {// do as you want})iferr!=nil {returnerr}executors=append(executors,svc)}{svc,err:=svcRoot.PublicV2()iferr!=nil {returnerr}_,err=svc.SubscribeTrade(bybit.SymbolSpotBTCUSDT,func(response bybit.SpotWebsocketV1PublicV2TradeResponse)error {// do as you want})iferr!=nil {returnerr}executors=append(executors,svc)}wsClient.Start(context.Background(),executors)
V5 usage
import"github.com/hirokisan/bybit/v2"wsClient:=bybit.NewWebsocketClient().WithBaseURL("wss://stream-testnet.bybit.com").WithAuth("key","secret")svc,err:=wsClient.V5().Private()iferr!=nil {// handle dialing error}err=svc.Subscribe()iferr!=nil {// handle subscription error}err=svc.SubscribePosition(func(position bybit.V5WebsocketPrivatePositionResponse)error {// handle new position information})iferr!=nil {// handle registration error}errHandler:=func(isWebsocketClosedbool,errerror) {// Connection issue (timeout, etc.).// At this point, the connection is dead and you must handle the reconnection yourself}err=svc.Start(context.Background(),errHandler)iferr!=nil {// handle reconnection (ping issue, etc.). Probably can be ignored as the errHandler would be notified too}
The following API endpoints have been implemented
/v5/market/klineGet Kline/v5/market/mark-price-klineGet Mark Price Kline/v5/market/index-price-klineGet Index Price Kline/v5/market/premium-index-price-klineGet Premium Index Price Kline/v5/market/instruments-infoGet Instruments Info/v5/market/orderbookGet Orderbook/v5/market/tickersGet Tickers/v5/market/funding/historyGet Funding Rate History/v5/market/recent-tradeGet Public Trading History/v5/market/open-interestGet Open Interest/v5/market/historical-volatilityGet Historical Volatility/v5/market/insuranceGet Insurance/v5/market/risk-limitGet Risk Limit
/v5/position/listGet Position Info/v5/position/set-leverageSet Leverage/v5/position/switch-isolatedSwitch Cross/Isolated Margin/v5/position/trading-stopSet Trading Stop/v5/position/switch-modeSwitch Position Mode/v5/position/set-tpsl-modeSet TP/SL Mode/v5/position/closed-pnlGet Closed PnL/v5/position/set-risk-limitSet Risk Limit/v5/execution/listGet Execution
/v5/order/createPlace Order/v5/order/amendAmend Order/v5/order/cancelCancel Order/v5/order/realtimeGet Open Orders/v5/order/cancel-allCancel All Orders/v5/order/historyGet Order History
/v5/account/wallet-balanceGet Wallet Balance/v5/account/account-infoGet Account Info/v5/account/transaction-logGet Transaction Log/v5/account/collateral-infoGet Collateral Info/v5/account/set-collateral-switchSet Collateral Coin/v5/account/batch-set-collateralBatch Set Collateral Coin/v5/account/fee-rateGet Fee Rate
/v5/asset/transfer/inter-transferCreate Internal Transfer/v5/asset/transfer/query-inter-transfer-listGet Internal Transfer Records/v5/asset/transfer/query-account-coins-balanceGet All Coins Balance/v5/asset/deposit/query-recordGet Deposit Records/v5/asset/deposit/query-sub-member-recordGet Sub Deposit Records/v5/asset/deposit/query-internal-recordGet Internal Deposit Records/v5/asset/deposit/query-addressGet Master Deposit Address/v5/asset/withdraw/query-recordGet Withdrawal Records/v5/asset/coin/query-infoGet Coin Info/v5/asset/withdraw/createWithdraw/v5/asset/transfer/universal-transferCreate Universal Transfer/v5/asset/transfer/query-universal-transfer-listGet Universal Transfer Records
/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/account/api-keyAPI Key info
/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/account/api-keyAPI Key info
/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/account/api-keyAPI Key info
/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
- Create
- Cancel
[deprecated]Spot v1
- 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#44.
To submit issues, PRs, and every other help is welcome.
About
Bybit client library for Go
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.