5.4 KiB
5.4 KiB
Rest API
Class: RestClient
new RestClient([key][, secret][, livenet][, options])
key{String} Bybit API Keysecret{String} Bybit private keylivenet{Boolean} If false (default), use testnet.options{Object} Optional settings for custom behaviour.recv_window{Number} Optional, default 5000. Increase if recv errors are seen.sync_interval_ms{Number} Optional, default 3600000. Interval at which syncTime is performed.
If you only use the public endpoints you can omit key and secret.
Private enpoints
async placeActiveOrder(params)
async getActiveOrder(params)
async cancelActiveOrder(params)
async cancelAllActiveOrders(params)
async replaceActiveOrder(params)
async queryActiveOrder(params)
async placeConditionalOrder(params)
async getConditionalOrder(params)
async cancelConditionalOrder(params)
async cancelAllConditionalOrders(params)
async queryConditionalOrder(params)
async getUserLeverage()
async changeUserLeverage(params)
async getPosition(params)
async getPositions()
Deprecated v1 method See bybit documentation
async changePositionMargin(params)
async setTradingStop(params)
async getWalletFundRecords(params)
async getWithdrawRecords(params)
async getWalletBalance(params)
async setRiskLimit(params)
async getRiskLimitList()
async getLastFundingRate(params)
async getMyLastFundingFee(params)
async getPredictedFunding(params)
async getTradeRecords(params)
Public enpoints
async getOrderBook(params)
async getKline(params)
async getLatestInformation()
async getPublicTradingRecords(params)
async getServerTime()
async getApiAnnouncements()
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('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(err);
});