Bitfinex is one of the world's largest and most advanced cryptocurrency trading platform. Users can exchange Bitcoin, Ethereum, Ripple, EOS, Bitcoin Cash, Iota, NEO, Litecoin, Ethereum Classic...
Bitfinex WebSocket API version is 2.0
Each message sent and received via the Bitfinex's WebSocket channel is encoded in JSON format
A symbol can be a trading pair or a margin currency:
Trading pairs symbols are formed prepending a "t" before the pair (i.e tBTCUSD, tETHUSD).
Margin currencies symbols are formed prepending an "f" before the currency (i.e fUSD, fBTC, ...)
After a successful connection, OnBitfinexConnect event is raised and you get Bitfinex API Version number as a parameter.
You can call Ping method to test connection to the server.
If the server sends any information, this can be handle using OnBitfinexInfoMessage event, where a Code and a Message are parameters with information about the message sent by the server. Example codes:
20051 : Stop/Restart WebSocket Server (please reconnect)
20060 : Entering in Maintenance mode. Please pause any activity and resume after receiving the info message 20061 (it should take 120 seconds at most).
20061 : Maintenance ended. You can resume normal activity. It is advised to unsubscribe/subscribe again all channels.
In case of error, OnBitfinexError will be raised, and information about error provided. Example error codes:
10000 : Unknown event
10001 : Unknown pair
In order to change the configuration, call Configuration method and pass as a parameter one of the following flags:
CS_DEC_S = 8; // Enable all decimal as strings.
CS_TIME_S = 32; // Enable all times as date strings.
CS_SEQ_ALL = 65536; // Enable sequencing BETA FEATURE
CHECKSUM = 131072; // Enable checksum for every book iteration. Checks the top 25 entries for each side of the book. The checksum is a signed int.
There are channels which are public and there is no need to authenticate against the server. All messages are raised OnBitfinexUpdate event.
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.
// 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
]
]
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.
// on trading pairs (ex. tBTCUSD)
[
CHANNEL_ID,
[
[
ID,
MTS,
AMOUNT,
PRICE
],
...
]
]
// on funding currencies (ex. fUSD)
[
CHANNEL_ID,
[
[
ID,
MTS,
AMOUNT,
RATE,
PERIOD
],
...
]
]
The Order Books channel allows 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.
// on trading pairs (ex. tBTCUSD)
[
CHANNEL_ID,
[
[
PRICE,
COUNT,
AMOUNT
],
...
]
]
// on funding currencies (ex. fUSD)
[
CHANNEL_ID,
[
[
RATE,
PERIOD,
COUNT,
AMOUNT
],
...
]
]
These are the most granular books.
// on trading pairs (ex. tBTCUSD)
[
CHANNEL_ID,
[
[
ORDER_ID,
PRICE,
AMOUNT
],
...
]
]
// on funding currencies (ex. fUSD)
[
CHANNEL_ID,
[
[
OFFER_ID,
PERIOD,
RATE,
AMOUNT
],
...
]
]
Provides a way to access charting candle info. 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
[
CHANNEL_ID,
[
[
MTS,
OPEN,
CLOSE,
HIGH,
LOW,
VOLUME
],
...
]
]
This channel allows you to keep up to date with the status of your account. You can receive updates on your positions, your balances, your orders and your trades.
Use Authenticate method in order to Authenticate against the server and set required parameters.
Once authenticated, you will receive updates of: Orders, positions, trades, funding offers, funding credits, funding loans, wallets, balance info, margin info, funding info, funding trades...
You can request UnAuthenticate method if you want to log off from the server.