{"id":22608945,"url":"https://github.com/bitfinexcom/bfx-api-node-core","last_synced_at":"2025-04-11T06:14:48.282Z","repository":{"id":33155954,"uuid":"145867903","full_name":"bitfinexcom/bfx-api-node-core","owner":"bitfinexcom","description":null,"archived":false,"fork":false,"pushed_at":"2022-08-01T12:31:32.000Z","size":162,"stargazers_count":5,"open_issues_count":0,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-11T06:14:42.859Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfinexcom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-23T14:49:58.000Z","updated_at":"2022-04-07T12:49:17.000Z","dependencies_parsed_at":"2022-07-29T19:19:04.862Z","dependency_job_id":null,"html_url":"https://github.com/bitfinexcom/bfx-api-node-core","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfinexcom%2Fbfx-api-node-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfinexcom","download_url":"https://codeload.github.com/bitfinexcom/bfx-api-node-core/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351393,"owners_count":21089272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-08T15:10:12.707Z","updated_at":"2025-04-11T06:14:48.262Z","avatar_url":"https://github.com/bitfinexcom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bitfinex Modular WSv2 API Library for Node.JS\n\n[![Build Status](https://travis-ci.org/bitfinexcom/bfx-api-node-core.svg?branch=master)](https://travis-ci.org/bitfinexcom/bfx-api-node-core)\n\nModular Bitfinex Node.JS API library as an alternative to `bitfinex-api-node`, supporting a plugin system. Connection instances are POJOs as opposed to the\nWSv2 class instances returned by `bitfinex-api-node` and are manipulated in a\nfunctional style. A connection pool manager is also provided for multiplexing.\n\n### Features\n\n* POJO connection instances\n* Multiplexing connection pool manager\n* Plugin system for extending the default events\n\n### Installation\n\n```bash\nnpm i --save bfx-api-node-core\n```\n\n### Quickstart\n\n```js\nconst { Manager, initState } = require('bfx-api-node-core')\n\n// Create a Manager instance with an internal connection pool, and add a\n// connection to the pool\nconst m = new Manager({ transform: true })\nconst managedConnection = m.openWS()\n\n// Alternatively, create \u0026 open a single connection yourself\nconst connection = initState({ transform: true })\n\n// do something with connections, see below for examples\n```\n\n### Docs\n\n[`See docs/manager_docs.md`](/docs/manager_docs.md) for the Manager class documentation, and [`docs/ws2_funcs.md`](/docs/ws2_funcs.md) for documentation on the functions available for manipulating a connection instance.\n\n### Examples\n\nSubscribing to a candle channel:\n```js\nconst debug = require('debug')('bfx:api:core:examples:candles')\nconst { subscribe, Manager } = require('../')\n\nconst CANDLE_KEY = 'trade:1m:tBTCUSD'\n\ndebug('opening connection...')\n\nconst m = new Manager({ transform: true })\nconst wsState = m.openWS()\n\nm.on('ws2:open', () =\u003e debug('connection opened'))\nm.on('ws2:close', () =\u003e debug('connection closed'))\n\nm.on('ws2:candles', (candles, meta) =\u003e {\n  const { chanFilter } = meta\n  const { key } = chanFilter\n  const [candle] = candles\n  const nCandles = candles.length\n\n  debug('recv %d candles on key', nCandles, key)\n  debug(\n    'latest candle: open %d, high %d, low %d, close %d, volume: %d, mts: %s',\n    candle.open, candle.high, candle.low, candle.close, candle.volume,\n    new Date(candle.mts).toLocaleString()\n  )\n})\n\ndebug('subscribing to candles channel %s', CANDLE_KEY)\n\nsubscribe(wsState, 'candles', { key: CANDLE_KEY })\n```\n\nUsing a plugin:\n```js\nconst debug = require('debug')('bfx:api:core:examples:candles')\nconst Watchdog = require('bfx-api-node-plugin-wd')\nconst { Manager } = require('../')\n\nconst WATCHDOG_DELAY = 5 * 1000\n\ndebug('opening connection...')\n\nconst m = new Manager({\n  transform: true,\n  plugins: [Watchdog({ pachetWDDelay: WATCHDOG_DELAY })]\n})\n\nm.on('ws2:open', () =\u003e debug('connection opened'))\nm.on('ws2:reopen', () =\u003e debug('connection re-opened'))\nm.on('ws2:close', () =\u003e debug('connection closed'))\nm.openWS()\n\ndebug('awaiting watchdog trigger [no subscriptions]')\n```\n\n### Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfx-api-node-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfinexcom%2Fbfx-api-node-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfinexcom%2Fbfx-api-node-core/lists"}