- wrapper for /v2/public/time rest endpoint - synchronize time before trying to authenticate a request in order to avoid invalid authentication because prevented replay attacks. Resolves #1
3.7 KiB
3.7 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 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 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);
});