API Development Update — April
Our APIs are designed to offer you an effective way to build the digital asset trading tools you need. Create your own charts, monitor and edit orders, and execute custom strategies in real-time with minimal latency.
We’re working hard to streamline our development process and we are excited to share a new batch of REST and WebSocket API updates with everyone.
RESTv2 API Updates
1. Ledger Entries
Now you can quickly view your ledger entries. This will view all movements of a currency between your wallets at Bitfinex. To do so, send a POST request to https://api.bitfinex.com/v2/auth/r/ledgers/currency/hist with your authenticated headers. Be sure you replace currency with the symbol you inquire about such as BTC or USD:
2. Foreign Exchange Calculation
You may now query the Bitfinex API to find the foreign exchange rate of two currencies. To do so send a POST request to https://api.bitfinex.com/v2/calc/fx containing each currency marked as ccy1 and ccy2 within the body.
3. User Settings
On the Bitfinex platform, the UI relies on saving unique user settings to ensure a quality user experience. We have decided to open source the same settings API to our users. You can now read, write, and delete user setting keys via our REST API:
It is important to note that all keys must follow the regex: /^api:[A-Za-z0–9_-]*$/
WebSocket v2 API Updates
1. Order Flags
The biggest change to our websocket API is the addition of order flags. With flags, request fields that apply to order parameters are now eliminated and are replaced with an integer that can be summed.
The following flags are now available (taken from our node API library):
For example — if you would like to submit a Hidden Post Only order you would set the flags field to 4160, the result of sum, or binary AND, between 64 (Hidden) and 4096 (Post Only)
The following endpoints now support the new order flags field:
- Orders — https://docs.bitfinex.com/v2/reference#ws-auth-orders
- New Order — https://docs.bitfinex.com/v2/reference#ws-input-order-new
- Update Order — https://docs.bitfinex.com/v2/reference#ws-input-order-new
- Order Multiple-OP — https://docs.bitfinex.com/v2/reference#ws-input-order-multi-op
- New Offer — https://docs.bitfinex.com/v2/reference#new-offer
2. Timestamp Flag
A websocket flag that was added was the timestamp flag. When sending the WebSocket `conf` request, you may apply the new timestamp flag of value 32768. Once received, the timestamp will appended to every array sent by the server.
Just like order flags, the timestamp flag can be summed with other conf flags.
All available conf flags can be found here: https://docs.bitfinex.com/v2/docs/ws-general#section-available-options
3. Order Update
You may now update an order via the WebSocket API in-place. You can change an order’s price, amount, change an amount with a given delta, alter group IDs, and change the trailing price delta. Prior to this, changes to an order were applied by cancelling & submitting a new order (orders were immutable).
A few examples:
4. Offer Submit
You may now submit an offer via the WebSocket API to receive or provide funding.
A few examples:
5. Broadcast Custom Notification
Users can now broadcast custom notifications via the WebSocket v2 API, with the only requirement being that the notification type must begin with ‘ucm’. Notifications broadcast by a user are echo’ed out from all other active API connections, and have no limitations on payload or internal structure.
With this broadcast system, users can now build multi-client integrations with Bitfinex which use the WSv2 API for synchronisation and control. A simple example use-case is to generate custom ‘ucm-req’ and ‘ucm-res’ notifications for broadcasting arbitrary requests/responses over the bitfinex notification system. This removes the need for an external push-broadcast system, for those integrations that have multiple connected API clients which must communicate with one another in real-time.
The following is example notification broadcast packet:
At Bitfinex, we use this system ourselves to allow our UI to communicate with external user components connected to our WS API.
That’s it for this round of updates! Stay tuned for more as we continue to expand our offerings & enable the next generation of automated trading tools, one update at a time.