replace deprecated method in sample
This commit is contained in:
32
README.md
32
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
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bybit-api",
|
||||
"version": "1.3.2",
|
||||
"version": "2.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user