Node.JS Client ‘2.0.0.beta-1' Release

Cris Mihalache
Bitfinex
Published in
3 min readMay 4, 2018

The first update to our 2.0.0.beta node API library is ready, and comes with many fixes, tweaks, and new features to support the recent updates to our REST and WebSocket v2 APIs.

The Bitfinex Node.JS trading API can be found here.

New CLI Commands

Alongside changes to the library internals, this release includes a set of command-line helpers for querying your account data in tabular form:

npm run tickers

The available commands use the API key & secret provided in an .env file in the library’s root folder. To use them, create a file in your local copy of the library with the following format:

Then, run any one of the available commands:

The results are returned within CLI tables where possible, and can be passed through utilities like grep for further processing:

All commands except for ‘cancel-orders’ perform read-only operations; ‘cancel-orders’ itself spawns a WSv2 client to fetch your account order snapshot before proceeding to cancel all orders included within it.

In the future we will add new commands and further refine their output, in order to allow you to perform basic account operations directly from your nearest console interface.

New REST Endpoints

We’ve added support for closing positions & querying the platform status (under maintenance or operative) to the RESTv1 & RESTv2 classes, along with full query param support (start, end, limit, sort) for the RESTv2 candles endpoint helper.

Improved WSv2 Order Listener Filtering

All WSv2 listener helpers for order-related messages (onOrderUpdate, etc) now support filtering by order id, gid, cid, and symbol. This allows you to bind a listener for a specific order CID to only receive updates for that order.

As before the listeners can be grouped together with a callback ID (cbID), and removed all at once.

Order Book Checksums

The OrderBook model now provides a checksum() method, which can be used to verify checksums received from the WSv2 API. A static checksumArr() helper is also available for array-format order books.

Along with these helpers, the WSv2 client now automatically verifies checksums for managed order books if checksums have been enabled. If automatic verification fails, an error event is emitted.

WSv2 Order Flags

Support for the new order flags has been added, along with a map of valid flag values on the Order model itself. Flags can now be modified via dedicated getters/setters on the Order model, with a combined flags field value maintained internally.

WSv2 Atomic Order Updates

The Order class now supports the new atomic update API via an update() method, which accepts & prepares an update change-set. The method returns a Promise, which resolves after receiving an update confirmation from the server.

For more information on both order flags & atomic updates, see the April API dev update.

Fixes & Tweaks

Besides these new features, several bugs have been found & fixed and core parts of the library, such as the model system, have been refactored. Moving forwards, we will release new versions of the library more often and with smaller change-sets in order to keep the npm registry version up to date.

We apologize to those of you that reached out via our Github issue tracker as a result of using an outdated version of the library, and we thank you for your patience during the wait.

For now, upgrade your node client to v2.0.0.beta-1 and let us know what you think!

We’ve recently open-sourced a number of the development libraries most essential to Bitfinex. If you are interested in learning more, visit our Github.

Stay up to date with Bitfinex on Twitter, Telegram, Facebook & LinkedIn.

Join us on our mission to create the most innovative & industry-leading cryptocurrency exchange.

--

--