Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Latest commit

 

History

History
148 lines (98 loc) · 5.44 KB

rest-client.md

File metadata and controls

148 lines (98 loc) · 5.44 KB

Rest API

Class: RestClient

new RestClient([key][, secret][, livenet][, options])

  • key {String} Bybit API Key
  • secret {String} Bybit private key
  • livenet {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 ommit key and secret.

Private enpoints

async placeActiveOrder(params)

See bybit documentation

async getActiveOrder(params)

See bybit documentation

async cancelActiveOrder(params)

See bybit documentation

async cancelAllActiveOrders(params)

See bybit documentation

async replaceActiveOrder(params)

See bybit documentation

async queryActiveOrder(params)

See bybit documentation

async placeConditionalOrder(params)

See bybit documentation

async getConditioanlOrder(params)

See bybit documentation

async cancelConditionalOrder(params)

See bybit documentation

async cancelAllConditionalOrders(params)

See bybit documentation

async queryConditionalOrder(params)

See bybit documentation

async getUserLeverage()

See bybit documentation

async changeUserLeverage(params)

See bybit documentation

async getPosition(params)

See bybit documentation

async getPositions()

Deprecated v1 method See bybit documentation

async changePositionMargin(params)

See bybit documentation

async setTradingStop(params)

See bybit documentation

async getWalletFundRecords(params)

See bybit documentation

async getWithdrawRecords(params)

See bybit documentation

async getWalletBalance(params)

See bybit documentation

async setRiskLimit(params)

See bybit documentation

async getRiskLimitList()

See bybit documentation

async getLastFundingRate(params)

See bybit documentation

async getMyLastFundingFee(params)

See bybit documentation

async getPredictedFunding(params)

See bybit documentation

async getTradeRecords(params)

See bybit documentation

Public enpoints

async getOrderBook(params)

See bybit documentation

async getKline(params)

See bybit documentation

async getLatestInformation()

See bybit documentation

async getPublicTradingRecords(params)

See bybit documentation

async getServerTime()

See bybit documentation

async getApiAnnouncements()

See bybit documentation

async getSymbols()

Returns symbol information (such as tick size & min notional): Meeting price restrictions

See bybit documentation

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(err);
  });