Introduction

The Bitfinex API’s are designed to allow access to all of the features of the Bitfinex platform. The end goal is to allow people to potentially recreate the entire platform on their own.

If you would like to suggest changes to the documentation, please see the github at https://github.com/bitfinexcom/api_docs

Open Source Libraries

The following open source projects are works in progress. We will be continually improving them, but we want to release them early so that the community can take a look, make use of them, and offer pull requests. Nothing in the Bitcoin world exists in isolation.

Get Started    
Suggest Edits

Tickers

The ticker is a high level overview of the state of the market. It shows you the current best bid and ask, as well as the last trade price. It also includes information such as daily volume and how much the price has moved over the last day.

 
gethttps://api.bitfinex.com/v2/tickers
// Raw Javascript - replace symbol for other tickers
request.get( 
  `${url}/tickers?symbols=tBTCUSD,tLTCUSD,fUSD`,
  (error, response, body) => console.log(body)
)
curl https://api.bitfinex.com/v2/ticker/tBTCUSD
A binary file was returned
[
  // on trading pairs (ex. tBTCUSD)
  [
    SYMBOL,
    BID, 
    BID_SIZE, 
    ASK, 
    ASK_SIZE, 
    DAILY_CHANGE, 
    DAILY_CHANGE_PERC, 
    LAST_PRICE, 
    VOLUME, 
    HIGH, 
    LOW
  ],
  // on funding currencies (ex. fUSD)
  [
    SYMBOL,
    FRR, 
    BID, 
    BID_SIZE, 
    BID_PERIOD,
    ASK, 
    ASK_SIZE,
    ASK_PERIOD,
    DAILY_CHANGE,
    DAILY_CHANGE_PERC, 
    LAST_PRICE,
    VOLUME,
    HIGH, 
    LOW
  ],
  ...
]
{
  "message": "Unknown symbol"
}

Query Params

symbols
string

The symbols you want information about. ex: tBTCUSD,fUSD

 

Response Details

Fields Type Description
FRR float Flash Return Rate - average of all fixed rate funding over the last hour
BID float Price of last highest bid
BID_SIZE float Size of the last highest bid
BID_PERIOD int Bid period covered in days
ASK float Price of last lowest ask
ASK_SIZE float Size of the last lowest ask
ASK_PERIOD int Ask period covered in days
DAILY_CHANGE float Amount that the last price has changed since yesterday
DAILY_CHANGE_PERC float Amount that the price has changed expressed in percentage terms
LAST_PRICE float Price of the last trade
VOLUME float Daily volume
HIGH float Daily high
LOW float Daily low
Suggest Edits

Ticker

The ticker is a high level overview of the state of the market. It shows you the current best bid and ask, as well as the last trade price. It also includes information such as daily volume and how much the price has moved over the last day.

 
gethttps://api.bitfinex.com/v2/ticker/Symbol
// Raw Javascript - replace symbol for other tickers
request.get( 
  `${url}/ticker/tBTCUSD`,
  (error, response, body) => console.log(body)
)

// Javascript Client - replace symbol for other tickers
bfx.rest.ticker('tBTCUSD', cb)
curl https://api.bitfinex.com/v2/ticker/tBTCUSD
A binary file was returned
// on trading pairs (ex. tBTCUSD)
[
  BID, 
  BID_SIZE, 
  ASK, 
  ASK_SIZE, 
  DAILY_CHANGE, 
  DAILY_CHANGE_PERC, 
  LAST_PRICE, 
  VOLUME, 
  HIGH, 
  LOW
]

// on funding currencies (ex. fUSD)
[
  FRR, 
  BID, 
  BID_SIZE, 
  BID_PERIOD,
  ASK, 
  ASK_SIZE,
  ASK_PERIOD,
  DAILY_CHANGE,
  DAILY_CHANGE_PERC, 
  LAST_PRICE,
  VOLUME,
  HIGH, 
  LOW
]
{
  "message": "Unknown symbol"
}

Path Params

Symbol
string
required

The symbol you want information about. You can find the list of valid symbols by calling the /symbols endpoint.

 

Response Details

Fields Type Description
FRR float Flash Return Rate - average of all fixed rate funding over the last hour
BID float Price of last highest bid
BID_SIZE float Size of the last highest bid
BID_PERIOD int Bid period covered in days
ASK float Price of last lowest ask
ASK_SIZE float Size of the last lowest ask
ASK_PERIOD int Ask period covered in days
DAILY_CHANGE float Amount that the last price has changed since yesterday
DAILY_CHANGE_PERC float Amount that the price has changed expressed in percentage terms
LAST_PRICE float Price of the last trade
VOLUME float Daily volume
HIGH float Daily high
LOW float Daily low
Suggest Edits

Trades

Trades endpoint includes all the pertinent details of the trade, such as price, size and time.

 
gethttps://api.bitfinex.com/v2/trades/Symbol/hist
// Raw Javascript - replace symbol for other pairs
request.get( 
  `${url}/trades/tBTCUSD`,
  (error, response, body) => console.log(body)
)

// Javascript Client - replace symbol for other pairs
bfx.rest.ticker('tBTCUSD', cb)
curl https://api.bitfinex.com/v2/ticker/tBTCUSD
A binary file was returned
// on trading pairs (ex. tBTCUSD)
[
  [
    ID,
    MTS,
    AMOUNT,
    PRICE
  ]
]


// on funding currencies (ex. fUSD)
[
  [
    ID,
    MTS,
    AMOUNT,
    RATE,
    PERIOD
  ]
]
{
  "message": "Unknown symbol"
}

Path Params

Symbol
string
required

The symbol you want information about.

Query Params

limit
int32

Number of records

start
int32

Millisecond start time

end
int32

Millisecond end time

sort
int32

if = 1 it sorts results returned with old > new

 

Response Details

Fields Type Description
MTS int millisecond time stamp
±AMOUNT float How much was bought (positive) or sold (negative).
PRICE float Price at which the trade was executed
RATE float Rate at which funding transaction occurred
PERIOD int Amount of time the funding transaction was for

The order that causes the trade determines if it is a buy or a sell.

Suggest Edits

Books

The Order Books channel allow you to keep track of the state of the Bitfinex order book.
It is provided on a price aggregated basis, with customizable precision.

 
gethttps://api.bitfinex.com/v2/book/Symbol/Precision
// Raw Javascript - replace symbol for other tickers
request.get( 
  `${url}/book/tBTCUSD/P0`,
  (error, response, body) => console.log(body)
)

// Javascript Client - replace symbol for other tickers
bfx.rest.ticker('tBTCUSD', cb)
curl https://api.bitfinex.com/v2/ticker/tBTCUSD
A binary file was returned
// on trading pairs (ex. tBTCUSD)
[
  [
    PRICE,
    COUNT,
    AMOUNT
  ]
]

// on funding currencies (ex. fUSD)
[
  [
    RATE,
    PERIOD,
    COUNT,
    AMOUNT
  ]
]
{
  "message": "Unknown symbol"
}

Path Params

Symbol
string
required

The symbol you want information about. You can find the list of valid symbols by calling the /symbols endpoint.

Precision
string
required

Level of price aggregation (P0, P1, P2, P3, R0)

Query Params

len
int32

Number of price points ("25", "100")

 

Response Details

Fields Type Description
PRICE float Price level
RATE float Rate level
PERIOD float Period level (Funding only)
COUNT int Number of orders at that price level
±AMOUNT float Total amount available at that price level.

For Trading: if AMOUNT > 0 then bid else ask.
For Funding: if AMOUNT > 0 then ask else bid.

Suggest Edits

Stats

Various statistics about the requested pair.

 
gethttps://api.bitfinex.com/v2/stats1/Key::Size::Symbol/Section
request.get(
  `${url}/stats1/pos.size:1m:tBTCUSD:long/last`,
  (error, response, body) => console.log(body)
)

request.get(
  `${url}/stats1/pos.size:1m:tBTCUSD:long/hist`,
  (error, response, body) => console.log(body)
)
curl https://api.bitfinex.com/v2/stats1/pos.size:1m:tBTCUSD:long/last

curl https://api.bitfinex.com/v2/stats1/pos.size:1m:tBTCUSD:long/hist
A binary file was returned
// response with Section = "last"
[ 
  MTS,
  VALUE
]

// response with Section = "hist"
[
  [ MTS, VALUE ],
  ...
]

Path Params

Key
string
required

Allowed values: "funding.size", "credits.size", "credits.size.sym", "pos.size"

Size
string
required

Available values: '1m'

Symbol
string
required

The symbol you want information about.

Side
string
required

Available values: "long", "short"

Section
string
required

Available values: "last", "hist"

Query Params

sort
int32

if = 1 it sorts results returned with old > new

 

Response Details

Fields Type Description
MTS int millisecond timestamp
VALUE float Total amount

Available Keys

Key Description Arguments Example
pos.size Total Open Position (long / short) :1m :SYM_TRADING :SIDE pos.size:1m:tBTCUSD:long , pos.size:1m:tBTCUSD:short
funding.size Total Active Funding :1m :SYM_FUNDING funding.size:1m:fUSD
credits.size Active Funding used in positions :1m :SYM_FUNDING credits.size:1m:fUSD
credits.size.sym Active Funding used in positions (per trading symbol) :1m :SYM_FUNDING :SYM_TRADING credits.size.sym:1m:fUSD:tBTCUSD
Suggest Edits

Candles

Provides a way to access charting candle info

 
gethttps://api.bitfinex.com/v2/candles/trade:TimeFrame::Symbol/Section
request.get(
  `${url}/candles/trade:1m:tBTCUSD/last`,
  (error, response, body) => console.log(body)
)

request.get(
  `${url}/candles/trade:1m:tBTCUSD/hist`,
  (error, response, body) => console.log(body)
)
curl https://api.bitfinex.com/v2/candles/trade:1m:tBTCUSD/last

curl https://api.bitfinex.com/v2/candles/trade:1m:tBTCUSD/hist
A binary file was returned
// response with Section = "last"
[ 
  MTS, 
  OPEN, 
  CLOSE, 
  HIGH, 
  LOW, 
  VOLUME 
]

// response with Section = "hist"
[
  [ MTS, OPEN, CLOSE, HIGH, LOW, VOLUME ], 
  ...
]

Path Params

TimeFrame
string
required

Available values: '1m', '5m', '15m', '30m', '1h', '3h', '6h', '12h', '1D', '7D', '14D', '1M'

Symbol
string
required

The symbol you want information about.

Section
string
required

Available values: "last", "hist"

Query Params

limit
int32

Number of candles requested

start
string

Filter start (ms)

end
string

Filter end (ms)

sort
int32

if = 1 it sorts results returned with old > new

 

Response Details

Fields Type Description
MTS int millisecond time stamp
OPEN float First execution during the time frame
CLOSE float Last execution during the time frame
HIGH float Highest execution during the time frame
LOW float Lowest execution during the timeframe
VOLUME float Quantity of symbol traded within the timeframe

Available Keys

Key Description Arguments Example
trade Trading Candles :TF :SYM_TRADING trade :1m :tBTCUSD
trade Funding Candles :TF :sym_funding:pPERIOD trade :1m :fUSD :p30
trade Aggregate Funding Candles (AGGR=[10,30]) :TF :SYM_FUNDING :aAGGR :pPER_START :p :PER_END trade :1m :fUSD :a10 :p2 :p10 , trade :1m :fUSD :a10 :p11 :p20 , trade :1m :fUSD :a10 :p21 :p30 , trade :1m :fUSD :a30 :p2 :p30
Suggest Edits

Market Average Price

Calculate the average execution rate for Trading or Margin funding.

 
posthttps://api.bitfinex.com/v2/calc/trade/avg
curl --request POST \
  --url https://api.bitfinex.com/v2/calc/trade/avg
var request = require("request");

var options = { method: 'POST',
  url: 'https://api.bitfinex.com/v2/calc/trade/avg' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.bitfinex.com/v2/calc/trade/avg")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.bitfinex.com/v2/calc/trade/avg");

xhr.send(data);
import requests

url = "https://api.bitfinex.com/v2/calc/trade/avg"

response = requests.request("POST", url)

print(response.text)
A binary file was returned
[RATE_AVG, AMOUNT]

Query Params

symbol
string

The symbol you want information about.

amount
string

Amount. Positive for buy, negative for sell (ex. "1.123")

period
int32

(optional) Maximum period for Margin Funding

rate_limit
string

Limit rate/price (ex. "1000.5")

 
Suggest Edits

Wallets

Get account wallets

 
posthttps://api.bitfinex.com/v2/auth/r/wallets
request.post(
  `${url}/auth/r/wallets`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  [
    WALLET_TYPE, 
    CURRENCY, 
    BALANCE, 
    UNSETTLED_INTEREST,
    BALANCE_AVAILABLE,
    ...
  ], 
  ...
]
 

Fields

Term Type Description
WALLET_TYPE string Wallet name (exchange, trading, deposit)
CURRENCY string Currency (fUSD, etc)
BALANCE float Wallet balance
UNSETTLED_INTEREST float Unsettled interest
BALANCE_AVAILABLE float / null Amount not tied up in active orders, positions or funding (null if the value is not fresh enough).
Suggest Edits

Orders

Get active orders

 
posthttps://api.bitfinex.com/v2/auth/r/orders
request.post(
  `${url}/auth/r/orders`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  [
    ID, 
    GID,
    CID,
    SYMBOL, 
    MTS_CREATE, 
    MTS_UPDATE, 
    AMOUNT, 
    AMOUNT_ORIG, 
    TYPE,
    TYPE_PREV,
    _PLACEHOLDER,
    _PLACEHOLDER,
    FLAGS,
    STATUS,
    _PLACEHOLDER,
    _PLACEHOLDER,
    PRICE,
    PRICE_AVG,
    PRICE_TRAILING,
    PRICE_AUX_LIMIT,
    _PLACEHOLDER,
    _PLACEHOLDER,
    _PLACEHOLDER,
    NOTIFY, 
    HIDDEN, 
    PLACED_ID,
    ...
  ],
  ...
]
 

Stream Fields

Term Type Description
ID int64 Order ID
GID int Group ID
CID int Client Order ID
SYMBOL string Pair (tBTCUSD, …)
MTS_CREATE int Millisecond timestamp of creation
MTS_UPDATE int Millisecond timestamp of update
AMOUNT float Positive means buy, negative means sell.
AMOUNT_ORIG float Original amount
TYPE string The type of the order: LIMIT, MARKET, STOP, TRAILING STOP, EXCHANGE MARKET, EXCHANGE LIMIT, EXCHANGE STOP, EXCHANGE TRAILING STOP, FOK, EXCHANGE FOK.
TYPE string Previous order type
FLAGS int Upcoming Params Object (stay tuned)
ORDER_STATUS string Order Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
PRICE float Price
PRICE_AVG float Average price
PRICE_TRAILING float The trailing price
PRICE_AUX_LIMIT float Auxiliary Limit price (for STOP LIMIT)
NOTIFY int 1 if Notify flag is active, 0 if not
HIDDEN int 1 if Hidden, 0 if not hidden
PLACED_ID int If another order caused this order to be placed (OCO) this will be that other order's ID
Suggest Edits

Order Trades

Get Trades generated by an Order

 
posthttps://api.bitfinex.com/v2/auth/r/order/SymbolOrderId/trades
request.post(
  `${url}/auth/r/order/tBTCUSD:12345/trades`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  [
    ID, 
    PAIR, 
    MTS_CREATE, 
    ORDER_ID, 
    EXEC_AMOUNT, 
    EXEC_PRICE, 
    ORDER_TYPE, 
    ORDER_PRICE, 
    MAKER,
    FEE, 
    FEE_CURRENCY, 
    ...
  ],
  ...
]

Path Params

Symbol:OrderId
string
required
 

Fields

Term Type Description
ID integer Trade database id
PAIR string Pair (BTCUSD, …)
MTS_CREATE integer Execution timestamp
ORDER_ID integer Order id
EXEC_AMOUNT float Positive means buy, negative means sell
EXEC_PRICE float Execution price
ORDER_TYPE string Order type
ORDER_PRICE float Order price
MAKER int 1 if true, 0 if false
FEE float Fee
FEE_CURRENCY string Fee currency
Suggest Edits

Positions

Get active positions

 
posthttps://api.bitfinex.com/v2/auth/r/positions
request.post(
  `${url}/auth/positions`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  [
    SYMBOL, 
    STATUS, 
    AMOUNT, 
    BASE_PRICE, 
    MARGIN_FUNDING, 
    MARGIN_FUNDING_TYPE,
    PL,
    PL_PERC,
    PRICE_LIQ,
    LEVERAGE
    ...
  ], 
  ...
]
 

Fields

Term Type Description
SYMBOL string Pair (tBTCUSD, …).
STATUS string Status (ACTIVE, CLOSED).
±AMOUNT float Size of the position. Positive values means a long position, negative values means a short position.
BASE_PRICE float The price at which you entered your position.
MARGIN_FUNDING float The amount of funding being used for this position.
MARGIN_FUNDING_TYPE int 0 for daily, 1 for term.
PL float Profit & Loss
PL_PERC float Profit & Loss Percentage
PRICE_LIQ float Liquidation price
LEVERAGE float Beta value
Suggest Edits

Offers

Get active offers

 
posthttps://api.bitfinex.com/v2/auth/r/offers
request.post(
  `${url}/auth/r/offers`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  [
    ID,
    SYMBOL,
    MTS_CREATED,
    MTS_UPDATED,
    AMOUNT,
    AMOUNT_ORIG,
    TYPE,
    _PLACEHOLDER,
    _PLACEHOLDER,
    FLAGS,
    STATUS,
    _PLACEHOLDER,
    _PLACEHOLDER,
    _PLACEHOLDER,
    RATE,
    PERIOD,
    NOTIFY,
    HIDDEN,
    _PLACEHOLDER,
    RENEW,
    RATE_REAL,
    ...
  ],
  ...
]
 

Fields

Term Type Description
ID integer Offer ID
SYMBOL string The currency of the offer (fUSD, etc)
MTS_CREATED int Millisecond Time Stamp when the offer was created
MSG_UPDATED int Millisecond Time Stamp when the offer was created
AMOUNT float Amount the offer is for
AMOUNT_ORIG float Amount the offer was entered with originally
TYPE string "lend" or "loan"
FLAGS object future params object (stay tuned)
STATUS string Offer Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
RATE float Rate of the offer
PERIOD int Period of the offer
NOTIFY int 0 if false, 1 if true
HIDDEN int 0 if false, 1 if true
INSURE int 0 if false, 1 if true
RENEW int 0 if false, 1 if true
RATE_REAL float the calculated rate for FRR and FRRDELTAFIX
Suggest Edits

Margin Info

Get account margin info

 
posthttps://api.bitfinex.com/v2/auth/r/margin/key
// margin base
request.post(
  `${url}/auth/r/margin/base`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)

// margin symbol
request.post(
  `${url}/auth/r/margin/tBTCUSD`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
// margin base
[
  "base",
  [
    USER_PL, 
    USER_SWAPS, 
    MARGIN_BALANCE, 
    MARGIN_NET,
    ...
  ]
]
  
// margin symbol
[
  "sym",
  "tBTCUSD",
  [
    TRADABLE_BALANCE,
    ...
  ]
]

Path Params

key
string
required

"base" | SYMBOL

 

Stream Fields

Term Type Description
SYMBOL string Symbol
USER_PL float User Profit and Loss
USER_SWAPS float Amount of swaps a user has
SYMBOL string The symbol the information pertains to
TRADABLE_BALANCE float Your buying power (how large a position you can obtain)
MARGIN_BALANCE float Balance in your margin funding account
MARGIN_NET float Balance after P&L is accounted for
Suggest Edits

Funding Info

Get account funding info

 
posthttps://api.bitfinex.com/v2/auth/r/funding/key
request.post(
  `${url}/auth/r/funding/fUSD`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  "sym", 
  SYMBOL, 
  [
    YIELD_LOAN,
    YIELD_LEND,
    DURATION_LOAN,
    DURATION_LEND,
    ...
  ],
  ...
]

Path Params

key
string
required

SYMBOL

 

Stream Fields

Term Type Description
SYMBOL string The symbol the information pertains to (funding currencies)
YIELD_LOAN float Weighted average rate for taken funding
YIELD_LEND float Weighted average rate for provided funding
DURATION_LOAN float Weighted average duration for taken funding
DURATION_LEND float Weighted average duration for provided funding
Suggest Edits

Performance

Get account historical daily performance

 
posthttps://api.bitfinex.com/v2/auth/r/stats/perf:1D/hist
request.post(
  `${url}/auth/r/stats/perf:1D/hist`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  [
    MTS,
    PERFORMANCE
  ],
  ...
]
 

Response Details

Fields Type Description
MTS float Millisecond time stamp
PERFORMANCE float Historical performance
Suggest Edits

Alert List

 
posthttps://api.bitfinex.com/v2/auth/r/alerts
request.post(
  `${url}/auth/r/alerts?type=price`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  [
    'price:tBTCUSD:560.92',
    'price',
    'tBTCUSD',
    560.92,
    91
  ],
  ...
]

Query Params

type
string
required
 
Suggest Edits

Alert Set

Sets up a price alert at the given value

 
posthttps://api.bitfinex.com/v2/auth/w/alert/set
request.post(
  `${url}/auth/w/alert/set`,
  headers: { /* auth headers */ },
  json: {
  	type: 'price',
  	symbol: 'tBTCUSD',
    price: 600
  },
  (error, response, body) => console.log(body)
)
A binary file was returned
[
  'price:tBTCUSD:600', 
  'price', 
  'tBTCUSD', 
  600, 
  100
]

Form Data

type
string
required
symbol
string
required
price
int32
required
 
Suggest Edits

Alert Delete

 
posthttps://api.bitfinex.com/v2/auth/w/alert/price:tBTCUSD::600/del
request.post(
  `${url}/auth/w/alert/price:${symbol}:${price}/del`,
  headers: { /* auth headers */ },
  json: {},
  (error, response, body) => console.log(body)
)
A binary file was returned
Try the API to see results

Path Params

symbol
string
required
price
float
required
 
Suggest Edits

Calc Available Balance

Calculate available balance for order/offer

 
posthttps://api.bitfinex.com/v2/auth/calc/order/avail
request.post(
  `${url}/auth//calc/order/avail`,
  headers: { /* auth headers */ },
  json: {
    symbol: 'tBTCUSD',
    dir: 1, // buy
    rate: 800,
    type: 'EXCHANGE'
  },
  (error, response, body) => console.log(body)
)
A binary file was returned
[AMOUNT_AVAIL]

Query Params

symbol
string

Symbol

dir
int32

direction of the order/offer (orders: > 0 buy, < 0 sell | offers: > 0 sell, < 0 buy)

rate
string

Rate of the order/offer

type
string

Type of the order/offer EXCHANGE or MARGIN

 

Details

Fields Type Description
AMOUNT_AVAIL float Amount available for order/offer
Suggest Edits

Ticker

The ticker is a high level overview of the state of the market. It shows you the current best bid and ask, as well as the last trade price. It also includes information such as daily volume and how much the price has moved over the last day.

 
const ws = require('ws')
const w = new ws('wss://api.bitfinex.com/ws/2')

w.on('message', (msg) => console.log(msg))

let msg = JSON.stringify({ 
  event: 'subscribe', 
  channel: 'ticker', 
  symbol: 'tBTCUSD' 
})

w.on('open', () => w.send(msg))

Stream Fields

Fields Type Description
FRR float Flash Return Rate - average of all fixed rate funding over the last hour
BID float Price of last highest bid
BID_PERIOD integer Bid period covered in days
BID_SIZE float Size of the last highest bid
ASK float Price of last lowest ask
ASK_PERIOD integer Ask period covered in days
ASK_SIZE float Size of the last lowest ask
DAILY_CHANGE float Amount that the last price has changed since yesterday
DAILY_CHANGE_PERC float Amount that the price has changed expressed in percentage terms
LAST_PRICE float Price of the last trade.
VOLUME float Daily volume
HIGH float Daily high
LOW float Daily low
// request
{ 
  event: "subscribe", 
  channel: "ticker", 
  symbol: SYMBOL
}

// response - trading
{
   event: "subscribed",
   channel: "ticker",
   chanId: CHANNEL_ID,
   pair: "BTCUSD"
}

// response - funding
{
  event: "subscribed",
  channel: "fticker",
  chanId: CHANNEL_ID,
  symbol: "USD"
}
// Trading pairs
[
  CHANNEL_ID,
  [
    BID,
    BID_SIZE,
    ASK,
    ASK_SIZE,
    DAILY_CHANGE,
    DAILY_CHANGE_PERC,
    LAST_PRICE,
    VOLUME,
    HIGH,
    LOW
  ]
]

// Funding pairs
[
  CHANNEL_ID,
  [
    FRR,
    BID,
    BID_PERIOD,
    BID_SIZE,
    ASK,
    ASK_PERIOD,
    ASK_SIZE,
    DAILY_CHANGE,
    DAILY_CHANGE_PERC,
    LAST_PRICE,
    VOLUME,
    HIGH,
    LOW
  ]
]
// Trading pairs
[
  CHANNEL_ID,
  [
    BID,
    BID_SIZE,
    ASK,
    ASK_SIZE,
    DAILY_CHANGE,
    DAILY_CHANGE_PERC,
    LAST_PRICE,
    VOLUME,
    HIGH,
    LOW
  ]
]

// Funding pairs
[
  CHANNEL_ID,
  [
    FRR,
    BID,
    BID_PERIOD,
    BID_SIZE,
    ASK,
    ASK_PERIOD,
    ASK_SIZE,
    DAILY_CHANGE,
    DAILY_CHANGE_PERC,
    LAST_PRICE,
    VOLUME,
    HIGH,
    LOW
  ]
]
Suggest Edits

Trades

This channel sends a trade message whenever a trade occurs at Bitfinex. It includes all the pertinent details of the trade, such as price, size and time.

 

Stream Fields

Fields Type Description
MTS int millisecond time stamp
±AMOUNT float How much was bought (positive) or sold (negative).
PRICE float Price at which the trade was executed
RATE float Rate at which funding transaction occurred
PERIOD int Amount of time the funding transaction was for

The order that causes the trade determines if it is a buy or a sell.

// request
{ 
  event: "subscribe", 
  channel: "trades", 
  symbol: SYMBOL 
}

// response Trading
{
  event: "subscribed",
  channel: "trades",
  chanId: CHANNEL_ID,
  symbol: "tBTCUSD"
  pair: "BTCUSD"
}

// response Funding
{
  event: "subscribed",
  channel: "trades",
  chanId: CHANNEL_ID,
  symbol: "fUSD"
}
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  [
    [
      ID,
      MTS,
      AMOUNT,
      PRICE
    ],
    ...
  ]
]


// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  [
    [
      ID,
      MTS,
      AMOUNT,
      RATE,
      PERIOD
    ],
    ...
  ]
]
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  <"te", "tu">,
  [
    ID,
    MTS,
    AMOUNT,
    PRICE
  ]
]

// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  <"fte", "ftu">,
  [
    ID,
    MTS,
    AMOUNT,
    RATE,
    PERIOD
  ]
]
Suggest Edits

Books

The Order Books channel allow you to keep track of the state of the Bitfinex order book.
It is provided on a price aggregated basis, with customizable precision.
After receiving the response, you will receive a snapshot of the book,
followed by updates upon any changes to the book.

 

Request Fields

Fields Type Description
PRECISION string Level of price aggregation (P0, P1, P2, P3).
The default is P0
FREQUENCY string Frequency of updates (F0, F1, F2, F3).
F0=realtime / F1=2sec / F2=5sec / F3=10sec
LENGTH string Number of price points ("25", "100") [default="25"]

Stream Fields

Fields Type Description
PRICE float Price level
RATE float Rate level
PERIOD float Period level
COUNT int Number of orders at that price level
±AMOUNT float Total amount available at that price level. Trading: if AMOUNT > 0 then bid else ask; Funding: if AMOUNT < 0 then bid else ask;

Algorithm to create and keep a book instance updated

  1. subscribe to channel
  2. receive the book snapshot and create your in-memory book structure
  3. when count > 0 then you have to add or update the price level
    3.1 if amount > 0 then add/update bids
    3.2 if amount < 0 then add/update asks
  4. when count = 0 then you have to delete the price level.
    4.1 if amount = 1 then remove from bids
    4.2 if amount = -1 then remove from asks

Node.JS example gist: https://gist.github.com/prdn/b8c067c758aab7fa3bf715101086b47c

Precision Levels per Pair

Pair Precision Level Number of significant figures Example
BTCUSD P0 2 $0.01
... P1 1 $0.10
... P2 0 $1
... P3 -1 $10
LTCUSD P0 4 $0.0001
... P1 3 $0.001
... P2 2 $0.01
... P3 1 $0.1
LTCBTC P0 6 ฿0.000001
... P1 5 ฿0.00001
... P2 4 ฿0.0001
... P3 3 ฿0.001
ETHUSD P0 4 $0.0001
... P1 3 $0.001
... P2 2 $0.01
... P3 1 $0.1
ETHBTC P0 6 ฿0.000001
... P1 5 ฿0.00001
... P2 4 ฿0.0001
... P3 3 ฿0.001

Error Codes

10011 : Unknown Book precision
10012 : Unknown Book length

// request
{ 
  event: 'subscribe',
  channel: 'book',
  symbol: SYMBOL,
  prec: PRECISION,
  freq: FREQUENCY,
  len: LENGTH 
}

// response
{ 
  event: 'subscribed',
  channel: 'book',
  chanId: CHANNEL_ID,
  symbol: SYMBOL,
  prec: PRECISION,
  freq: FREQUENCY,
  len: LENGTH 
}
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  [
    [
      PRICE,
      COUNT,
      AMOUNT
    ],
    ...
  ]
]
  
// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  [
    [
      RATE,
      PERIOD,
      COUNT,
      AMOUNT
    ],
    ...
  ]
]
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  [
    PRICE,
    COUNT,
    AMOUNT
  ]
]
  
// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  [
    RATE,
    PERIOD,
    COUNT,
    AMOUNT
  ]
]
Suggest Edits

Raw Books

These are the most granular books.

 

Note

PRICE = 0 means that you have to remove the order from your book.

Stream Fields

Fields Type Description
ORDER_ID int Order id
PRICE float Order price; if 0 you have to rr from your book
±AMOUNT float Total amount available at that price level.

Trading: if AMOUNT > 0 then bid else ask; Funding: if AMOUNT < 0 then bid else ask;

Algorithm to create and keep a book instance updated

  1. subscribe to channel with R0 precision
  2. receive the raw book snapshot and create your in-memory book structure
  3. when price > 0 then you have to add or update the order
  4. when price = 0 then you have to delete the order
// request
{
  event: "subscribe",
  channel: "book",
  prec: "R0",
  symbol: SYMBOL,
  len: LENGTH
}

// response
{
  event: "subscribed",
  channel: "book",
  chanId: CHANNEL_ID,
  symbol: SYMBOL,
  prec: PRECISION,
  len: LENGTH,
  len: LENGTH
}
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  [
    [
      ORDER_ID,
      PRICE,
      AMOUNT
    ],
    ...
  ]
]
  
// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  [
    [
      OFFER_ID,
      RATE,
      PERIOD,
      AMOUNT
    ],
    ...
  ]
]
// on trading pairs (ex. tBTCUSD)
[
  CHANNEL_ID,
  [
    ORDER_ID,
    PRICE,
    AMOUNT
  ]
]
  
// on funding currencies (ex. fUSD)
[
  CHANNEL_ID,
  [
    OFFER_ID,
    RATE,
    PERIOD,
    AMOUNT
  ]
]
Suggest Edits

Candles

Provides a way to access charting candle info

 

Stream Fields

Fields Type Description
MTS int millisecond time stamp
OPEN float First execution during the time frame
CLOSE float Last execution during the time frame
HIGH integer Highest execution during the time frame
LOW float Lowest execution during the timeframe
VOLUME float Quantity of symbol traded within the timeframe

Time frames

  • 1m: one minute
  • 5m : five minutes
  • 15m : 15 minutes
  • 30m : 30 minutes
  • 1h : one hour
  • 3h : 3 hours
  • 6h : 6 hours
  • 12h : 12 hours
  • 1D : one day
  • 7D : one week
  • 14D : two weeks
  • 1M : one month
// request
{
   event: "subscribe",
   channel: "candles",
   key: "trade:1m:tBTCUSD"
}

// response
{
  event: "subscribed",
  channel: "candles",
  chanId": CHANNEL_ID,
  key: "trade:1m:tBTCUSD"
}
[
  CHANNEL_ID,
  [
    [
      MTS,
      OPEN,
      CLOSE,
      HIGH,
      LOW,
      VOLUME
    ],
    ...
  ]
]
[
  CHANNEL_ID,
  [
    MTS,
    OPEN,
    CLOSE,
    HIGH,
    LOW,
    VOLUME
  ]
]
Suggest Edits

Account Info

Information about your account (trading fees)

 

Stream Fields

Term Type Description
ID int Order ID
GID int Group ID
CID int Client Order ID
SYMBOL string Pair (tBTCUSD, …)
MTS_CREATE int Millisecond timestamp of creation
MTS_UPDATE int Millisecond timestamp of update
AMOUNT float Positive means buy, negative means sell.
AMOUNT_ORIG float Original amount
TYPE string The type of the order: LIMIT, MARKET, STOP, TRAILING STOP, EXCHANGE MARKET, EXCHANGE LIMIT, EXCHANGE STOP, EXCHANGE TRAILING STOP, FOK, EXCHANGE FOK.
TYPE_PREV string Previous order type
FLAGS int Upcoming Params Object (stay tuned)
ORDER_STATUS string Order Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
PRICE float Price
PRICE_AVG float Average price
PRICE_TRAILING float The trailing price
PRICE_AUX_LIMIT float Auxiliary Limit price (for STOP LIMIT)
NOTIFY int 1 if Notify flag is active, 0 if not
HIDDEN int 1 if Hidden, 0 if not hidden
PLACED_ID int If another order caused this order to be placed (OCO) this will be that other order's ID
[
  CHAN_ID, 
  'os',
  [
    [
      ID, 
      GID,
      CID,
      SYMBOL, 
      MTS_CREATE, 
      MTS_UPDATE, 
      AMOUNT, 
      AMOUNT_ORIG, 
      TYPE,
      TYPE_PREV,
      _PLACEHOLDER,
      _PLACEHOLDER,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      PRICE,
      PRICE_AVG,
      PRICE_TRAILING,
      PRICE_AUX_LIMIT,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      NOTIFY, 
      HIDDEN, 
      PLACED_ID,
      ...
    ], 
    ...
  ]
]
[
  CHAN_ID, 
  <'on', 'ou', 'oc'>,
  [
    ID, 
    GID,
    CID,
    SYMBOL, 
    MTS_CREATE, 
    MTS_UPDATE, 
    AMOUNT, 
    AMOUNT_ORIG, 
    TYPE,
    TYPE_PREV,
    _PLACEHOLDER,
    _PLACEHOLDER,
    FLAGS,
    STATUS,
    _PLACEHOLDER,
    _PLACEHOLDER,
    PRICE,
    PRICE_AVG,
    PRICE_TRAILING,
    PRICE_AUX_LIMIT,
    _PLACEHOLDER,
    _PLACEHOLDER,
    _PLACEHOLDER,
    NOTIFY, 
    HIDDEN, 
    PLACED_ID,
    ...
  ]
]
Suggest Edits

Historical Orders

 

Stream Fields

Term Type Description
ID int Order ID
GID int Group ID
CID int Client Order ID
SYMBOL string Pair (tBTCUSD, …)
MTS_CREATE int Millisecond timestamp of creation
MTS_UPDATE int Millisecond timestamp of update
AMOUNT float Positive means buy, negative means sell.
AMOUNT_ORIG float Original amount
TYPE string The type of the order: LIMIT, MARKET, STOP, TRAILING STOP, EXCHANGE MARKET, EXCHANGE LIMIT, EXCHANGE STOP, EXCHANGE TRAILING STOP, FOK, EXCHANGE FOK.
TYPE_PREV string Previous order type
FLAGS int Upcoming Params Object (stay tuned)
ORDER_STATUS string Order Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
PRICE float Price
PRICE_AVG float Average price
PRICE_TRAILING float The trailing price
PRICE_AUX_LIMIT float Auxiliary Limit price (for STOP LIMIT)
NOTIFY int 1 if Notify flag is active, 0 if not
HIDDEN int 1 if Hidden, 0 if not hidden
PLACED_ID int If another order caused this order to be placed (OCO) this will be that other order's ID
[
  CHAN_ID, 
  'hos'
  [
    [
      ID, 
      GID,
      CID,
      SYMBOL, 
      MTS_CREATE, 
      MTS_UPDATE, 
      AMOUNT, 
      AMOUNT_ORIG, 
      TYPE,
      TYPE_PREV,
      _PLACEHOLDER,
      _PLACEHOLDER,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      PRICE,
      PRICE_AVG,
      PRICE_TRAILING,
      PRICE_AUX_LIMIT,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      NOTIFY, 
      HIDDEN, 
      PLACED_ID,
      ...
    ], 
    ...
  ]
]
 

Stream Fields

Term Type Description
SYMBOL string Pair (tBTCUSD, …).
STATUS string Status (ACTIVE, CLOSED).
±AMOUNT float Size of the position. Positive values means a long position, negative values means a short position.
BASE_PRICE float The price at which you entered your position.
MARGIN_FUNDING float The amount of funding being used for this position.
MARGIN_FUNDING_TYPE int 0 for daily, 1 for term.
PL float Profit & Loss
PL_PERC float Profit & Loss Percentage
PRICE_LIQ float Liquidation price
LEVERAGE float Beta value
[
  CHAN_ID, 
  'ps',
  [
    [
      SYMBOL, 
      STATUS, 
      AMOUNT, 
      BASE_PRICE, 
      MARGIN_FUNDING, 
      MARGIN_FUNDING_TYPE,
      PL,
      PL_PERC,
      PRICE_LIQ,
      LEVERAGE
      ...
    ], 
    ...
  ]
]
[
  CHAN_ID, 
  <‘pn’, ’pu’, ‘pc’>,
  [
      POS_PAIR, 
      POS_STATUS, 
      POS_AMOUNT, 
      POS_BASE_PRICE, 
      POS_MARGIN_FUNDING, 
      POS_MARGIN_FUNDING_TYPE,
      PL,
      PL_PERC,
      PRICE_LIQ,
      LEVERAGE
      ...
  ]
]

After a te message you receive shortly a tu message that contains the real trade id (TRD_ID) and additional/updated fields.

Stream Fields

Term Type Description
ID integer Trade database id
PAIR string Pair (BTCUSD, …)
MTS_CREATE integer Execution timestamp
ORDER_ID integer Order id
EXEC_AMOUNT float Positive means buy, negative means sell
EXEC_PRICE float Execution price
ORDER_TYPE string Order type
ORDER_PRICE float Order price
MAKER int 1 if true, 0 if false
FEE float Fee
FEE_CURRENCY string Fee currency
[
  CHAN_ID,
  'hts',
  [
    [
      ID, 
      PAIR, 
      MTS_CREATE, 
      ORDER_ID, 
      EXEC_AMOUNT, 
      EXEC_PRICE, 
      ORDER_TYPE, 
      ORDER_PRICE, 
      FEE, 
      FEE_CURRENCY, 
      MAKER,
      ...
    ], 
    ...
  ]
]
[
  CHAN_ID, 
  'te', 
  [
    ID, 
    PAIR, 
    MTS_CREATE, 
    ORDER_ID, 
    EXEC_AMOUNT, 
    EXEC_PRICE, 
    ORDER_TYPE, 
    ORDER_PRICE, 
    MAKER,
    ...
  ]
]
[
  CHAN_ID, 
  'tu', 
  [
    ID, 
    PAIR, 
    MTS_CREATE, 
    ORDER_ID, 
    EXEC_AMOUNT, 
    EXEC_PRICE, 
    ORDER_TYPE, 
    ORDER_PRICE, 
    MAKER, 
    FEE, 
    FEE_CURRENCY,
    ...
  ]
]
 

Stream Fields

Term Type Description
WALLET_TYPE string Wallet name (exchange, trading, deposit)
CURRENCY string Currency (fUSD, etc)
BALANCE float Wallet balance
UNSETTLED_INTEREST float Unsettled interest
BALANCE_AVAILABLE float / null Amount not tied up in active orders, positions or funding (null if the value is not fresh enough).

Important

These messages have gained the ability to send the calculation values (liquidation price, available balance) equal to "null" meaning that the new calculated value is not yet available. (see changelog section)

In order to receive those values the user have to actively request for it with a "calc" message.
See calc input dedicated section for more details.

[
  CHAN_ID, 
  'ws',
  [
    [
      WALLET_TYPE, 
      CURRENCY, 
      BALANCE, 
      UNSETTLED_INTEREST,
      BALANCE_AVAILABLE,
      ...
    ], 
    ...
  ]
]
[
  CHAN_ID, 
  'wu',
  [
    WALLET_TYPE, 
    CURRENCY, 
    BALANCE, 
    UNSETTLED_INTEREST,
    BALANCE_AVAILABLE,
    ...
  ]
]
Suggest Edits

Balance Info

Balance information

 

Stream Fields

Term Type Description
AUM float Total Assets Under Management
AUM_NET float Net Assets Under Management
WALLET_TYPE string Exchange, Trading, or Deposit
CURRENCY string "BTC", "USD", etc
[
  CHAN_ID,
  'bu',
  [
    AUM,
    AUM_NET,
    ...
  ]
]
Suggest Edits

Margin Info

 

Stream Fields

Term Type Description
USER_PL float User Profit and Loss
USER_SWAPS float Amount of swaps a user has
SYMBOL string The symbol the information pertains to
TRADABLE_BALANCE float Your buying power (how large a position you can obtain)
MARGIN_BALANCE float Balance in your margin funding account
MARGIN_NET float Balance after P&L is accounted for
// margin base calc
[
  CHAN_ID, 
	'miu',
  [
    'base',
    [
      USER_PL, 
      USER_SWAPS, 
      MARGIN_BALANCE, 
      MARGIN_NET
    ]
   ]
]

// margin symbol calc
[
  CHAN_ID, 
	'miu',
  [
    'sym',
    SYMBOL,
    [
      TRADABLE_BALANCE
    ]
   ]
]
Suggest Edits

Funding Info

Get account funding info

 
[
  CHAN_ID, 
  'fiu',
  [
    'sym',
    SYMBOL
    [
    
      YIELD_LOAN,
      YIELD_LEND,
      DURATION_LOAN,
      DURATION_LEND,
      ...
    ],
    ...
  ]
]

Stream Fields

Term Type Description
SYMBOL string The symbol the information pertains to (funding currencies)
YIELD_LOAN float Weighted average rate for taken funding
YIELD_LEND float Weighted average rate for provided funding
DURATION_LOAN float Weighted average duration for taken funding
DURATION_LEND float Weighted average duration for provided funding

Stream Fields

Term Type Description
ID integer Offer ID
SYMBOL string The currency of the offer (fUSD, etc)
MTS_CREATED int Millisecond Time Stamp when the offer was created
MSG_UPDATED int Millisecond Time Stamp when the offer was created
AMOUNT float Amount the offer is for
AMOUNT_ORIG float Amount the offer was entered with originally
TYPE string "lend" or "loan"
FLAGS object future params object (stay tuned)
STATUS string Offer Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
RATE float Rate of the offer
PERIOD int Period of the offer
NOTIFY int 0 if false, 1 if true
HIDDEN int 0 if false, 1 if true
INSURE int 0 if false, 1 if true
RENEW int 0 if false, 1 if true
RATE_REAL float the calculated rate for FRR and FRRDELTAFIX
[
  CHAN_ID,
  'fos',
  [
    [
      ID,
      SYMBOL,
      MTS_CREATED,
      MTS_UPDATED,
      AMOUNT,
      AMOUNT_ORIG,
      TYPE,
      _PLACEHOLDER,
      _PLACEHOLDER,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      RATE,
      PERIOD,
      NOTIFY,
      HIDDEN,
      _PLACEHOLDER,
      RENEW,
      RATE_REAL,
      ...
    ],
    ...
  ]
]
[
  CHAN_ID,
  <'fon', 'fou', 'foc'>,
  [
    ID,
    SYMBOL,
    MTS_CREATED,
    MTS_UPDATED,
    AMOUNT,
    AMOUNT_ORIG,
    TYPE,
    _PLACEHOLDER,
    _PLACEHOLDER,
    FLAGS,
    STATUS,
    _PLACEHOLDER,
    _PLACEHOLDER,
    _PLACEHOLDER,
    RATE,
    PERIOD,
    NOTIFY,
    HIDDEN,
    _PLACEHOLDER,
    RENEW,
    RATE_REAL,
    ...
  ]
]
Suggest Edits

Historical Offers

 

Stream Fields

Term Type Description
ID integer Offer ID
CURRENCY string The currency of the offer (fUSD, etc)
MTS_CREATED int Millisecond Time Stamp when the offer was created
MSG_UPDATED int Millisecond Time Stamp when the offer was created
AMOUNT float Amount the offer is for
AMOUNT_ORIG float Amount the offer was entered with originally
TYPE string "lend" or "loan"
FLAGS object future params object (stay tuned)
STATUS string Offer Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
RATE float Rate of the offer
PERIOD int Period of the offer
NOTIFY int 0 if false, 1 if true
HIDDEN int 0 if false, 1 if true
INSURE int 0 if false, 1 if true
RENEW int 0 if false, 1 if true
RATE_REAL float the calculated rate for FRR and FRRDELTAFIX
[
  CHAN_ID,
  'hfos',
  [
    [
      ID,
      SYMBOL,
      MTS_CREATED,
      MTS_UPDATED,
      AMOUNT,
      AMOUNT_ORIG,
      TYPE,
      _PLACEHOLDER,
      _PLACEHOLDER,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      RATE,
      PERIOD,
      NOTIFY,
      HIDDEN,
      _PLACEHOLDER,
      RENEW,
      RATE_REAL,
      ...
    ],
    ...
  ]
]
Suggest Edits

Credits

Funds used in active positions

 

Stream Fields

Term Type Description
ID integer Offer ID
SYMBOL string The currency of the offer (fUSD, etc)
SIDE string "Lend" or "Loan"
MTS_CREATE int Millisecond Time Stamp when the offer was created
MSG_UPDATE int Millisecond Time Stamp when the offer was created
AMOUNT float Amount the offer is for
FLAGS object future params object (stay tuned)
STATUS string Offer Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
RATE float Rate of the offer
PERIOD int Period of the offer
MTS_OPENING int Millisecond Time Stamp when the funding was opened
MTS_LAST_PAYOUT int Millisecond Time Stamp when the last payout was received
NOTIFY int 0 if false, 1 if true
HIDDEN int 0 if false, 1 if true
INSURE int 0 if false, 1 if true
RENEW int 0 if false, 1 if true
RATE_REAL float the calculated rate for FRR and FRRDELTAFIX
NO_CLOSE int 0 if false, 1 if true (whether the funding should be closed when the position is closed)
POSITION_PAIR string The pair that the currency was used for
[
  CHAN_ID,
  'fcs',
  [
    [
      ID,
      SYMBOL,
      SIDE,
      MTS_CREATE,
      MTS_UPDATE,
      AMOUNT,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      RATE,
      PERIOD,
      MTS_OPENING,
      MTS_LAST_PAYOUT,
      NOTIFY,
      HIDDEN,
      _PLACEHOLDER,
      RENEW,
      RATE_REAL,
      NO_CLOSE,
      POSITION_PAIR,
      ...
    ],
    ...
  ]
]
'fcn', 'fcu', 'fcc': [
  CHAN_ID,
  UPD_TYPE,
  [
    ID, 
    CURRENCY, 
    SIDE, 
    MTS_CREATE, 
    MTS_UPDATE, 
    AMOUNT, 
    FLAGS, 
    STATUS,
    _PLACEHOLDER,
    _PLACEHOLDER,
    _PLACEHOLDER,
    RATE,
    PERIOD, 
    MTS_OPENING, 
    MTS_LAST_PAYOUT, 
    NOTIFY, 
    HIDDEN, 
    _PLACEHOLDER,
    RENEW,
    RATE_REAL, 
    NO_CLOSE, 
    POSITION_PAIR,
    ...
  ]
]
Suggest Edits

Historical Credits

 

Stream Fields

Term Type Description
ID integer Offer ID
SYMBOL string The currency of the offer (fUSD, etc)
SIDE string "Lend" or "Loan"
MTS_CREATE int Millisecond Time Stamp when the offer was created
MSG_UPDATE int Millisecond Time Stamp when the offer was created
AMOUNT float Amount the offer is for
FLAGS object future params object (stay tuned)
STATUS string Offer Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
RATE float Rate of the offer
PERIOD int Period of the offer
MTS_OPENING int Millisecond Time Stamp when funding opened
MTS_LAST_PAYOUT int Millisecond Time Stamp when last payout received
NOTIFY int 0 if false, 1 if true
HIDDEN int 0 if false, 1 if true
INSURED int 0 if false, 1 if true
RENEW int 0 if false, 1 if true
RATE_REAL float the calculated rate for FRR and FRRDELTAFIX
NO_CLOSE int 0 if false, 1 if true Whether the funding will be closed when the position is closed
POSITION_PAIR string Pair of the position that the funding was used for
[
  CHAN_ID,
  'hfcs',
  [
    [
      ID,
      SYMBOL,
      SYMBOL,
      MTS_CREATE,
      MTS_UPDATE,
      AMOUNT,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      RATE,
      PERIOD,
      MTS_OPENING,
      MTS_LAST_PAYOUT,
      NOTIFY,
      HIDDEN,
      _PLACEHOLDER,
      RENEW,
      RATE_REAL,
      NO_CLOSE,
      POSITION_PAIR,
      ...
    ],
    ...
  ]
]
Suggest Edits

Loans

Funds not used in active positions

 

Stream Fields

Term Type Description
ID integer Offer ID
SYMBOL string The currency of the offer (fUSD, etc)
SIDE string "Lend" or "Loan"
MTS_CREATE int Millisecond Time Stamp when the offer was created
MTS_UPDATE int Millisecond Time Stamp when the offer was updated
AMOUNT float Amount the offer is for
FLAGS object future params object (stay tuned)
STATUS string Offer Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
RATE float Rate of the offer
PERIOD int Period of the offer
MTS_OPENING int Millisecond Time Stamp of when funding was opened
MTS_LAST_PAYOUT int Millisecond Time Stamp of when last payout was received
NOTIFY int 0 if false, 1 if true
HIDDEN int 0 if false, 1 if true
INSURE int 0 if false, 1 if true
RENEW int 0 if false, 1 if true
RATE_REAL float the calculated rate for FRR and FRRDELTAFIX
NO_CLOSE int If funding will be returned when position is closed. 0 if false, 1 if true
[
  CHAN_ID,
  'fls',
  [
    [
      ID,
      SYMBOL,
      SIDE,
      MTS_CREATE,
      MTS_UPDATE,
      AMOUNT,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      RATE,
      PERIOD,
      MTS_OPENING,
      MTS_LAST_PAYOUT,
      NOTIFY,
      HIDDEN,
      _PLACEHOLDER,
      RENEW,
      RATE_REAL,
      NO_CLOSE,
      ...
    ],
    ...
  ]
]
[
  CHAN_ID,
  <'fln', 'flu', 'flc'>,
  [
    ID,
    CURRENCY,
    SIDE,
    MTS_CREATE,
    MTS_UPDATE,
    AMOUNT,
    FLAGS,
    STATUS,
    _PLACEHOLDER,
    _PLACEHOLDER,
    _PLACEHOLDER,
    RATE,
    PERIOD,
    MTS_OPENING,
    MTS_LAST_PAYOUT,
    NOTIFY,
    HIDDEN,
    _PLACEHOLDER,
    RENEW,
    RATE_REAL,
    NO_CLOSE,
    ...
  ]
]
Suggest Edits

Historical Loans

 

Stream Fields

Term Type Description
ID integer Offer ID
SYMBOL string The currency of the offer (fUSD, etc)
SIDE string "Lend" or "Loan"
MTS_CREATE int Millisecond Time Stamp when the offer was created
MTS_UPDATE int Millisecond Time Stamp when the offer was created
AMOUNT float Amount the offer is for
FLAGS object future params object (stay tuned)
STATUS string Offer Status: ACTIVE, EXECUTED, PARTIALLY FILLED, CANCELED
RATE float Rate of the offer
PERIOD int Period of the offer
MTS_OPENING int Millisecond Time Stamp for when the loan was opened
MTS_LAST_PAYOUT int Millisecond Time Stamp for when the last payout was made
NOTIFY int 0 if false, 1 if true
HIDDEN int 0 if false, 1 if true
INSURED int 0 if false, 1 if true
RENEW int 0 if false, 1 if true
RATE_REAL float the calculated rate for FRR and FRRDELTAFIX
NO_CLOSE int If funding will be returned when position is closed. 0 if false, 1 if true
POSITION_PAIR string Pair of the position that the funding was used for
[
  CHAN_ID,
  'hfls',
  [
    [
      ID,
      SYMBOL,
      SIDE,
      MTS_CREATE,
      MTS_UPDATE,
      AMOUNT,
      FLAGS,
      STATUS,
      _PLACEHOLDER,
      _PLACEHOLDER,
      _PLACEHOLDER,
      RATE,
      PERIOD,
      MTS_OPENING,
      MTS_LAST_PAYOUT,
      NOTIFY,
      HIDDEN,
      _PLACEHOLDER,
      RENEW,
      RATE_REAL,
      NO_CLOSE,
      ...
    ],
    ...
  ]
]
Suggest Edits

Funding Trades

 

Stream Fields

Term Type Description
ID integer Offer ID
SYMBOL string The currency of the offer (fUSD, etc)
MTS_CREATE int Millisecond Time Stamp when the offer was created
OFFER_ID int The ID of the offer
AMOUNT float Amount the offer is for
RATE float Rate of the offer
PERIOD int Period of the offer
MAKER int Whether the offer took liquidity off the funding book
[
  CHAN_ID,
  'hfts',
  [
    [
      ID,
      SYMBOL,
      MTS_CREATE,
      OFFER_ID,
      AMOUNT,
      RATE,
      PERIOD,
      MAKER,
      ...
    ],
    ...
  ]
]
'fte', 'ftu': [
  CHAN_ID,
  UPD_TYPE,
  [
    ID,
    CURRENCY,
    MTS_CREATE,
    OFFER_ID,
    AMOUNT,
    RATE,
    PERIOD,
    MAKER,
    ...
  ]
]
Suggest Edits

Notifications

 

Work In Progress

This section (Notifications) is currently a work in progress, but it will be a way to be alerted as to different changes in status, price alerts, etc

Stream Fields

Term Type Description
MTS int Millisecond Time Stamp of the update
TYPE string Purpose of notification ('on-req', 'oc-req', 'uca', 'fon-req', 'foc-req')
MESSAGE_ID int unique ID of the message
NOTIFY_INFO array/object A message containing information regarding the notification
CODE null or integer Work in progress
STATUS string Status of the notification; it may vary over time (SUCCESS, ERROR, FAILURE, ...)
TEXT string Text of the notification
[
  CHAN_ID, 
  'n', 
  [
    MTS, 
    TYPE, 
    MESSAGE_ID, 
    null, 
    NOTIFY_INFO, 
    CODE, 
    STATUS, 
    TEXT,
    ...
  ]
]
notify_info =  [ 
  ID, 
  GID,
  CID,
  SYMBOL, 
  MTS_CREATE, 
  MTS_UPDATE, 
  AMOUNT, 
  AMOUNT_ORIG, 
  TYPE,
  TYPE_PREV,
  _PLACEHOLDER,
  _PLACEHOLDER,
  FLAGS,
  STATUS,
  _PLACEHOLDER,
  _PLACEHOLDER,
  PRICE,
  PRICE_AVG,
  PRICE_TRAILING,
  PRICE_AUX_LIMIT,
  _PLACEHOLDER,
  _PLACEHOLDER,
  _PLACEHOLDER,
  NOTIFY, 
  HIDDEN, 
  PLACED_ID,
  ...
]
notify_info = [ 
  KEY, 
  ‘price’, 
  SYMBOL, 
  PRICE, 
  COUNT, 
  DIRECTION 
]
notify_info = [
  ID,
  SYMBOL,
  MTS_CREATED,
  MTS_UPDATED,
  AMOUNT,
  AMOUNT_ORIG,
  TYPE,
  _PLACEHOLDER,
  _PLACEHOLDER,
  FLAGS,
  STATUS,
  _PLACEHOLDER,
  _PLACEHOLDER,
  _PLACEHOLDER,
  RATE,
  PERIOD,
  NOTIFY,
  HIDDEN,
  _PLACEHOLDER,
  RENEW,
  RATE_REAL,
  ...
]
Suggest Edits

Input API

Order Creation and Cancellation

 

FLAGS

Flags is an XOR'd bitwise number

Example: To enable all decimals as strings AND all timestamps as date strings, you would set FLAGS to 40 (32 XOR 8 = 40)

NOTE: Sequencing when enabled will add an extra field to all the websocket responses

Name Value Description
DEC_S 8 Enable all decimal as strings
TIME_S 32 Enable all times as date strings
SEQ_ALL 65536 BETA: Enable sequencing
{ 
  "event": "conf", 
  "flags": FLAGS 
}
{ 
  "event": "conf", 
  "status": "OK" 
}
Suggest Edits

New Order

 

You will receive a message of the appropriated type on the "account info" channel

Request Fields

Name Type Description
gid int32 (optional) Group id for the order
cid int45 Must be unique in the day (UTC)
type string MARKET, EXCHANGE MARKET, LIMIT, EXCHANGE LIMIT, STOP, EXCHANGE STOP, TRAILING STOP, EXCHANGE TRAILING STOP, FOK, EXCHANGE FOK, STOP LIMIT
symbol string symbol (tBTCUSD, tETHUSD, ...)
amount decimal string Positive for buy, Negative for sell
price decimal Price (Not required for market orders)
price_trailing decimal The trailing price
price_aux_limit decimal Auxiliary Limit price (for STOP LIMIT)
hidden int2 Whether the order is hidden (1) or not (0)
postonly int2 (optional) Whether the order is postonly (1) or not (0)
// Model
[
  0,
  "on",
  null,
  {
    "gid": GID,
    "cid": CID,
    "type": TYPE,
    "symbol": SYMBOL,
    "amount": AMOUNT,
    "price": PRICE,
    ...
  }
]

// Example
[
  0,
  "on",
  null,
  {
    "gid": 1,
    "cid": 12345,
    "type": "LIMIT",
    "symbol": "tBTCUSD",
    "amount": "1.0",
    "price": "500",
    "hidden": 0
  }
]
Suggest Edits

Cancel Order

 

When you send a cancel order, you will see the status of the order change by way of receiving an "oc" message. You will also receive a notification that the order was requested to be canceled of the type "oc-req".

You can cancel the order by the Internal Order ID or using a Client Order ID (supplied by you). The Client Order ID is unique per day, so you also have to provide the date of the order as a date string in this format YYYY-MM-DD.

Request Fields

Name Type Description
ID int64 Order ID
CID int45 Client Order ID
CID_DATE string Client Order ID Date
// Cancel order by internal order Id
[
  0,
  "oc",
  null,
  {
    "id": ID
  }
]

// Cancel order using client order Id and order creation date
[
  0,
  "oc",
  null,
  {
    "cid": CID,
    "cid_date": CID_DATE
  }
]
Suggest Edits

Cancel Order Multi

 

When you send a cancel order, you will see the status of the order change by way of receiving an "oc" message. You will also receive a notification that the order was requested to be canceled of the type "oc-req".

You can cancel the order by the Internal Order ID or using a Client Order ID (supplied by you). The Client Order ID is unique per day, so you also have to provide the date of the order as a date string in this format YYYY-MM-DD.

Request Fields

Name Type Description
ID int64 Order ID
CID int45 Client Order ID
CID_DATE string Client Order ID Date
GID int32 Group Order ID
ID_MAX INT Maximum Order ID
// Cancel multiple orders by Internal Order ID
[
  0,
  "oc_multi",
  null,
  {
    "id": [ID, 1234, ...]
  }
]

// Cancel multiple orders using Client Order ID and order creation date
[
  0,
  "oc_multi",
  null,
  {
    "cid": [
      [ID, CID_DATE],
      [234, "2016-12-05"],
      ...
    ]
  }
]

// Cancel multiple orders using Group ID
[
  0,
  "oc_multi",
  null,
  {
     "gid": [
       [GID, ID_MAX],
       [GID],
       [12, 1230],
       [11],
       ...
     ]
  }
]
Suggest Edits

Order Multi-OP

Send multiple order-related operations (max 15)

 
// Model
[
  0,
  "ox_multi",
  null,
  [
    [OPERATION, {}],
    [OPERATION, {}],
    [OPERATION, {}],
    ...
  ]
]
  
// Example
[
  0,
  "ox_multi",
  null,
  [
    ["on", {...}],
    ["oc", {...}],
    ["oc_multi", {...}],
    ["oc", {...}],
    ...
  ]
]