Socket
Socket
Sign inDemoInstall

bfx-api-node-rest

Package Overview
Dependencies
135
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.6 to 3.0.8

.jsdoc.json

57

.eslintrc.json
{
"parser": "babel-eslint",
"plugins": [
"jsdoc",
"mocha"
],
"env": {
"es6": true,
"node": true,
"es2020": true
},
"extends": [
"standard"
"standard",
"eslint:recommended",
"plugin:promise/recommended",
"plugin:node/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:lodash/recommended",
"plugin:mocha/recommended",
"plugin:jsdoc/recommended"
],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"jsx-quotes": ["error", "prefer-single"],
"semi": [1, "never"],
"max-len": 0,
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0
},
"settings": {
"import/resolver": {
"node": {
"moduleDirectory": [
"node_modules",
"lib"
]
}
}
},
"env": {
"jest": true
"jsdoc/check-tag-names": 0,
"jsdoc/no-undefined-types": 0,
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
"promise/no-callback-in-promise": 0,
"lodash/prefer-lodash-method": 0,
"lodash/prefer-noop": 0,
"lodash/prefer-constant": 0,
"node/no-unpublished-require": 0,
"mocha/no-mocha-arrows": 0,
"mocha/no-hooks-for-single-case": 0,
"mocha/no-setup-in-describe": 0,
"mocha/no-skipped-tests": 0
}
}
'use strict'
/* eslint camelcase: "off" */
/* eslint-disable */
/* legacy API interface, not cleaned up with new eslint rules */

@@ -4,0 +5,0 @@ const request = require('request')

@@ -7,2 +7,4 @@ 'use strict'

const _isEmpty = require('lodash/isEmpty')
const _isString = require('lodash/isString')
const _isFunction = require('lodash/isFunction')
const { URLSearchParams } = require('url')

@@ -45,3 +47,6 @@ const { genAuthSig, nonce, isClass } = require('bfx-api-node-util')

* Parses response into notification object
* @param {Object} Notification.notify_info
*
* @param {object} data - notification
* @returns {Notification} n
* @private
*/

@@ -60,10 +65,10 @@ function _takeResNotify (data) {

*
* @param {Object} opts
* @param {string?} opts.affCode - affiliate code to be applied to all orders
* @param {string} opts.apiKey
* @param {string} opts.apiSecret
* @param {string} opts.authToken - optional auth option
* @param {string} opts.url - endpoint URL
* @param {boolean} opts.transform - default false
* @param {Object} opts.agent - optional node agent for connection (proxy)
* @param {object} opts - options
* @param {string} [opts.affCode] - affiliate code to be applied to all orders
* @param {string} [opts.apiKey] - API key
* @param {string} [opts.apiSecret] - API secret
* @param {string} [opts.authToken] - optional auth option
* @param {string} [opts.url] - endpoint URL
* @param {boolean} [opts.transform] - default false
* @param {object} [opts.agent] - optional node agent for connection (proxy)
*/

@@ -94,3 +99,3 @@ constructor (opts = {

/**
* @return {boolean} url
* @returns {boolean} url
*/

@@ -102,3 +107,3 @@ getURL () {

/**
* @return {boolean} usesAgent
* @returns {boolean} usesAgent
*/

@@ -110,7 +115,7 @@ usesAgent () {

/**
* @param {string} path
* @param {Object} payload
* @param {Method} cb
* @param {Object|Function} transformer - model class or function
* @return {Promise} p
* @param {string} path - path
* @param {object} payload - payload
* @param {Function} [cb] - callback
* @param {object|Function} transformer - model class or function
* @returns {Promise} p
* @private

@@ -153,5 +158,6 @@ */

/**
* @param {string} path
* @param {Method} cb
* @param {Object|Function} transformer - model class or function
* @param {string} path - path
* @param {Function} [cb] - callback
* @param {object|Function} transformer - model class or function
* @returns {Promise} p
* @private

@@ -179,6 +185,6 @@ */

*
* @param {string} path
* @param {Object} body
* @param {Object|Function} transformer - model class or function
* @return {Promise} p
* @param {string} path - path
* @param {object} body - payload
* @param {object|Function} transformer - model class or function
* @returns {Promise} p
* @private

@@ -209,4 +215,4 @@ */

* @param {string} method - REST1 method name
* @param {Method?} cb - optional legacy cb
* @return {Promise} p - use this
* @param {Function?} [cb] - optional legacy cb
* @returns {Promise} p - use this
* @private

@@ -217,3 +223,3 @@ */

this._rest1.make_public_request(method, (err, data) => {
return this._cb(err, data, cb)
return this._cb(err, data, cb) // eslint-disable-line
.then(resolve)

@@ -227,6 +233,7 @@ .catch(reject)

* See _makePublicLegacyRequest
* @param {string} method
* @param {Object?} params
* @param {Method?} cb
* @return {Promise} p
*
* @param {string} method - method (i.e. GET)
* @param {?object} params - params
* @param {Function?} [cb] - callback
* @returns {Promise} p
* @private

@@ -237,3 +244,3 @@ */

this._rest1.make_request(method, params, (err, data) => {
return this._cb(err, data, cb)
return this._cb(err, data, cb) // eslint-disable-line
.then(resolve)

@@ -246,5 +253,5 @@ .catch(reject)

/**
* @param {Object} data
* @param {Object|Function} transformer - model class or function
* @return {Object|Object[]} finalData
* @param {object} data
* @param {object|Function} transformer - model class or function
* @returns {object|object[]} finalData
* @private

@@ -256,3 +263,3 @@ */

return this._classTransform(data, transformer)
} else if (typeof transformer === 'function') {
} else if (_isFunction(transformer)) {
return transformer(data)

@@ -265,5 +272,5 @@ } else {

/**
* @param {Object} data
* @param {Object} ModelClass
* @return {Object|Object[]} finalData
* @param {object} data - data
* @param {object} ModelClass - class
* @returns {object|object[]} finalData
* @private

@@ -283,5 +290,6 @@ */

/**
* @param {Object} data
* @param {Object|Function} transformer - model class or function
* @return {Object|Object[]} finalData
* @param {object} data - data
* @param {object|Function} transformer - model class or function
* @param {Function} [cb] - callback
* @returns {object|object[]} finalData
* @private

@@ -302,6 +310,6 @@ */

/**
* @param {Error?}
* @param {Response?}
* @param {Method?} cb
* @return {Promise} p
* @param {Error} err - error
* @param {object} res -resposne
* @param {Function} [cb] - callback
* @returns {Promise} p
* @private

@@ -311,3 +319,3 @@ */

return new Promise((resolve, reject) => {
const _isCbFunc = cb && typeof cb === 'function'
const _isCbFunc = [cb] && _isFunction(cb)
if (err) {

@@ -329,3 +337,3 @@ if (err.error && err.error[1] === 10114) {

* @param {Array[]} data order matters
* @return {Array[]} merged arr of currencies and names sorted with no pairs repeated adding pool and explorer to each
* @returns {Array[]} merged arr of currencies and names sorted with no pairs repeated adding pool and explorer to each
* @private

@@ -386,3 +394,4 @@ */

* @param {string} prec - i.e. P0
* @param {Method} cb
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-books

@@ -395,4 +404,4 @@ */

/**
* @param {Method?} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-platform-status

@@ -405,6 +414,6 @@ */

/**
* @param {string?} type
* @param {string[]} keys
* @param {Method?} cb
* @return {Promise} p
* @param {string} [type] - type
* @param {string[]} [keys] - keys
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#status

@@ -420,5 +429,5 @@ */

/**
* @param {string} symbol
* @param {Method} cb
* @return {Promise} p
* @param {string} symbol - symbol
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-ticker

@@ -438,5 +447,5 @@ */

/**
* @param {string[]} symbols
* @param {Method?} cb
* @return {Promise} p
* @param {string[]} symbols - symbols
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-tickers

@@ -458,8 +467,8 @@ */

/**
* @param {string[]} symbols
* @param {number?} start
* @param {number?} end
* @param {number?} limit
* @param {Method?} cb
* @return {Promise} p
* @param {string[]} symbols - symbols
* @param {number} [start] - query start timestamp
* @param {number} [end] - query end timestamp
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-tickers-history

@@ -485,6 +494,6 @@ */

/**
* @param {string} key
* @param {string} context
* @param {Method} cb
* @return {Promise} p
* @param {string} key - key
* @param {string} context - context
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-stats

@@ -498,8 +507,8 @@ */

*
* @param {Object} opts
* @param {object} opts - options
* @param {string} opts.timeframe - 1m, 5m, 15m, 30m, 1h, 3h, 6h, 12h, 1D, 7D, 14D, 1M
* @param {string} opts.symbol
* @param {string} opts.symbol - symbol
* @param {string} opts.section - hist, last
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see http://docs.bitfinex.com/v2/reference#rest-public-candles

@@ -525,6 +534,7 @@ */

*
* @param {string[]} keys
* @param {Method?} cb
* @param {string[]} keys - keys
* @param {Function} [cb] - callback
* @returns {Promise} p
*/
conf (keys = [], cb = () => {}) {
conf (keys = [], [cb] = () => {}) {
if (_isEmpty(keys)) {

@@ -541,4 +551,4 @@ return Promise.resolve([])

*
* @param {Method?} cb - legacy callback
* @return {Promise} p
* @param {Function?} [cb] - legacy callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-currencies

@@ -563,5 +573,5 @@ */

/**
* @param {string} type
* @param {Method} cb
* @return {Promise} p
* @param {string} type - type
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-alert-list

@@ -574,6 +584,7 @@ */

/**
* @param {string} type
* @param {string} symbol
* @param {number} price
* @return {Promise} p
* @param {string} type - type
* @param {string} symbol - symbol
* @param {number} price - price
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-alert-set

@@ -586,5 +597,6 @@ */

/**
* @param {string} symbol
* @param {number} price
* @return {Promise} p
* @param {string} symbol - symbol
* @param {number} price - price
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-alert-delete

@@ -597,9 +609,9 @@ */

/**
* @param {string} symbol
* @param {number?} start
* @param {number?} end
* @param {number?} limit
* @param {number?} sort - if 1, sorts results oldest first
* @param {Method} cb
* @return {Promise} p
* @param {string} symbol - symbol
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {number} [sort] - if 1, sorts results oldest first
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-trades

@@ -625,9 +637,8 @@ */

/**
* @param {string} symbol
* @param {number?} start
* @param {number?} end
* @param {number?} limit
* @param {number?} sort - if 1, sorts results oldest first
* @param {Method} cb
* @return {Promise} p
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {number} [sort] - if 1, sorts results oldest first
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-liquidations

@@ -653,9 +664,9 @@ */

/**
* @param {string?} symbol - optional, omit/leave empty for all
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {number} sort - if 1, sorts results oldest first
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - optional, omit/leave empty for all
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {number} [sort] - if 1, sorts results oldest first
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-trades-hist

@@ -674,7 +685,7 @@ */

/**
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {Method} cb
* @return {Promise} p
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-logins-hist

@@ -691,4 +702,4 @@ */

/**
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-wallets

@@ -701,6 +712,6 @@ */

/**
* @param {number} end
* @param {string} currency
* @param {Method} cb
* @return {Promise} p
* @param {number} [end] - query end
* @param {string} [currency] - currency
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-wallets-hist

@@ -713,4 +724,4 @@ */

/**
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-wallets

@@ -723,4 +734,4 @@ */

/**
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-orders

@@ -733,5 +744,5 @@ */

/**
* @param {array?} ids - order ids
* @param {Method} cb
* @return {Promise} p
* @param {Array} [ids] - order ids
* @param {Function} cb - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-orders

@@ -745,8 +756,8 @@ */

/**
* @param {string?} ccy - i.e. ETH
* @param {number?} start
* @param {number?} end
* @param {number?} limit - default 25
* @param {Method} cb
* @return {Promise} p
* @param {string} [ccy] - i.e. ETH
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit, default 25
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#movements

@@ -763,8 +774,8 @@ */

/**
* @param {Object|string} filters
* @param {number?} start
* @param {number?} end
* @param {number?} limit - default 25
* @param {Method} cb
* @return {Promise} p
* @param {object|string} filters - filters
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - default 25
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#ledgers

@@ -774,3 +785,3 @@ */

const parseFilters = (sent) => {
if (typeof sent === 'string') return { ccy: sent }
if (_isString(sent)) return { ccy: sent }
return sent || {}

@@ -791,7 +802,7 @@ }

* @param {string?} symbol - optional, omit/leave empty for all
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {Method} cb
* @return {Promise} p
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#orders-history

@@ -810,5 +821,5 @@ */

/**
* @param {array?} ids - order ids
* @param {Method} cb
* @return {Promise} p
* @param {Array} [ids] - order ids
* @param {Function} cb - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#orders-history

@@ -822,9 +833,9 @@ */

/**
* @param {string} symbol
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {number} orderID
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - symbol
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {number} [orderID] - order ID
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-order-trades

@@ -839,4 +850,4 @@ */

/**
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-positions

@@ -849,7 +860,7 @@ */

/**
* @param {Number} start
* @param {Number} end
* @param {Number} limit
* @param {Method} cb
* @return {Promise} p
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-positions-history

@@ -864,9 +875,9 @@ */

/**
* @param {Array[]} id
* @param {Number} start
* @param {Number} end
* @param {Number} limit
* @param {Method} cb
* @return {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-positions-audit
* @param {Array[]} [id] - ids of positions to audit
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-positions-audit
*/

@@ -880,5 +891,5 @@ positionsAudit (id = [], start = 0, end = Date.now(), limit = 250, cb) {

/**
* @param {string} symbol
* @param {Method} cb
* @return {Promise} p
* @param {string} symbol - symbol
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-offers

@@ -891,8 +902,8 @@ */

/**
* @param {string} symbol - optional, omit/leave empty for all
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - omit/leave empty for all
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-offers-hist

@@ -910,5 +921,5 @@ */

/**
* @param {string} symbol
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - symbol
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-loans

@@ -921,8 +932,8 @@ */

/**
* @param {string} symbol - optional, omit/leave empty for all
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - omit/leave empty for all
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-loans-hist

@@ -940,5 +951,5 @@ */

/**
* @param {string} symbol
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - symbol
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-credits

@@ -951,8 +962,8 @@ */

/**
* @param {string} symbol - optional, omit/leave empty for all
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - omit/leave empty for all
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-credits-hist

@@ -970,8 +981,8 @@ */

/**
* @param {string} symbol - optional, omit/leave empty for all
* @param {number} start
* @param {number} end
* @param {number} limit
* @param {Method} cb
* @return {Promise} p
* @param {string} [symbol] - optional, omit/leave empty for all
* @param {number} [start] - query start
* @param {number} [end] - query end
* @param {number} [limit] - query limit
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-funding-trades-hist

@@ -990,5 +1001,5 @@ */

/**
* @param {string} key
* @param {Method} cb
* @return {Promise} p
* @param {string} key - key
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-info-margin

@@ -1001,5 +1012,5 @@ */

/**
* @param {string} key
* @param {Method} cb
* @return {Promise} p
* @param {string} key - key
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-info-funding

@@ -1012,4 +1023,4 @@ */

/**
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-performance

@@ -1022,8 +1033,8 @@ */

/**
* @param {string} symbol
* @param {string} dir
* @param {number} rate
* @param {string} type
* @param {Method} cb
* @return {Promise} p
* @param {string} symbol - symbol
* @param {string} dir - dir
* @param {number} rate - rate
* @param {string} type - type
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-calc-bal-avail

@@ -1043,4 +1054,4 @@ */

*
* @param {Method?} cb - legacy callback
* @return {Promise} p
* @param {Function?} [cb] - legacy callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-symbols

@@ -1058,4 +1069,4 @@ */

*
* @param {Method?} cb - legacy callback
* @return {Promise} p
* @param {Function?} [cb] - legacy callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-public-futures

@@ -1073,6 +1084,6 @@ */

*
* @param {string} symbol
* @param {number} collateral
* @param {Method?} cb - legacy callback
* @return {Promise} p
* @param {string} symbol - symbol
* @param {number} collateral - collateral
* @param {Function} [cb] - legacy callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v2/reference#rest-auth-deriv-pos-collateral-set

@@ -1091,4 +1102,4 @@ */

*
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callbak
* @returns {Promise} p
* @deprecated

@@ -1104,4 +1115,4 @@ * @see https://docs.bitfinex.com/v1/reference#rest-public-symbol-details

*
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @deprecated

@@ -1117,4 +1128,4 @@ * @see https://docs.bitfinex.com/v1/reference#rest-auth-account-info

*
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @deprecated

@@ -1131,4 +1142,4 @@ * @see https://docs.bitfinex.com/v1/reference#rest-auth-fees

*
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @see https://docs.bitfinex.com/v1/reference#rest-auth-summary

@@ -1145,4 +1156,4 @@ */

*
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @deprecated

@@ -1158,4 +1169,4 @@ * @see https://docs.bitfinex.com/v1/reference#auth-key-permissions

*
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
* @deprecated

@@ -1169,6 +1180,6 @@ * @see https://docs.bitfinex.com/v1/reference#rest-auth-wallet-balances

/**
* @param {Object} params
* @param {number} params.position_id
* @param {Method} cb
* @return {Promise} p
* @param {object} params - parameters
* @param {number} params.position_id - position ID
* @param {Function} [cb] - callback
* @returns {Promise} p
* @deprecated

@@ -1182,5 +1193,5 @@ * @see https://docs.bitfinex.com/v1/reference#rest-auth-close-position

/**
* @param {Object} settings - key:value map
* @param {Method} cb
* @return {Promise} p
* @param {object} settings - key:value map
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1194,5 +1205,5 @@ updateSettings (settings, cb) {

/**
* @param {string[]} keys
* @param {Method} cb
* @return {Promise} p
* @param {string[]} keys - keys
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1204,5 +1215,5 @@ deleteSettings (keys, cb) {

/**
* @param {string[]} keys
* @param {Method} cb
* @return {Promise} p
* @param {string[]} keys - keys
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1216,3 +1227,3 @@ getSettings (keys, cb) {

* @param {string} ccy2 - i.e. USD
* @return {Promise} p - resolves to currenct exchange rate
* @returns {Promise} p - resolves to currenct exchange rate
*/

@@ -1227,8 +1238,8 @@ exchangeRate (ccy1, ccy2) {

/**
* @param {Object} opts
* @param {number} opts.ttl
* @param {string} opts.scope
* @param {boolean} opts.writePermission
* @param {Method} cb
* @return {Promise} p
* @param {object} opts - options
* @param {number} opts.ttl - time-to-live
* @param {string} opts.scope - scope
* @param {boolean} opts.writePermission - write permission
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1244,4 +1255,5 @@ generateToken ({ ttl, scope, writePermission } = {}, cb) {

*
* @param {Order} order - models.Order
* @param {Method} cb
* @param {Order} order - order model instance
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1271,4 +1283,5 @@ submitOrder (order, cb) {

*
* @param {Objet} order - updates to order
* @param {Method} cb
* @param {object} changes - updates to order
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1283,4 +1296,5 @@ updateOrder (changes, cb) {

*
* @param {int} id - order id
* @param {Method} cb
* @param {number} id - order id
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1295,7 +1309,9 @@ cancelOrder (id, cb) {

*
* @param {int} cid
* @param {Method} cb
* @param {number} cid - cid
* @param {string} date - Date of order YYYY-MM-DD
* @param {Method} cb - callback
* @returns {Promise} p
*/
cancelOrderWithCid (cid, cb) {
return this._makeAuthRequest('/auth/w/order/cancel', { cid }, cb)
cancelOrderWithCid (cid, date, cb) {
return this._makeAuthRequest('/auth/w/order/cancel', { cid, cid_date: date }, cb)
.then(_takeResNotify)

@@ -1305,21 +1321,7 @@ }

/**
* Cancel existing order using the cID date
*
* @param {int} cid
* @param {Method} cb
*/
cancelOrderWithDate (date, cb) {
return this._makeAuthRequest('/auth/w/order/cancel', { cid_date: date }, cb)
.then(_takeResNotify)
}
submitOrderMulti () {
return Promise.reject(new Error('Not implemented - requires work on WS as well'))
}
/**
* Claim existing open position
*
* @param {int} id - position id
* @param {Method} cb
* @param {number} id - position id
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1334,4 +1336,5 @@ claimPosition (id, cb) {

*
* @param {Object} offer - models.Offer
* @param {Method} cb
* @param {object} offer - offer model instance
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1356,4 +1359,5 @@ submitFundingOffer (offer, cb) {

*
* @param {int} id - offer id
* @param {Method} cb
* @param {number} id - offer id
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1368,5 +1372,6 @@ cancelFundingOffer (id, cb) {

*
* @param {Object} params
* @param {object} params - parameters
* @param {string} params.currency - currency i.e USD
* @param {Method} cb
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1381,6 +1386,7 @@ cancelAllFundingOffers (params, cb) {

*
* @param {Object} params
* @param {int} param.id - funding id
* @param {string} param.type - funding type LIMIT | FRRDELTAVAR
* @param {*} cb
* @param {object} params - parameters
* @param {number} params.id - funding id
* @param {string} params.type - funding type LIMIT | FRRDELTAVAR
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1395,9 +1401,10 @@ closeFunding (params, cb) {

*
* @param {Object} params
* @param {int} params.status
* @param {object} params - parameters
* @param {number} params.status - status
* @param {string} params.currency - currency i.e fUSD
* @param {number} params.amount - amount to borrow/lend
* @param {number} params.rate - if == 0 then FRR is used
* @param {int} params.period - time the offer remains locked in for
* @param {*} cb
* @param {number} params.period - time the offer remains locked in for
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1412,2 +1419,3 @@ submitAutoFunding (params, cb) {

*
* @param {object} params - parameters
* @param {number} params.amount - amount to transfer

@@ -1418,4 +1426,4 @@ * @param {string} params.from - wallet from

* @param {string} params.currencyTo - currency to
* @param {Method} cb
* @return {Promise} p
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1429,7 +1437,8 @@ transfer (params, cb) {

/**
* @param {Object} params
* @param {string} wallet - wallet i.e exchange, margin
* @param {string} method - protocol method i.e bitcoin, tetherus
* @param {int} opRenew - if 1 then generates a new address
* @param {*} cb
* @param {object} params - parameters
* @param {string} params.wallet - wallet i.e exchange, margin
* @param {string} params.method - protocol method i.e bitcoin, tetherus
* @param {nubmer} params.opRenew - if 1 then generates a new address
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1443,8 +1452,9 @@ getDepositAddress (params, cb) {

/**
* @param {object} params
* @param {string} wallet - wallet i.e exchange, margin
* @param {string} method - protocol method i.e bitcoin, tetherus
* @param {number} amount - amount to withdraw
* @param {string} address - destination address
* @param {*} cb
* @param {object} params - parameters
* @param {string} params.wallet - wallet i.e exchange, margin
* @param {string} params.method - protocol method i.e bitcoin, tetherus
* @param {number} params.amount - amount to withdraw
* @param {string} params.address - destination address
* @param {Function} [cb] - callback
* @returns {Promise} p
*/

@@ -1451,0 +1461,0 @@ withdraw (params, cb) {

{
"name": "bfx-api-node-rest",
"version": "3.0.6",
"version": "3.0.8",
"description": "Official Bitfinex REST v1 & v2 API interfaces",
"engines": {
"node": ">=7"
"node": ">=8.3.0"
},

@@ -15,8 +15,6 @@ "main": "./dist/index.js",

"scripts": {
"lint": "standard",
"lint": "eslint lib/ examples/ test/ index.js",
"test": "npm run lint && npm run unit",
"unit": "NODE_ENV=test nyc --check-coverage --lines 45 --branches 19 --functions 39 --statements 44 --reporter=lcov --reporter=html mocha -b --recursive",
"rest2_docs": "node_modules/jsdoc-to-markdown/bin/cli.js lib/rest2.js > docs/rest2.md",
"rest1_docs": "node_modules/jsdoc-to-markdown/bin/cli.js lib/rest1.js > docs/rest1.md",
"docs": "npm run rest2_docs && npm run rest1_docs",
"docs": "rm -rf docs && node_modules/.bin/jsdoc --configure .jsdoc.json --verbose",
"build": "babel -q ./index.js -d ./dist && babel -q ./lib -d ./dist/lib && copy package.json dist"

@@ -55,2 +53,12 @@ },

"chai": "^4.2.0",
"docdash": "^1.2.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsdoc": "^22.0.0",
"eslint-plugin-lodash": "^6.0.0",
"eslint-plugin-mocha": "^6.3.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"husky": "^4.2.3",

@@ -64,3 +72,3 @@ "jsdoc-to-markdown": "^5.0.0",

"dependencies": {
"bfx-api-node-models": "^1.1.9",
"bfx-api-node-models": "^1.2.0",
"bfx-api-node-util": "^1.0.4",

@@ -67,0 +75,0 @@ "bluebird": "^3.5.5",

# Bitfinex RESTv1 & RESTv2 APIs for Node.JS
[![Build Status](https://travis-ci.org/bitfinexcom/bfx-api-node-rest.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-api-node-rest)
A Node.JS reference implementation of the Bitfinex REST APIs
To use, construct a new instance of either the `RESTv1` or `RESTv2` classes. All API methods return promises and accept a callback as the last parameter; the callback will be called with `(error, response)`.
To use, construct a new instance of either the `RESTv1` or `RESTv2` classes.
All API methods return promises and accept a callback as the last parameter; the
callback will be called with `(error, response)`.
To minimize the data sent over the network the transmitted data is structured in arrays. In order to reconstruct key / value pairs, set `opts.transform` to `true` when creating an interface.
To minimize the data sent over the network the transmitted data is structured in
arrays. In order to reconstruct key / value pairs, set `opts.transform` to `true`
when creating an interface.
### Features
## Features

@@ -37,4 +40,2 @@ * Official implementation

[See `docs/`](/docs) for JSDoc generated documentation of available methods.
* [RESTv2 API](/docs/rest2.md)
* [RESTv1 API](/docs/rest1.md)

@@ -72,3 +73,7 @@ ## Example

Both v1 client classes & server APIs have been deprecated, and will be removed. In the meantime, some methods available via `RESTv1` have been exposed on `RESTv2` to prevent future migration issues. Although the underlying implementation of these methods is likely to change once they are fully ported to v2, the signatures should remain the same.
Both v1 client classes & server APIs have been deprecated, and will be removed.
In the meantime, some methods available via `RESTv1` have been exposed on
`RESTv2` to prevent future migration issues. Although the underlying
implementation of these methods is likely to change once they are fully ported
to v2, the signatures should remain the same.

@@ -79,5 +84,8 @@ ## FAQ

I make multiple parallel request and I receive an error that the nonce is too small. What does it mean?
I make multiple parallel request and I receive an error that the nonce is too
small. What does it mean?
Nonces are used to guard against replay attacks. When multiple HTTP requests arrive at the API with the wrong nonce, e.g. because of an async timing issue, the API will reject the request.
Nonces are used to guard against replay attacks. When multiple HTTP requests
arrive at the API with the wrong nonce, e.g. because of an async timing issue,
the API will reject the request.

@@ -84,0 +92,0 @@ If you need to go parallel, you have to use multiple API keys right now.

@@ -6,8 +6,12 @@ 'use strict'

const DNS = require('dns')
const assert = require('assert')
const { expect } = require('chai')
const _has = require('lodash/has')
const _map = require('lodash/map')
const _keys = require('lodash/keys')
const _every = require('lodash/every')
const _values = require('lodash/values')
const _isArray = require('lodash/isArray')
const { expect } = require('chai')
const DNS = require('dns')
const RESTv1 = require('../../lib/rest1')
const _ = require('lodash')

@@ -46,3 +50,4 @@ describe('REST v1', () => {

expect(data).to.exist
expect(_.has(data, ['mid',
expect(_has(data, [ // eslint-disable-line
'mid',
'bid',

@@ -73,5 +78,5 @@ 'ask',

expect(data).to.exist
expect(_.has(data[0], ['period', 'volume']))
expect(_.has(data[1], ['period', 'volume']))
expect(_.has(data[2], ['period', 'volume']))
expect(_has(data[0], ['period', 'volume'])) // eslint-disable-line
expect(_has(data[1], ['period', 'volume'])) // eslint-disable-line
expect(_has(data[2], ['period', 'volume'])) // eslint-disable-line
done()

@@ -86,6 +91,6 @@ })

expect(data).to.exist
expect(_.has(data, ['bids', 'asks']))
expect(_.keys(data.bids[0])).is.eql(['rate', 'amount', 'period', 'timestamp', 'frr'])
expect(_.keys(data.asks[0])).is.eql(['rate', 'amount', 'period', 'timestamp', 'frr'])
expect(_.every([data.asks[0] + data.bids[0]]), !NaN).ok
expect(_has(data, ['bids', 'asks'])) // eslint-disable-line
expect(_keys(data.bids[0])).is.eql(['rate', 'amount', 'period', 'timestamp', 'frr'])
expect(_keys(data.asks[0])).is.eql(['rate', 'amount', 'period', 'timestamp', 'frr'])
expect(_every([data.asks[0] + data.bids[0]]), !NaN).ok
done()

@@ -101,6 +106,6 @@ })

expect(data).to.exist
expect(_.keys(data)).is.eql(['bids', 'asks'])
expect(_.keys(data.bids[0])).is.eql(['price', 'amount', 'timestamp'])
expect(_.keys(data.asks[0])).is.eql(['price', 'amount', 'timestamp'])
expect(_.every([data.asks[0] + data.bids[0]]), !NaN).ok
expect(_keys(data)).is.eql(['bids', 'asks'])
expect(_keys(data.bids[0])).is.eql(['price', 'amount', 'timestamp'])
expect(_keys(data.asks[0])).is.eql(['price', 'amount', 'timestamp'])
expect(_every([data.asks[0] + data.bids[0]]), !NaN).ok
done()

@@ -116,5 +121,5 @@ })

expect(data.length).to.eql(100)
expect(_.keys(data[0])).to.eql(['timestamp', 'tid', 'price', 'amount', 'exchange', 'type'])
expect(_keys(data[0])).to.eql(['timestamp', 'tid', 'price', 'amount', 'exchange', 'type'])
expect(
_.map(_.values(data[0]), (v) => typeof (v))
_map(_values(data[0]), (v) => typeof (v))
).is.eql(['number', 'number', 'string', 'string', 'string', 'string'])

@@ -132,5 +137,5 @@ done()

expect(data.length).to.eql(50)
expect(_.keys(data[0])).to.eql(['rate', 'amount_lent', 'amount_used', 'timestamp'])
expect(_keys(data[0])).to.eql(['rate', 'amount_lent', 'amount_used', 'timestamp'])
expect(
_.map(_.values(data[0]), (v) => typeof (v))
_map(_values(data[0]), (v) => typeof (v))
).is.eql(['string', 'string', 'string', 'number'])

@@ -137,0 +142,0 @@ done()

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc