bfx-api-node-rest
Version:
Official Bitfinex REST v1 & v2 API interfaces
681 lines (575 loc) • 29.4 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>rest1.js - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<input type="text" id="nav-search" placeholder="Search" />
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="RESTv1.html">RESTv1</a><ul class='methods'><li data-type='method'><a href="RESTv1.html#account_infos">account_infos</a></li><li data-type='method'><a href="RESTv1.html#active_credits">active_credits</a></li><li data-type='method'><a href="RESTv1.html#active_offers">active_offers</a></li><li data-type='method'><a href="RESTv1.html#active_orders">active_orders</a></li><li data-type='method'><a href="RESTv1.html#active_positions">active_positions</a></li><li data-type='method'><a href="RESTv1.html#balance_history">balance_history</a></li><li data-type='method'><a href="RESTv1.html#cancel_all_orders">cancel_all_orders</a></li><li data-type='method'><a href="RESTv1.html#cancel_multiple_orders">cancel_multiple_orders</a></li><li data-type='method'><a href="RESTv1.html#cancel_offer">cancel_offer</a></li><li data-type='method'><a href="RESTv1.html#cancel_order">cancel_order</a></li><li data-type='method'><a href="RESTv1.html#claim_position">claim_position</a></li><li data-type='method'><a href="RESTv1.html#close_swap">close_swap</a></li><li data-type='method'><a href="RESTv1.html#fundingbook">fundingbook</a></li><li data-type='method'><a href="RESTv1.html#get_symbols">get_symbols</a></li><li data-type='method'><a href="RESTv1.html#lends">lends</a></li><li data-type='method'><a href="RESTv1.html#margin_infos">margin_infos</a></li><li data-type='method'><a href="RESTv1.html#movements">movements</a></li><li data-type='method'><a href="RESTv1.html#multiple_new_orders">multiple_new_orders</a></li><li data-type='method'><a href="RESTv1.html#new_deposit">new_deposit</a></li><li data-type='method'><a href="RESTv1.html#new_offer">new_offer</a></li><li data-type='method'><a href="RESTv1.html#new_order">new_order</a></li><li data-type='method'><a href="RESTv1.html#offer_status">offer_status</a></li><li data-type='method'><a href="RESTv1.html#order_status">order_status</a></li><li data-type='method'><a href="RESTv1.html#orderbook">orderbook</a></li><li data-type='method'><a href="RESTv1.html#orders_history">orders_history</a></li><li data-type='method'><a href="RESTv1.html#past_trades">past_trades</a></li><li data-type='method'><a href="RESTv1.html#replace_order">replace_order</a></li><li data-type='method'><a href="RESTv1.html#stats">stats</a></li><li data-type='method'><a href="RESTv1.html#symbols_details">symbols_details</a></li><li data-type='method'><a href="RESTv1.html#taken_swaps">taken_swaps</a></li><li data-type='method'><a href="RESTv1.html#ticker">ticker</a></li><li data-type='method'><a href="RESTv1.html#today">today</a></li><li data-type='method'><a href="RESTv1.html#total_taken_swaps">total_taken_swaps</a></li><li data-type='method'><a href="RESTv1.html#trades">trades</a></li><li data-type='method'><a href="RESTv1.html#transfer">transfer</a></li><li data-type='method'><a href="RESTv1.html#wallet_balances">wallet_balances</a></li><li data-type='method'><a href="RESTv1.html#withdraw">withdraw</a></li></ul></li><li><a href="RESTv2.html">RESTv2</a><ul class='methods'><li data-type='method'><a href="RESTv2.html#accountFees">accountFees</a></li><li data-type='method'><a href="RESTv2.html#accountSummary">accountSummary</a></li><li data-type='method'><a href="RESTv2.html#accountTrades">accountTrades</a></li><li data-type='method'><a href="RESTv2.html#activeOrders">activeOrders</a></li><li data-type='method'><a href="RESTv2.html#activeOrdersWithIds">activeOrdersWithIds</a></li><li data-type='method'><a href="RESTv2.html#alertDelete">alertDelete</a></li><li data-type='method'><a href="RESTv2.html#alertList">alertList</a></li><li data-type='method'><a href="RESTv2.html#alertSet">alertSet</a></li><li data-type='method'><a href="RESTv2.html#calcAvailableBalance">calcAvailableBalance</a></li><li data-type='method'><a href="RESTv2.html#cancelAllFundingOffers">cancelAllFundingOffers</a></li><li data-type='method'><a href="RESTv2.html#cancelFundingOffer">cancelFundingOffer</a></li><li data-type='method'><a href="RESTv2.html#cancelOrder">cancelOrder</a></li><li data-type='method'><a href="RESTv2.html#cancelOrderMulti">cancelOrderMulti</a></li><li data-type='method'><a href="RESTv2.html#cancelOrderWithCid">cancelOrderWithCid</a></li><li data-type='method'><a href="RESTv2.html#cancelOrders">cancelOrders</a></li><li data-type='method'><a href="RESTv2.html#cancelRecurringAlgoOrder">cancelRecurringAlgoOrder</a></li><li data-type='method'><a href="RESTv2.html#candles">candles</a></li><li data-type='method'><a href="RESTv2.html#changeLogs">changeLogs</a></li><li data-type='method'><a href="RESTv2.html#claimPosition">claimPosition</a></li><li data-type='method'><a href="RESTv2.html#closeFunding">closeFunding</a></li><li data-type='method'><a href="RESTv2.html#closePosition">closePosition</a></li><li data-type='method'><a href="RESTv2.html#conf">conf</a></li><li data-type='method'><a href="RESTv2.html#currencies">currencies</a></li><li data-type='method'><a href="RESTv2.html#deleteSettings">deleteSettings</a></li><li data-type='method'><a href="RESTv2.html#derivsPositionCollateralSet">derivsPositionCollateralSet</a></li><li data-type='method'><a href="RESTv2.html#exchangeRate">exchangeRate</a></li><li data-type='method'><a href="RESTv2.html#fundingCreditHistory">fundingCreditHistory</a></li><li data-type='method'><a href="RESTv2.html#fundingCredits">fundingCredits</a></li><li data-type='method'><a href="RESTv2.html#fundingInfo">fundingInfo</a></li><li data-type='method'><a href="RESTv2.html#fundingLoanHistory">fundingLoanHistory</a></li><li data-type='method'><a href="RESTv2.html#fundingLoans">fundingLoans</a></li><li data-type='method'><a href="RESTv2.html#fundingOfferHistory">fundingOfferHistory</a></li><li data-type='method'><a href="RESTv2.html#fundingOffers">fundingOffers</a></li><li data-type='method'><a href="RESTv2.html#fundingTrades">fundingTrades</a></li><li data-type='method'><a href="RESTv2.html#futures">futures</a></li><li data-type='method'><a href="RESTv2.html#generateInvoice">generateInvoice</a></li><li data-type='method'><a href="RESTv2.html#generateToken">generateToken</a></li><li data-type='method'><a href="RESTv2.html#getCoreSettings">getCoreSettings</a></li><li data-type='method'><a href="RESTv2.html#getDepositAddress">getDepositAddress</a></li><li data-type='method'><a href="RESTv2.html#getRecurringAlgoOrder">getRecurringAlgoOrder</a></li><li data-type='method'><a href="RESTv2.html#getRecurringAlgoOrders">getRecurringAlgoOrders</a></li><li data-type='method'><a href="RESTv2.html#getRecurringAoOrders">getRecurringAoOrders</a></li><li data-type='method'><a href="RESTv2.html#getSettings">getSettings</a></li><li data-type='method'><a href="RESTv2.html#getURL">getURL</a></li><li data-type='method'><a href="RESTv2.html#getWeightedAverages">getWeightedAverages</a></li><li data-type='method'><a href="RESTv2.html#inactiveSymbols">inactiveSymbols</a></li><li data-type='method'><a href="RESTv2.html#invalidateAuthToken">invalidateAuthToken</a></li><li data-type='method'><a href="RESTv2.html#keepFunding">keepFunding</a></li><li data-type='method'><a href="RESTv2.html#keyPermissions">keyPermissions</a></li><li data-type='method'><a href="RESTv2.html#ledgers">ledgers</a></li><li data-type='method'><a href="RESTv2.html#liquidations">liquidations</a></li><li data-type='method'><a href="RESTv2.html#lnxInvoicePayments">lnxInvoicePayments</a></li><li data-type='method'><a href="RESTv2.html#logins">logins</a></li><li data-type='method'><a href="RESTv2.html#marginInfo">marginInfo</a></li><li data-type='method'><a href="RESTv2.html#marketAveragePrice">marketAveragePrice</a></li><li data-type='method'><a href="RESTv2.html#movementInfo">movementInfo</a></li><li data-type='method'><a href="RESTv2.html#movements">movements</a></li><li data-type='method'><a href="RESTv2.html#orderBook">orderBook</a></li><li data-type='method'><a href="RESTv2.html#orderHistory">orderHistory</a></li><li data-type='method'><a href="RESTv2.html#orderHistoryWithIds">orderHistoryWithIds</a></li><li data-type='method'><a href="RESTv2.html#orderMultiOp">orderMultiOp</a></li><li data-type='method'><a href="RESTv2.html#orderTrades">orderTrades</a></li><li data-type='method'><a href="RESTv2.html#payAddCurrencyConversion">payAddCurrencyConversion</a></li><li data-type='method'><a href="RESTv2.html#payCurrencyConversionList">payCurrencyConversionList</a></li><li data-type='method'><a href="RESTv2.html#payCurrencyList">payCurrencyList</a></li><li data-type='method'><a href="RESTv2.html#payDeposits">payDeposits</a></li><li data-type='method'><a href="RESTv2.html#payDepositsUnlinked">payDepositsUnlinked</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceComplete">payInvoiceComplete</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceCreate">payInvoiceCreate</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceCreatePos">payInvoiceCreatePos</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceCurrencyDetailed">payInvoiceCurrencyDetailed</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceEvents">payInvoiceEvents</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceExpire">payInvoiceExpire</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceList">payInvoiceList</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceListPaginated">payInvoiceListPaginated</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceMarkRefunded">payInvoiceMarkRefunded</a></li><li data-type='method'><a href="RESTv2.html#payInvoiceUpdate">payInvoiceUpdate</a></li><li data-type='method'><a href="RESTv2.html#payMerchantDailyLimit">payMerchantDailyLimit</a></li><li data-type='method'><a href="RESTv2.html#payMerchantSettingsList">payMerchantSettingsList</a></li><li data-type='method'><a href="RESTv2.html#payMerchantSettingsRead">payMerchantSettingsRead</a></li><li data-type='method'><a href="RESTv2.html#payMerchantSettingsWrite">payMerchantSettingsWrite</a></li><li data-type='method'><a href="RESTv2.html#payMerchantSettingsWriteBatch">payMerchantSettingsWriteBatch</a></li><li data-type='method'><a href="RESTv2.html#payPublicInvoiceCurrencyDetailed">payPublicInvoiceCurrencyDetailed</a></li><li data-type='method'><a href="RESTv2.html#payRefundInvoice">payRefundInvoice</a></li><li data-type='method'><a href="RESTv2.html#payRemoveCurrencyConversion">payRemoveCurrencyConversion</a></li><li data-type='method'><a href="RESTv2.html#performance">performance</a></li><li data-type='method'><a href="RESTv2.html#positions">positions</a></li><li data-type='method'><a href="RESTv2.html#positionsAudit">positionsAudit</a></li><li data-type='method'><a href="RESTv2.html#positionsHistory">positionsHistory</a></li><li data-type='method'><a href="RESTv2.html#positionsSnapshot">positionsSnapshot</a></li><li data-type='method'><a href="RESTv2.html#stats">stats</a></li><li data-type='method'><a href="RESTv2.html#status">status</a></li><li data-type='method'><a href="RESTv2.html#statusMessages">statusMessages</a></li><li data-type='method'><a href="RESTv2.html#submitAutoFunding">submitAutoFunding</a></li><li data-type='method'><a href="RESTv2.html#submitFundingOffer">submitFundingOffer</a></li><li data-type='method'><a href="RESTv2.html#submitOrder">submitOrder</a></li><li data-type='method'><a href="RESTv2.html#submitOrderMulti">submitOrderMulti</a></li><li data-type='method'><a href="RESTv2.html#submitRecurringAlgoOrder">submitRecurringAlgoOrder</a></li><li data-type='method'><a href="RESTv2.html#symbolDetails">symbolDetails</a></li><li data-type='method'><a href="RESTv2.html#symbols">symbols</a></li><li data-type='method'><a href="RESTv2.html#ticker">ticker</a></li><li data-type='method'><a href="RESTv2.html#tickers">tickers</a></li><li data-type='method'><a href="RESTv2.html#tickersHistory">tickersHistory</a></li><li data-type='method'><a href="RESTv2.html#trades">trades</a></li><li data-type='method'><a href="RESTv2.html#transfer">transfer</a></li><li data-type='method'><a href="RESTv2.html#updateOrder">updateOrder</a></li><li data-type='method'><a href="RESTv2.html#updateOrderMulti">updateOrderMulti</a></li><li data-type='method'><a href="RESTv2.html#updateRecurringAlgoOrder">updateRecurringAlgoOrder</a></li><li data-type='method'><a href="RESTv2.html#updateSettings">updateSettings</a></li><li data-type='method'><a href="RESTv2.html#userInfo">userInfo</a></li><li data-type='method'><a href="RESTv2.html#usesAgent">usesAgent</a></li><li data-type='method'><a href="RESTv2.html#wallets">wallets</a></li><li data-type='method'><a href="RESTv2.html#walletsHistory">walletsHistory</a></li><li data-type='method'><a href="RESTv2.html#withdraw">withdraw</a></li></ul></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<div id="main">
<h1 class="page-title">rest1.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>'use strict'
/* eslint-disable */
/* legacy API interface, not cleaned up with new eslint rules */
const fetch = require('node-fetch')
const debug = require('debug')('bfx:rest1')
const { genAuthSig, nonce } = require('bfx-api-node-util')
const API_URL = 'https://api.bitfinex.com'
/**
* Communicates with v1 of the Bitfinex HTTP API
*/
class RESTv1 {
/**
* Instantiate a new REST v1 transport.
*
* @param {Object} opts
* @param {string?} opts.apiKey
* @param {string?} opts.apiSecret
* @param {string?} opts.url - endpoint URL
* @param {Object?} opts.agent - optional node agent for connection (proxy)
* @param {Method?} opts.nonceGenerator - optional, should return a nonce
*/
constructor (opts = {}) {
this._url = opts.url || API_URL
this._apiKey = opts.apiKey || ''
this._apiSecret = opts.apiSecret || ''
this._agent = opts.agent
this._generateNonce = (typeof opts.nonceGenerator === 'function')
? opts.nonceGenerator
: nonce
}
/**
* @param {string} body - raw JSON
* @param {Method} cb
* @private
*/
_parse_req_body (result, cb) {
if (typeof result.message === 'string') {
if (result.message.indexOf('Nonce is too small') !== -1) {
result.message += ' See https://github.com/bitfinexcom/bitfinex-api-node/blob/master/README.md#nonce-too-small for help'
}
return cb(new Error(result.message))
}
return cb(null, result)
}
/**
* @param {string} path
* @param {Object} params
* @param {Method} cb
* @private
*/
async make_request (path, params, cb) {
if (!this._apiKey || !this._apiSecret) {
return cb(new Error('missing api key or secret'))
}
if (!path) {
return cb(new Error('path is missing'))
}
const payload = Object.assign({
request: `/v1/${path}`,
nonce: JSON.stringify(this._generateNonce())
}, params)
const payloadBase64 = Buffer.from(JSON.stringify(payload)).toString('base64')
const { sig } = genAuthSig(this._apiSecret, payloadBase64)
const url = `${this._url}/v1/${path}`
debug('POST %s', url)
const reqOpts = {
method: 'POST',
timeout: 15000,
agent: this._agent,
headers: {
'X-BFX-APIKEY': this._apiKey,
'X-BFX-PAYLOAD': payloadBase64,
'X-BFX-SIGNATURE': sig
}
}
try {
const resp = await fetch(url, reqOpts)
if (!resp.ok && +resp.status !== 400) {
throw new Error(`HTTP code ${resp.status} ${resp.statusText || ''}`)
}
const json = await resp.json()
return this._parse_req_body(json, cb)
} catch (err) {
return cb(err)
}
}
/**
* @param {string} path
* @param {Method} cb
* @private
*/
async make_public_request (path, cb) {
if (!path) {
return cb(new Error('path is missing'))
}
const url = `${this._url}/v1/${path}`
debug('GET %s', url)
const reqOpts = {
method: 'GET',
agent: this._agent,
timeout: 15000
}
try {
const resp = await fetch(url, reqOpts)
if (!resp.ok && +resp.status !== 400) {
throw new Error(`HTTP code ${resp.status} ${resp.statusText || ''}`)
}
const json = await resp.json()
return this._parse_req_body(json, cb)
} catch (err) {
return cb(err)
}
}
/**
* @param {string} symbol
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-ticker
*/
ticker (symbol = 'BTCUSD', cb) {
if (!cb) {
cb = (err, data) => {
if (err) {
console.error(err)
}
console.log(data)
}
}
return this.make_public_request(`pubticker/${symbol}`, cb)
}
/**
* @param {string} symbol
* @param {Method} cb
*/
today (symbol, cb) {
return this.make_public_request(`today/${symbol}`, cb)
}
/**
* @param {string} symbol
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-stats
*/
stats (symbol, cb) {
return this.make_public_request(`stats/${symbol}`, cb)
}
/**
* @param {string} currency
* @param {Object} options
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-fundingbook
*/
fundingbook (currency, options, cb) {
let uri = `lendbook/${currency}`
if (typeof options === 'function') {
cb = options
} else {
const keys = Object.keys(options)
for (let i = 0; i < keys.length; i++) {
uri += `${i === 0 ? '/?' : '&'}${keys[i]}=${options[keys[i]]}`
}
}
return this.make_public_request(uri, cb)
}
/**
* @param {string} symbol
* @param {Object} options
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-orderbook
*/
orderbook (symbol, options, cb) {
let uri = `book/${symbol}`
if (typeof options === 'function') {
cb = options
} else {
const keys = Object.keys(options)
for (let i = 0; i < keys.length; i++) {
uri += `${i === 0 ? '/?' : '&'}${keys[i]}=${options[keys[i]]}`
}
}
return this.make_public_request(uri, cb)
}
/**
* @param {string} symbol
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-trades
*/
trades (symbol, cb) {
return this.make_public_request('trades/' + symbol, cb)
}
/**
* @param {string} symbol
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-lends
*/
lends (currency, cb) {
return this.make_public_request('lends/' + currency, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-symbols
*/
get_symbols (cb) {
return this.make_public_request('symbols', cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-public-symbol-details
*/
symbols_details (cb) {
return this.make_public_request('symbols_details', cb)
}
/**
* @param {string} symbol
* @param {number} amount
* @param {number} price
* @param {string} exchange
* @param {string} side
* @param {string} type
* @param {boolean} is_hidden
* @param {boolean} postOnly
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-new-order
*/
new_order (symbol, amount, price, exchange, side, type, is_hidden, postOnly, cb) {
if (typeof is_hidden === 'function') {
cb = is_hidden
is_hidden = false
}
if (typeof postOnly === 'function') {
cb = postOnly
postOnly = false
}
const params = {
symbol,
amount,
price,
exchange,
side,
type
}
if (postOnly) params.post_only = true
if (is_hidden) params.is_hidden = true
return this.make_request('order/new', params, cb)
}
/**
* @param {Object[]} orders
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-multiple-new-orders
*/
multiple_new_orders (orders, cb) {
return this.make_request('order/new/multi', { orders }, cb)
}
/**
* @param {number} order_id
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-cancel-order
*/
cancel_order (order_id, cb) {
return this.make_request('order/cancel', {
order_id: parseInt(order_id)
}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-cancel-all-orders
*/
cancel_all_orders (cb) {
return this.make_request('order/cancel/all', {}, cb)
}
/**
* @param {number[]} order_ids
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-cancel-multiple-orders
*/
cancel_multiple_orders (order_ids, cb) {
return this.make_request('order/cancel/multi', {
order_ids: order_ids.map(id => parseInt(id))
}, cb)
}
/**
* @param {number} order_id
* @param {string} symbol
* @param {number} amount
* @param {number} price
* @param {string} exchange
* @param {string} side
* @param {string} type
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-replace-order
*/
replace_order (order_id, symbol, amount, price, exchange, side, type, cb) {
return this.make_request('order/cancel/replace', {
order_id: parseInt(order_id),
symbol,
amount,
price,
exchange,
side,
type
}, cb)
}
/**
* @param {string} order_id
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-order-status
*/
order_status (order_id, cb) {
return this.make_request('order/status', {
order_id: parseInt(order_id)
}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-active-orders
*/
active_orders (cb) {
return this.make_request('orders', {}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-orders-history
*/
orders_history (cb) {
return this.make_request('orders/hist', {}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-active-positions
*/
active_positions (cb) {
return this.make_request('positions', {}, cb)
}
/**
* @param {string} position_id
* @param {number} amount
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-claim-position
*/
claim_position (position_id, amount, cb) {
return this.make_request('position/claim', {
position_id: parseInt(position_id),
amount
}, cb)
}
/**
* @param {string} currency
* @param {Object} options
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-balance-history
*/
balance_history (currency, options, cb) {
const params = { currency }
if (typeof options === 'function') {
cb = options
} else if (options && options.constructor.name === 'Object') {
Object.assign(params, options)
}
return this.make_request('history', params, cb)
}
/**
* @param {string} currency
* @param {Object} options
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-deposit-withdrawal-history
*/
movements (currency, options, cb) {
const params = { currency }
if (typeof options === 'function') {
cb = options
} else if (options && options.constructor.name === 'Object') {
Object.assign(params, options)
}
return this.make_request('history/movements', params, cb)
}
/**
* @param {string} symbol
* @param {Object} options
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-past-trades
*/
past_trades (symbol, options, cb) {
const params = { symbol }
if (typeof options === 'function') {
cb = options
} else if (options && options.constructor.name === 'Object') {
Object.assign(params, options)
}
return this.make_request('mytrades', params, cb)
}
/**
* @param {string} currency
* @param {string} method
* @param {string} wallet_name
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-deposit
*/
new_deposit (currency, method, wallet_name, cb) {
return this.make_request('deposit/new', {
currency,
method,
wallet_name
}, cb)
}
/**
* @param {string} currency
* @param {number} amount
* @param {number} rate
* @param {number} period
* @param {string} direction
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-new-offer
*/
new_offer (currency, amount, rate, period, direction, cb) {
return this.make_request('offer/new', {
currency,
amount,
rate,
period,
direction
}, cb)
}
/**
* @param {string} offer_id
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-cancel-offer
*/
cancel_offer (offer_id, cb) {
return this.make_request('offer/cancel', {
offer_id: parseInt(offer_id)
}, cb)
}
/**
* @param {string} offer_id
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-offer-status
*/
offer_status (offer_id, cb) {
return this.make_request('offer/status', {
offer_id: parseInt(offer_id)
}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-offers
*/
active_offers (cb) {
return this.make_request('offers', {}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-active-credits
*/
active_credits (cb) {
return this.make_request('credits', {}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-wallet-balances
*/
wallet_balances (cb) {
return this.make_request('balances', {}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-active-funding-used-in-a-margin-position
*/
taken_swaps (cb) {
return this.make_request('taken_funds', {}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-total-taken-funds
*/
total_taken_swaps (cb) {
return this.make_request('total_taken_funds', {}, cb)
}
/**
* @param {string} swap_id
* @param {Method} cb
*/
close_swap (swap_id, cb) {
return this.make_request('swap/close', {
swap_id: parseInt(swap_id)
}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-account-info
*/
account_infos (cb) {
return this.make_request('account_infos', {}, cb)
}
/**
* @param {Method} cb
* @see https://docs.bitfinex.com/v1/reference#rest-auth-margin-information
*/
margin_infos (cb) {
return this.make_request('margin_infos', {}, cb)
}
/**
* POST /v1/withdraw
*
* @param {string} withdrawType "bitcoin", "litecoin", "darkcoin" or "mastercoin"
* @param {string} walletSelected origin of the wallet to withdraw from, can be "trading", "exchange", or "deposit"
* @param {number} amount amount to withdraw
* @param {string} address destination address for withdrawal
*/
withdraw (withdrawType, walletSelected, amount, address, cb) {
return this.make_request('withdraw', {
withdrawType,
walletSelected,
amount,
address
}, cb)
}
/**
* POST /v1/transfer
*
* @param {number} amount amount to transfer
* @param {string} currency currency of funds to transfer
* @param {string} walletFrom wallet to transfer from
* @param {string} walletTo wallet to transfer to
*/
transfer (amount, currency, walletFrom, walletTo, cb) {
return this.make_request('transfer', {
amount,
currency,
walletFrom,
walletTo
}, cb)
}
}
module.exports = RESTv1
</code></pre>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Sep 17 2024 00:34:07 GMT+0200 (Central European Summer Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/search.js" defer></script>
</body>
</html>