bybit
v1.0.5
Published
Simple and easy to use bybit.com client.
Downloads
30
Readme
Bybit
Simple and easy to use bybit API abstraction defined using the official documentation.
Official API Documentation: https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md
Initialize & Use
Below is a short guide on how to use the client.
Register your APIKEY
testnet
: https://testnet.bybit.com/user/api-managementmainnet
: https://www.bybit.com/app/user/api-management
Configure/Init Client
baseURL.testnet
: https://api-testnet.bybit.combaseURL.mainnet
: https://api.bybit.comkey
: APIKeysecret
: Private Key
const client = require('bybit')({
baseURL: 'https://api.bybit.com',
key: '',
secret: '',
})
Call Something
client
.get('/order/list', params)
.then(console.log)
.catch(console.error)
Interface
Methods provided by the client.
listActiveOrders
List your Active orders.
options
- Optional api params
client
.listOrders([options])
.then(console.log)
.catch(console.error)
getActiveOrder
Get a previously created Active order.
id
- Order ID. The unique order ID returned to you when the corresponding order was created.options
- Optional api params
client
.getOrder(id, [options])
.then(console.log)
.catch(console.error)
cancelActiveOrder
Canel a previously created Active order.
id
- Order ID. The unique order ID returned to you when the corresponding order was created.
client
.cancelOrder(id)
.then(console.log)
.catch(console.error)
createOrder
Create a new order.
client
.createOrder({
side: 'Buy',
symbol: 'BTCUSD',
order_type: 'Limit',
time_in_force: 'GoodTillCancel',
price: 10000,
qty: 100000,
})
.then(console.log)
.catch(console.error)
limitBuy
Create a limit buy order.
price
- Order Priceqty
- Number of Contractsoptions
- Optional api params
client
.limitBuy(price, qty, [options])
.then(console.log)
.catch(console.error)
limitSell
Create a limit sell order.
price
- Order Priceqty
- Number of Contractsoptions
- Optional api params
client
.limitSell(price, qty, [options])
.then(console.log)
.catch(console.error)
marketBuy
Create a market buy order.
qty
- Number of Contractsoptions
- Optional api params
client
.marketBuy(qty, [options])
.then(console.log)
.catch(console.error)
marketSell
Create a market sell order.
qty
- Number of Contractsoptions
- Optional api params
client
.marketSell(qty, [options])
.then(console.log)
.catch(console.error)
createConditionalOrder
Create a new order.
options
- Optional api params
client
.createConditionalOrder([options])
.then(console.log)
.catch(console.error)
listConditionalOrders
List conditional orders.
options
- Optional api params
client
.listConditionalOrders([options])
.then(console.log)
.catch(console.error)
getConditionalOrder
Get a previously created Conditional order.
options
- Optional api params
client
.getOrder('order_id', [options])
.then(console.log)
.catch(console.error)
cancelConditionalOrder
Canel a previously created Conditional order.
id
- Order ID. The unique order ID returned to you when the corresponding order was created.
client
.cancelOrder(id)
.then(console.log)
.catch(console.error)
listMyLeverage
List symbol leverage settings.
client
.listMyLeverage()
.then(console.log)
.catch(console.error)
setMyLeverage
Set symbol leverage setting.
symbol
- Contract typeleverage
- Leverage value
client
.setMyLeverage(symbol, leverage)
.then(console.log)
.catch(console.error)
listMyPositions
List your positions.
client
.listMyPositions()
.then(console.log)
.catch(console.error)
updatePoisitionMargin
Update position margin allocation.
symbol
- Contract typemargin
- margin value
client
.updatePoisitionMargin(symbol, margin)
.then(console.log)
.catch(console.error)
getFundingRate
Get the current funding rate. Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC
symbol
- Contract type
client
.getFundingRate(symbol)
.then(console.log)
.catch(console.error)
getMyFundingFee
Get the provious funding fee. Funding settlement occurs every 8 hours at 00:00 UTC, 08:00 UTC and 16:00 UTC
symbol
- Contract type
client
.getMyFundingFee(symbol)
.then(console.log)
.catch(console.error)
getMyPredictedFunding
Get your predictied funding rate and fee.
symbol
- Contract type
client
.getMyPredictedFunding(symbol)
.then(console.log)
.catch(console.error)
listOrderTrades
List trades placed to fill and order.
id
- order id
client
.listOrderTrades(symbol)
.then(console.log)
.catch(console.error)
getOrderbookSnapshot
Get the current state of the orderbook.
symbol
- Contract type
client
.getOrderbookSnapshot(symbol)
.then(console.log)
.catch(console.error)
listTickers
List all available ticker data. ( price, ect... )
client
.listTickers()
.then(console.log)
.catch(console.error)
getTicker
get current ticker data.
symbol
- Contract type
client
.listTickers(symbol)
.then(console.log)
.catch(console.error)