Skip to content
Brent Kirkland edited this page Dec 15, 2017 · 18 revisions

v1 REST API

Here is some documentation that will help you along your way. If you would like to read more, visit the Bitfinex Docs

Install

Install bitfinex-api-node via npm:

npm install bitfinex-api-node

new BFX(APIKey, APISecret, opts).rest

Param Type Description
APIKey string Your BFX API Key
APISecret string Your BFX Secret Key
Opts object opts = {version: 1}

where Opts consists of:

const opts = {
  version: 1 // for v1
}

BFX.ticker(pair, cb)

Param Type Description
pair string BTCUSD, LTCUSD, ETHUSD...
cb function callback of error, result

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.ticker('BTCUSD', (err, data) => {
  if (err) console.log(err)
  console.log('Ticker:', data)
})

BFX.stats(pair, cb)

Param Type Description
pair string BTCUSD, LTCUSD, ETHUSD...
cb function callback of error, result

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.stats('BTCUSD', (err, data) => {
  if (err) console.log(err)
  console.log('Stats:', data)
})

BFX.fundingbook(currency, {options}, cb)

Param Type Description
currency string USD, GBP, JPY
options sting i.e. options = {'limit_asks': 2, 'limit_bids': 2}.
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
const options = {'limit_asks': 30, 'limit_bids': 30}
bfxRest.fundingbook('USD', options, (err, data) => {
  if (err) console.log(err)
  console.log('Funding Book:', data)
})

BFX.orderbook(pair, cb)

Param Type Description
pair string BTCUSD, ETHUSD, LTCUSD
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.orderbook('BTCUSD', (err, data) => {
  if (err) console.log(err)
  console.log('Orderbook:', data)
})

BFX.trades(currency, cb)

Param Type Description
currency string USD, GBP, JPY
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.trades('USD', (err, data) => {
  if (err) console.log(err)
  console.log('Trades:', data)
})

BFX.lends(pair, cb)

Param Type Description
pair string BTCUSD, ETHUSD, LTCUSD
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.lends('BTCUSD', (err, data) => {
  if (err) console.log(err)
  console.log('Lends:', data)
})

BFX.get_symbols(cb)

Param Type Description
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.get_symbols((err, data) => {
  if (err) console.log(err)
  console.log('Symbols:', data)
})

BFX.symbols_details(cb)

Param Type Description
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.symbols_details((err, data) => {
  if (err) console.log(err)
  console.log('Symbols Details:', data)
})

BFX.account_infos(cb)

Param Type Description
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.account_infos((err, data) => {
  if (err) console.log(err)
  console.log('Symbols Details:', data)
})

BFX.account_fees

NOT IMPLEMENTED

BFX.summary

NOT IMPLEMENTED

BFX.new_deposit(currency, method, wallet, cb)

** DOC DISCREPENCY ** will look into this! currency should not be there

Param Type Description
currency string BTC
method string bitcoin, litecoin, ethereum, ...
wallet string trading, exchange, deposit, ...
cb function callback with error, result as params

Example:

const bfxRest = new BFX(apiKey, apiSecretKey, opts).rest
bfxRest.new_deposit('BTC', 'deposit', 'exchange', (err, data) => {
  if (err) console.log(err)
  console.log('Symbols Details:', data)
})

BFX.key_permissions

NOT IMPLEMENTED

BFX.margin_infos(cb)

Param Type Description
cb function callback with error, result as params

Example:

// or use bitfinex-api-node
const BFX = require('bitfinex-api-node')
const bfxRest = new BFX(apiKey, apiSecretKey, {version: 1}).rest
bfxRest.margin_infos((err, res) => {
  if (err) console.log(err)
  console.log(result)
})

BFX.wallet_balances(cb)

NEED TO TEST ON PRODUCTION

Param Type Description
cb function callback with error, result as params

Example:

// or use bitfinex-api-node
const BFX = require('bitfinex-api-node')
const bfxRest = new BFX(apiKey, apiSecretKey, {version: 1}).rest
bfxRest.wallet_balances((err, res) => {
  if (err) console.log(err)
  console.log(result)
})

BFX.transfer(amount, currency, walletfrom, walletto, cb)

NEED TO TEST ON PRODUCTION

Param Type Description
amount decimal string '1.0', '26'...
currency string BTC, USD ...
walletfrom string exchange, trading, deposit
walletto string exchange, trading, deposit
cb function callback with error, result as params

Example:

// or use bitfinex-api-node
const BFX = require('bitfinex-api-node')
const bfxRest = new BFX(apiKey, apiSecretKey, {version: 1}).rest
bfxRest.transfer((err, res) => {
  if (err) console.log(err)
  console.log(result)
})

BFX.withdraw(withdraw_type, walletselected, amount, address, cb)

Param Type Description
withdraw_type string 'bitcoin', 'ethereum', ...
walletselected string 'exchange', 'trading', 'desposit'
amount decimal string '1000.1'
walletto string '1DKwqRhDmVyHJDL4FUYpDmQMYA3Rsxtvur'
cb function callback with error, result as params

Example:

const BFX = require('bitfinex-api-node')
const bfxRest = new BFX(apiKey, apiSecretKey, {version: 1}).rest
bfxRest.withdraw(withdraw_type, walletselected, amount, address, (err, res) => {
  if (err) console.log(err)
  console.log(result)
})

BFX.new_order(symbol, amount, price, exchange, side, type, is_hidden, postOnly, cb)

Param Type Description
symbol string 'BTCUSD', 'LTCUSD', ...
amount decimal string '1.0'
price decimal string '1000.1'
exchange string 'bitfinex'
side string 'buy' or 'sell'
type string 'market', 'limit', 'stop', 'trailing-stop', 'fill-or-kill', 'exchange market', 'exchange stop', 'exchange trailing-stop'
is_hidden boolean true or false. is optional
postOnly boolean true or false. is optional
cb function callback with error, result as params

Example:

const BFX = require('bitfinex-api-node')
const bfxRest = new BFX(apiKey, apiSecretKey, {version: 1}).rest
bfxRest.new_order('BTCUSD', '1.269', '1000', 'bitfinex', 'sell', 'exchange market', (err, res) => {
  if (err) console.log(err)
  console.log(result)
})

BFX.multiple_new_orders(orders, cb)

Param Type Description
orders array An array of orders. Use BFX.new_order to see order params
cb function callback with error, result as params

Example:

const BFX = require('bitfinex-api-node')
const bfxRest = new BFX(apiKey, apiSecretKey, {version: 1}).rest

const orderOne = {
  symbol: 'BTCUSD',
  amount: '0.011',
  price: '1000',
  exchange: 'bitfinex',
  side: 'buy',
  type: 'exchange market'
}

const orderTwo = {
  symbol: 'BTCUSD',
  amount: '0.022',
  price: '1000',
  exchange: 'bitfinex',
  side: 'buy',
  type: 'exchange market'
}
const orderThree = {
  symbol: 'BTCUSD',
  amount: '0.033',
  price: '1000',
  exchange: 'bitfinex',
  side: 'buy',
  type: 'exchange market'
}
const orders = [orderOne, orderTwo, orderThree]

bfxRest.multiple_new_orders(orders, (err, res) => {
  if (err) console.log(err)
  console.log(result)
})

BFX.cancel_order(id, cb)

Param Type Description
id integer Order ID
cb function callback with error, result as params
bfxRest.cancel_order(order.id, (err, res) => {
  if (err) console.log(err)
  console.log(res)
})