From 63f3de96704f1f543615323f927f51eec44c3e91 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Mon, 22 Feb 2021 11:15:02 +0000 Subject: [PATCH] replace deprecated method in sample --- README.md | 32 ++++++++++++++++++++++++-------- package-lock.json | 2 +- package.json | 2 +- src/inverse-client.ts | 8 ++++---- src/linear-client.ts | 8 ++++---- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5a4321d..ff9f3c0 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Since inverse and linear (USDT) contracts don't use the exact same APIs, the RES ```javascript const { InverseClient } = require('bybit-api'); -const restInverseOptions = { +const restClientOptions = { // override the max size of the request window (in ms) recv_window?: number; @@ -77,16 +77,24 @@ const client = new InverseClient( // optional, uses testnet by default. Set to 'true' to use livenet. useLivenet, - // restInverseOptions, + // restClientOptions, // requestLibraryOptions ); -client.changeUserLeverage({leverage: 4, symbol: 'ETHUSD'}) +client.getApiKeyInfo() .then(result => { - console.log(result); + console.log("apiKey result: ", result); }) .catch(err => { - console.error(err); + console.error("apiKey error: ", err); + }); + +client.getOrderBook({ symbol: 'BTCUSD' }) + .then(result => { + console.log("getOrderBook inverse result: ", result); + }) + .catch(err => { + console.error("getOrderBook inverse error: ", err); }); ``` @@ -98,7 +106,7 @@ To use the Linear (USDT) REST APIs, import the `LinearClient`: ```javascript const { LinearClient } = require('bybit-api'); -const restInverseOptions = { +const restClientOptions = { // override the max size of the request window (in ms) recv_window?: number; @@ -130,17 +138,25 @@ const client = new LinearClient( // optional, uses testnet by default. Set to 'true' to use livenet. useLivenet, - // restInverseOptions, + // restClientOptions, // requestLibraryOptions ); -client.changeUserLeverage({leverage: 4, symbol: 'ETHUSDT'}) +client.getApiKeyInfo() .then(result => { console.log(result); }) .catch(err => { console.error(err); }); + +client.getOrderBook({ symbol: 'BTCUSDT' }) + .then(result => { + console.log("getOrderBook linear result: ", result); + }) + .catch(err => { + console.error("getOrderBook linear error: ", err); + }); ``` ### WebSockets diff --git a/package-lock.json b/package-lock.json index 5d53965..db61da8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "1.3.2", + "version": "2.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9944d18..6568d7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "2.0.1", + "version": "2.0.2", "description": "Node.js connector for Bybit's Inverse & Linear REST APIs and WebSockets", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/inverse-client.ts b/src/inverse-client.ts index 30f3ab9..2a1779e 100644 --- a/src/inverse-client.ts +++ b/src/inverse-client.ts @@ -12,22 +12,22 @@ export class InverseClient extends SharedEndpoints { * @param {string} key - your API key * @param {string} secret - your API secret * @param {boolean} [useLivenet=false] - * @param {RestClientOptions} [restInverseOptions={}] options to configure REST API connectivity + * @param {RestClientOptions} [restClientOptions={}] options to configure REST API connectivity * @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios */ constructor( key?: string | undefined, secret?: string | undefined, useLivenet?: boolean, - restInverseOptions: RestClientOptions = {}, + restClientOptions: RestClientOptions = {}, requestOptions: AxiosRequestConfig = {} ) { super() this.requestWrapper = new RequestWrapper( key, secret, - getRestBaseUrl(useLivenet, restInverseOptions), - restInverseOptions, + getRestBaseUrl(useLivenet, restClientOptions), + restClientOptions, requestOptions ); return this; diff --git a/src/linear-client.ts b/src/linear-client.ts index b623902..4c11411 100644 --- a/src/linear-client.ts +++ b/src/linear-client.ts @@ -12,22 +12,22 @@ export class LinearClient extends SharedEndpoints { * @param {string} key - your API key * @param {string} secret - your API secret * @param {boolean} [useLivenet=false] - * @param {RestClientOptions} [restInverseOptions={}] options to configure REST API connectivity + * @param {RestClientOptions} [restClientOptions={}] options to configure REST API connectivity * @param {AxiosRequestConfig} [requestOptions={}] HTTP networking options for axios */ constructor( key?: string | undefined, secret?: string | undefined, useLivenet?: boolean, - restInverseOptions: RestClientOptions = {}, + restClientOptions: RestClientOptions = {}, requestOptions: AxiosRequestConfig = {} ) { super() this.requestWrapper = new RequestWrapper( key, secret, - getRestBaseUrl(useLivenet, restInverseOptions), - restInverseOptions, + getRestBaseUrl(useLivenet, restClientOptions), + restClientOptions, requestOptions ); return this;