Switch to V2 versions of some APIs: * place order * cancel order Add missing APIs: * cancel all orders * replace order * get symbols Add support for custom order ID for cancel active order.
4.4 KiB
4.4 KiB
Rest API
Class: RestClient
new RestClient([key][, secret])
key{String} Bybit API Keysecret{String} Bybit private key
If you only use the public endpoints you can ommit key and secret.
Private enpoints
async placeActiveOrder(params)
async getActiveOrder(params)
async cancelActiveOrder(params)
async cancelAllActiveOrders(params)
async replaceActiveOrder(params)
async placeConditionalOrder(params)
async getConditioanlOrder(params)
async cancelConditionalOrder(params)
async getUserLeverage()
async changeUserLeverage(params)
async getPosition()
async changePositionMargin(params)
async getLastFundingRate(params)
async getMyLastFundingFee(params)
async getPredictedFunding(params)
async getOrderTradeRecords(params)
Public enpoints
async getOrderBook(params)
async getLatestInformation()
async getServerTime()
async getSymbols()
Returns symbol information (such as tick size & min notional): Meeting price restrictions
async getTimeOffset()
Returns the time offset in ms to the server time retrieved by async getServerTime.
If positive the time on the server is ahead of the clients time, if negative the time on the server is behind the clients time.
Example
const {RestClient} = require('@pxtrn/bybit-api');
const API_KEY = 'xxx';
const PRIVATE_KEY = 'yyy';
const client = new RestClient(API_KEY, PRIVATE_KEY);
client.changeUserLeverage({leverage: 4, symbol: 'ETHUSD'})
.then(result => {
console.log(result);
})
.catch(err => {
console.error(error);
});