{"_id":"@bitfinex/bfx-facs-http","_rev":"5-e1b2299aae5afe9342801f8cedf3eed4","name":"@bitfinex/bfx-facs-http","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.0":{"name":"@bitfinex/bfx-facs-http","version":"1.0.0","keywords":["bitfinex","http","facility"],"author":{"name":"vigan.abd"},"license":"Apache-2.0","_id":"@bitfinex/bfx-facs-http@1.0.0","maintainers":[{"name":"vigan-abd","email":"vigan.abd@gmail.com"},{"name":"bitfinexorg","email":"paolo@bitfinex.com"},{"name":"prdn","email":"paolo.ardoino@gmail.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"homepage":"https://github.com/bitfinexcom/bfx-facs-http","bugs":{"url":"https://github.com/bitfinexcom/bfx-facs-http/issues"},"dist":{"shasum":"e89b6a95798ec0fa57b0956430ce8a695a10110d","tarball":"https://registry.npmjs.org/@bitfinex/bfx-facs-http/-/bfx-facs-http-1.0.0.tgz","fileCount":9,"integrity":"sha512-WWEuufj9KauElg0eIsYRYQvd5vkT/vBtvx5JwAHl4bdUMM8lISLhMAlclUOK8ddcK+l76niO+nJw2hCPefkHtg==","signatures":[{"sig":"MEYCIQCvnvoXnQklXoHmx5UYPxz+2iO3ukUXvAlB+v9y6gpnRAIhANbr4ZoODd/MYQ8IT9gMwLsjAwUxW0A4UfCJ/lK0gjUQ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55456},"main":"index.js","engines":{"node":">=16.0"},"gitHead":"850fee8051e0045c8647a95ea152969e3d00f397","scripts":{"lint":"standard","test":"npm run lint && npm run unit","unit":"NODE_ENV=test mocha ./test","format":"standard --fix","coverage":"nyc --reporter=html mocha"},"_npmUser":{"name":"vigan-abd","email":"vigan.abd@gmail.com"},"repository":{"url":"git+https://github.com/bitfinexcom/bfx-facs-http.git","type":"git"},"_npmVersion":"10.7.0","description":"Bitfinex HTTP Facility","directories":{},"_nodeVersion":"18.20.4","dependencies":{"async":"^2.6.3","lodash":"^4.17.21","node-fetch":"2.6.7","@bitfinex/bfx-facs-base":"git+https://github.com/bitfinexcom/bfx-facs-base.git"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.4","mocha":"^11.7.5","sinon":"^11.1.2","express":"^4.17.1","standard":"^17.1.0","dirty-chai":"^2.0.1","chai-as-promised":"^7.1.1"},"_npmOperationalInternal":{"tmp":"tmp/bfx-facs-http_1.0.0_1765397044992_0.5198125168085017","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@bitfinex/bfx-facs-http","version":"1.1.0","keywords":["bitfinex","http","facility"],"author":{"name":"vigan.abd"},"license":"Apache-2.0","_id":"@bitfinex/bfx-facs-http@1.1.0","maintainers":[{"name":"vigan-abd","email":"vigan.abd@gmail.com"},{"name":"bitfinexorg","email":"paolo@bitfinex.com"},{"name":"prdn","email":"paolo.ardoino@gmail.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"homepage":"https://github.com/bitfinexcom/bfx-facs-http","bugs":{"url":"https://github.com/bitfinexcom/bfx-facs-http/issues"},"dist":{"shasum":"1d9b3d4682e41892e23c9f8e00db1ba6976e716c","tarball":"https://registry.npmjs.org/@bitfinex/bfx-facs-http/-/bfx-facs-http-1.1.0.tgz","fileCount":9,"integrity":"sha512-1Md3KtSxpuRE9HQ8PTGKMUyQ8VeYQe6L9I7i8Hr0wl4blRlT/0G5ilcv1QILUppubdsX3HZXRA87uKt/FHRNkA==","signatures":[{"sig":"MEUCIQC5XdjO/xOpcdjSUiTYuRGpcIUtK212kONBemgB3T17LwIgJZQBzkCXrU23Smt2AUgXGuGxt+IDInZSNnjLOnv+dmE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":61538},"main":"index.js","engines":{"node":">=16.0"},"gitHead":"a605a4d29f46ddc23f4e9bd70373d0ef8dd18fdb","scripts":{"lint":"standard","test":"npm run lint && npm run unit","unit":"NODE_ENV=test mocha ./test","format":"standard --fix","coverage":"nyc --reporter=html mocha"},"_npmUser":{"name":"vigan-abd","email":"vigan.abd@gmail.com"},"repository":{"url":"git+https://github.com/bitfinexcom/bfx-facs-http.git","type":"git"},"_npmVersion":"11.12.1","description":"Bitfinex HTTP Facility","directories":{},"_nodeVersion":"24.15.0","dependencies":{"async":"^2.6.3","lodash":"^4.17.21","node-fetch":"2.6.7","cacheable-lookup":"7.0.0","@bitfinex/bfx-facs-base":"git+https://github.com/bitfinexcom/bfx-facs-base.git"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.4","mocha":"^11.7.5","sinon":"^11.1.2","express":"^4.17.1","standard":"^17.1.0","dirty-chai":"^2.0.1","chai-as-promised":"^7.1.1"},"_npmOperationalInternal":{"tmp":"tmp/bfx-facs-http_1.1.0_1779806975140_0.767749791191705","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@bitfinex/bfx-facs-http","version":"1.1.1","keywords":["bitfinex","http","facility"],"author":{"name":"vigan.abd"},"license":"Apache-2.0","_id":"@bitfinex/bfx-facs-http@1.1.1","maintainers":[{"name":"vigan-abd","email":"vigan.abd@gmail.com"},{"name":"bitfinexorg","email":"paolo@bitfinex.com"},{"name":"prdn","email":"paolo.ardoino@gmail.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"homepage":"https://github.com/bitfinexcom/bfx-facs-http","bugs":{"url":"https://github.com/bitfinexcom/bfx-facs-http/issues"},"dist":{"shasum":"7bcf2c232876cd9a3409ac72980232e830243f05","tarball":"https://registry.npmjs.org/@bitfinex/bfx-facs-http/-/bfx-facs-http-1.1.1.tgz","fileCount":9,"integrity":"sha512-61RK1YZJFy8m+e7mot8dungrPDapTXoNWHv5DgjPd2npYDrXl+BG5rWlJydc8CUqG/3Rfsb6firEFRujrpppYA==","signatures":[{"sig":"MEYCIQCIotbVDTVkioU0FQFZgUMy29DYa0A2nPmfaCvk/X5sYgIhANCGSuyeLN0AvAcHM9hvaeJCY7I8d2IfO2gX3tTtTkzh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":61732},"main":"index.js","engines":{"node":">=16.0"},"gitHead":"e327de5d767b36eea0e964e3d2bfb18b9265cc5b","scripts":{"lint":"standard","test":"npm run lint && npm run unit","unit":"NODE_ENV=test mocha ./test","format":"standard --fix","coverage":"nyc --reporter=html mocha"},"_npmUser":{"name":"vigan-abd","email":"vigan.abd@gmail.com"},"repository":{"url":"git+https://github.com/bitfinexcom/bfx-facs-http.git","type":"git"},"_npmVersion":"11.12.1","description":"Bitfinex HTTP Facility","directories":{},"_nodeVersion":"24.15.0","dependencies":{"async":"^2.6.3","lodash":"^4.17.21","node-fetch":"2.6.7","cacheable-lookup":"6.1.0","@bitfinex/bfx-facs-base":"git+https://github.com/bitfinexcom/bfx-facs-base.git"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.4","mocha":"^11.7.5","sinon":"^11.1.2","express":"^4.17.1","standard":"^17.1.0","dirty-chai":"^2.0.1","chai-as-promised":"^7.1.1"},"_npmOperationalInternal":{"tmp":"tmp/bfx-facs-http_1.1.1_1784831705861_0.202501904056539","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@bitfinex/bfx-facs-http","version":"1.1.2","keywords":["bitfinex","http","facility"],"author":{"name":"vigan.abd"},"license":"Apache-2.0","_id":"@bitfinex/bfx-facs-http@1.1.2","maintainers":[{"name":"vigan-abd","email":"vigan.abd@gmail.com"},{"name":"bitfinexorg","email":"paolo@bitfinex.com"},{"name":"prdn","email":"paolo.ardoino@gmail.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"homepage":"https://github.com/bitfinexcom/bfx-facs-http","bugs":{"url":"https://github.com/bitfinexcom/bfx-facs-http/issues"},"dist":{"shasum":"94e7ebd8f721124ed37ca94a61dc5379fdf0ac95","tarball":"https://registry.npmjs.org/@bitfinex/bfx-facs-http/-/bfx-facs-http-1.1.2.tgz","fileCount":9,"integrity":"sha512-04tOKSM5tC/OeVRtl9o0jOid04PNpv5Vwe0P3EwC+FwfKERzc2vZjaIUaoysYSSkseUOk+kGAh6G9tyCh1PiVw==","signatures":[{"sig":"MEUCIQDGWF2oAhJqf1wZjpjPxQeR0SDcOfO/Ale0R7D3M+ByMQIgKQ85ZlYq+LQc8poIyZXOk8VZiHuN2JkZwnRYO7fuI24=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":62349},"main":"index.js","engines":{"node":">=16.0"},"gitHead":"139e4882aec60915525f643d03db4319a38ef840","scripts":{"lint":"standard","test":"npm run lint && npm run unit","unit":"NODE_ENV=test mocha ./test","format":"standard --fix","coverage":"nyc --reporter=html mocha"},"_npmUser":{"name":"vigan-abd","email":"vigan.abd@gmail.com"},"repository":{"url":"git+https://github.com/bitfinexcom/bfx-facs-http.git","type":"git"},"_npmVersion":"11.12.1","description":"Bitfinex HTTP Facility","directories":{},"_nodeVersion":"24.15.0","dependencies":{"async":"^2.6.3","lodash":"^4.17.21","node-fetch":"2.6.7","cacheable-lookup":"6.1.0","@bitfinex/bfx-facs-base":"git+https://github.com/bitfinexcom/bfx-facs-base.git"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","chai":"^4.3.4","mocha":"^11.7.5","sinon":"^11.1.2","express":"^4.17.1","standard":"^17.1.0","dirty-chai":"^2.0.1","chai-as-promised":"^7.1.1"},"_npmOperationalInternal":{"tmp":"tmp/bfx-facs-http_1.1.2_1786377622328_0.20146108370388638","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"@bitfinex/bfx-facs-http","version":"1.1.3","description":"Bitfinex HTTP Facility","author":{"name":"vigan.abd"},"keywords":["bitfinex","http","facility"],"scripts":{"coverage":"nyc --reporter=html mocha","lint":"standard","format":"standard --fix","test":"npm run lint && npm run unit","unit":"NODE_ENV=test mocha ./test"},"dependencies":{"@bitfinex/bfx-facs-base":"^1.1.0","async":"^2.6.3","cacheable-lookup":"6.1.0","lodash":"^4.17.21","node-fetch":"2.6.7"},"engines":{"node":">=16.0"},"main":"index.js","license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/bitfinexcom/bfx-facs-http.git"},"homepage":"https://github.com/bitfinexcom/bfx-facs-http","maintainers":[{"name":"vigan-abd","email":"vigan.abd@gmail.com"},{"name":"bitfinexorg","email":"paolo@bitfinex.com"},{"name":"prdn","email":"paolo.ardoino@gmail.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"devDependencies":{"chai":"^4.3.4","chai-as-promised":"^7.1.1","dirty-chai":"^2.0.1","express":"^4.17.1","mocha":"^11.7.5","nyc":"^15.1.0","sinon":"^11.1.2","standard":"^17.1.0"},"gitHead":"7e6982ca39ff4f61d74baab2f9a3558ab30067e0","_id":"@bitfinex/bfx-facs-http@1.1.3","bugs":{"url":"https://github.com/bitfinexcom/bfx-facs-http/issues"},"_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-t0sewDYbgYHTjW9Kuy9L9keXGgR33QLXL1L92RgQ1Krxgg7NKaUuvfir05uWO+wlPnYMCq/v8F0kihGiwPu9Bw==","shasum":"14c787c8cc92b99753748392a86ebb13dc8280c2","tarball":"https://registry.npmjs.org/@bitfinex/bfx-facs-http/-/bfx-facs-http-1.1.3.tgz","fileCount":9,"unpackedSize":62303,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGluWApWVeJfjq25QckWVvnSxz3EgfRG70zrheIwYaUFAiEA0q3g1GuwbG++qsjhYmlksLHNZiWbsd1WliOgeLSUco8="}]},"_npmUser":{"name":"vigan-abd","email":"vigan.abd@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bfx-facs-http_1.1.3_1787298341859_0.0800112624572471"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-10T20:04:04.933Z","modified":"2026-08-21T07:45:42.178Z","1.0.0":"2025-12-10T20:04:05.133Z","1.1.0":"2026-05-26T14:49:35.274Z","1.1.1":"2026-07-23T18:35:06.011Z","1.1.2":"2026-08-10T16:00:22.477Z","1.1.3":"2026-08-21T07:45:41.987Z"},"bugs":{"url":"https://github.com/bitfinexcom/bfx-facs-http/issues"},"author":{"name":"vigan.abd"},"license":"Apache-2.0","homepage":"https://github.com/bitfinexcom/bfx-facs-http","keywords":["bitfinex","http","facility"],"repository":{"type":"git","url":"git+https://github.com/bitfinexcom/bfx-facs-http.git"},"description":"Bitfinex HTTP Facility","maintainers":[{"name":"vigan-abd","email":"vigan.abd@gmail.com"},{"name":"bitfinexorg","email":"paolo@bitfinex.com"},{"name":"prdn","email":"paolo.ardoino@gmail.com"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"readme":"# bfx-facs-http\n\nA facility that simplifies making http requests both on promise and callback approaches.\n\n## Config\n\nFac doesn't support config files but supports the options defined below:\n- `baseUrl<String?>` - Optional base url\n- `timeout<Number?>` - Optional request timeout, default one is node default timeout (0)\n- `abortTimeout<Number?>` - Optional abort timeout in ms, auto-creates an AbortController that aborts the request after the specified duration. Default is 0 (disabled). Per-request `abortTimeout` overrides this value. Ignored when caller provides their own `signal`\n- `debug<(Boolean|Number)?>` - Optional debug flag, default false\n- `qs<(String|Array<String>|Object)?>` - Optional, default query string params\n- `dnsCaching<Boolean?>` - Option dns caching, disabled by default\n\n## API\n\n### fac.request\n\nPerforms generic HTTP request\n\nParams:\n  - `path<String>` - Full request url or path\n  - `opts<Object?>` - Optional request options\n    - `body<(String|Object)?>` - Optional request body, in case of json encoding it can be also object\n    - `headers<Object<String, String>?>` Optional request headers\n    - `method<String?>` - Optional http method, currently supported `get`, `head`, `post`, `put`, `patch`,\n                         `delete`, `options`. Default value is `get`\n    - `redirect<Boolean?>` - Optional, follow redirects or treat them as errors, default is treat as error\n    - `auth<Object?>` - HTTP Basic authorization credentials. Overwrites header `authorization`. Please note\n                        only HTTP Basic auth is configurable through this parameter.\n      - `username<String?>`\n      - `password<String?>`\n    - `agent<http.Agent?>` - Optional user agent\n    - `compress<Boolean?>` - Optional, support gzip/deflate content encoding\n    - `timeout<Number?>` - Optional request timeout, default is opt provided in fac setup (3s)\n    - `encoding<(String|Object)?>` - Optional request and response encoding,\n                                     if string is provided it applies to both request and response.\n                                     Default encoding is text for both request and response\n      - `req<String?>` - Optional request body encoding, supported: `json` and `text`. \n                         If no value is provided it will be treated as text\n      - `res<String?>` - Optional response body encoding, supported: `json`, `text` and `raw`. \n                         If no value is provided it will be treated as text,\n                         if unsupported value is provided it will return buffer.\n                         If value is `raw` then body stream is returned, useful for file downloads\n    - `qs<(String|Array<String>|Object)?>` - Optional, query string params\n    - `signal<AbortSignal?>` - Optional, abort controller signal\n    - `abortTimeout<Number?>` - Optional abort timeout in ms for this request, overrides facility-level `abortTimeout`. Ignored when `signal` is provided\n    - `dnsCaching<Boolean?>` - Optional, enable dns caching\n  - `cb<Function?>` - Optional callback function, if not provided call will be treated as promise\n\nResponse:\n  - `Promise<{ body: any, headers: object }>|void` - Server response, promise or callback result\n\nExamples:\n```js\n// GET\nconst { body, headers } = await fac.request('https://example.com')\n\n// POST\nconst { body, headers } = await fac.request('https://example.com/submit', { method: 'post', body: { foo: 'bar' }, encoding: 'json' })\n\n// OPTIONS\nconst { headers } = await fac.request('https://api-pub.bitfinex.com/v2/conf/pub:list:currency', { method: 'options' })\n\n// Callback\nfac.request(\n  '/data/store',\n  { method: 'patch', body: 'test=33&foo=bar', headers: { 'content-type': 'application/x-www-form-urlencoded' } },\n  (err, resp) => {\n    ...\n  })\n\n// Request without options\nfac.request('/data', (err, resp) => {\n  ...\n})\n\n// error handling\nfac.request('/data/store', (err) => {\n  console.log(err.message) // ERR_HTTP: 500 - Internal Server Error\n  console.log(err.status) // 500\n  console.log(err.statusText) // Internal Server Error\n  console.log(err.response) // { auth: 'failed' }\n})\n\n// file download\nconst stream = require('stream')\n\nconst { body: resp } = await fac.request('/file', { encoding: { res: 'raw' } }) // raw means return stream\nawait new Promise((resolve, reject) => {\n  stream.pipeline(resp, fs.createWriteStream(writefile), (err) => err ? reject(err) : resolve())\n})\n\n// abort signal\nconst abortController = new AbortController()\nsetTimeout(() => {\n  abortController.abort()\n}, 1000)\n\nconst { body: resp } = await fac.request('/data', { signal: abortController.signal })\n\n// abort timeout (auto-creates AbortController)\nconst { body: resp } = await fac.request('/data', { abortTimeout: 5000 })\n```\n\n### fac.get\n\nPerforms HTTP GET request\n\nParams:\n- Same as in request method just without `method` param\n\nResponse:\n- Same as in request method\n\nExample:\n```js\nawait fac.get('https://api-pub.bitfinex.com/v2/conf/pub:list:currency')\n```\n\n### fac.post\n\nPerforms HTTP POST request\n\nParams:\n- Same as in request method just without `method` param\n\nResponse:\n- Same as in request method\n\nExample:\n```js\nconst FormData = require('form-data')\n\nconst form = new FormData();\nform.append('a', 1);\n\nconst reqOpts = {\n  body: form,\n  headers: form.getHeaders()\n}\n\nawait fac.post('/submit', reqOpts)\n```\n\n### fac.put\n\nPerforms HTTP PUT request\n\nParams:\n- Same as in request method just without `method` param\n\nResponse:\n- Same as in request method\n\nExample:\n```js\nconst reqOpts = {\n  body: JSON.stringify({ a: 1 }),\n  headers: {\n    'Content-Type': 'application/json'\n  }\n}\n\nawait fac.put('/data/store', reqOpts)\n```\n\n### fac.patch\n\nPerforms HTTP PATCH request\n\nParams:\n- Same as in request method just without `method` param\n\nResponse:\n- Same as in request method\n\nExample:\n```js\nconst reqOpts = {\n  body: { a: 1 },\n  encoding: 'json'\n}\n\nawait fac.patch('/data/store', reqOpts)\n```\n\n### fac.delete\n\nPerforms HTTP DELETE request\n\nParams:\n- Same as in request method just without `method` param\n\nResponse:\n- Same as in request method\n\nExample:\n```js\nconst reqOpts = {\n  body: JSON.stringify({ id: 31 }),\n  headers: {\n    'Content-Type': 'application/json'\n  }\n}\n\nawait fac.delete('/books', reqOpts)\n```\n\n### fac.head\n\nPerforms HTTP HEAD request\n\nParams:\n- Same as in request method just without `method` param\n\nResponse:\n- HTTP response headers\n\nExample:\n```js\nconst { headers } = await fac.head('https://api-pub.bitfinex.com/v2/conf/pub:list:currency')\nconsole.log(headers['content-type']) // 'application/json; charset=utf-8'\n```\n\n### fac.options\n\nPerforms HTTP OPTIONS request\n\nParams:\n- Same as in request method just without `method` param\n\nResponse:\n- HTTP response headers\n\nExample:\n```js\nconst { headers } = await fac.head('https://api-pub.bitfinex.com/v2/conf/pub:list:currency')\nconsole.log(headers['allow']) // 'GET,PUT,POST'\n```\n","readmeFilename":"README.md"}