UNPKG

bfx-api-node-rest

Version:
143 lines (91 loc) 16.6 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Home - 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"> <section class="package"> <h3> </h3> </section> <section class="readme usertext"> <article><h1>Bitfinex RESTv1 &amp; RESTv2 APIs for Node.JS</h1> <p>A Node.JS reference implementation of the Bitfinex REST APIs</p> <p>To use, construct a new instance of either the <code>RESTv1</code> or <code>RESTv2</code> classes. All API methods return promises and accept a callback as the last parameter; the callback will be called with <code>(error, response)</code>.</p> <p>To minimize the data sent over the network the transmitted data is structured in arrays. In order to reconstruct key / value pairs, set <code>opts.transform</code> to <code>true</code> when creating an interface.</p> <h3>Features</h3> <ul> <li>Official implementation</li> <li>REST v2 API</li> <li>REST v1 API</li> </ul> <h2>Installation</h2> <pre class="prettyprint source lang-bash"><code> npm i --save bfx-api-node-rest </code></pre> <h3>Quickstart</h3> <pre class="prettyprint source lang-js"><code>const { RESTv2 } = require('bfx-api-node-rest') const rest = new RESTv2({ transform: true }) // do something with the RESTv2 instance </code></pre> <h3>Docs</h3> <p>Documentation at <a href="https://docs.bitfinex.com/v2/reference">https://docs.bitfinex.com/v2/reference</a></p> <h2>Example</h2> <pre class="prettyprint source lang-js"><code>const { RESTv2 } = require('bfx-api-node-rest') const rest = new RESTv2({ apiKey: '...', apiSecret: '...', authToken: '...', // optional, has priority over API key/secret url: '...', // optional transform: true, // to have full models returned by all methods agent: null, // optional proxy agent }) rest.candles({ timeframe: '1m', symbol: 'tBTCUSD', query: { start: Date.now() - (24 * 60 * 60 * 1000), end: Date.now(), limit: 1000, } }).then((candles) => { // ... }).catch((err) => { console.log(err) }) </code></pre> <h2>FAQ</h2> <h3>nonce too small</h3> <p>I make multiple parallel request and I receive an error that the nonce is too small. What does it mean?</p> <p>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.</p> <p>If you need to go parallel, you have to use multiple API keys right now.</p></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>