{"id":18895639,"url":"https://github.com/binance/binance-futures-connector-node","last_synced_at":"2026-04-02T18:38:36.718Z","repository":{"id":199983722,"uuid":"699615039","full_name":"binance/binance-futures-connector-node","owner":"binance","description":"Simple NodeJS connector to Binance Futures API","archived":false,"fork":false,"pushed_at":"2025-04-25T12:17:00.000Z","size":288,"stargazers_count":39,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-04T19:53:42.402Z","etag":null,"topics":["binance-api","connector","crypto","futures","library","market-data","nodejs","real-time","trading"],"latest_commit_sha":null,"homepage":"","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/binance.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-03T01:35:53.000Z","updated_at":"2025-09-03T06:08:59.000Z","dependencies_parsed_at":"2025-04-15T01:14:09.560Z","dependency_job_id":"f96ec77d-62f9-43ba-8d5a-7a3288cc56a0","html_url":"https://github.com/binance/binance-futures-connector-node","commit_stats":null,"previous_names":["binance/binance-futures-connector-node"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/binance/binance-futures-connector-node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fbinance-futures-connector-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fbinance-futures-connector-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fbinance-futures-connector-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fbinance-futures-connector-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binance","download_url":"https://codeload.github.com/binance/binance-futures-connector-node/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fbinance-futures-connector-node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31313089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["binance-api","connector","crypto","futures","library","market-data","nodejs","real-time","trading"],"created_at":"2024-11-08T08:29:11.584Z","updated_at":"2026-04-02T18:38:36.706Z","avatar_url":"https://github.com/binance.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS Binance Futures Connector - DEPRECATED\n\n[![npm version](https://badge.fury.io/js/%40binance%2Ffutures-connector.svg)](https://badge.fury.io/js/%40binance%2Ffutures-connector)\n[![Node version](https://img.shields.io/node/v/%40binance%2Ffutures-connector.svg?style=flat)](http://nodejs.org/download/)\n[![Standard-Js](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**This repository is deprecated. Please use the new modular connector repository: [binance-connector-js](https://github.com/binance/binance-connector-js)**\n\nThis is a lightweight library that works as a connector to the UM and CM Binance Futures Endpoints. It’s designed to be simple, clean, and easy to use with minimal dependencies.\n\n- Supported APIs:\n  - /fapi/\\*\n  - /dapi/\\*\n  - UM Futures Websocket Market Stream\n  - CM Futures Websocket Market Stream\n  - UM Futures User Data Stream\n  - CM Futures User Data Stream\n- Inclusion of examples\n- Customisable base URL\n- Support request timeout and HTTP proxy\n- Response metadata can be displayed\n- Customisable Logger\n\n## Installation\n\n```bash\nnpm install @binance/futures-connector\n```\n\n## Documentation\n\n[https://binance.github.io/binance-futures-connector-node/](https://binance.github.io/binance-futures-connector-node/)\n\n## RESTful APIs\n\n```javascript\nconst { CMFutures } = require(\"@binance/futures-connector\");\n\nconst apiKey = \"\";\nconst apiSecret = \"\";\nconst cmFuturesClient = new CMFutures(apiKey, apiSecret, {\n  baseURL: \"https://dapi.binance.com\",\n});\n\ncmFuturesClient\n  .newOrder(\"BNBUSD_PERP\", \"BUY\", \"LIMIT\", {\n    timeInForce: \"GTC\",\n    quantity: 1,\n    price: 0.001,\n  })\n  .then((response) =\u003e console.log(response))\n  .catch(console.error);\n```\n\nPlease find `examples` folder to see the examples for more endpoints.\n\n## RSA Key based Authentication\n\n```javascript\nconst { UMFutures } = require(\"@binance/futures-connector\");\n\nconst apiKey = \"\";\nconst apiSecret = \"\"; // has no effect when RSA private key is provided\n\n// load private key\nconst privateKey = fs.readFileSync(\"/Users/john/ssl/private_key_encrypted.pem\");\nconst privateKeyPassphrase = \"password\";\n\nconst umFuturesClient = new UMFutures(apiKey, apiSecret, {\n  privateKey,\n  privateKeyPassphrase, // only used for encrypted key\n});\n\n// Get account information\numFuturesClient\n  .getAccountInformation()\n  .then((response) =\u003e client.logger.log(response.data));\n```\n\n### Testnet\n\nYou can use the testnet by adjusting the base URL:\n\n```javascript\n// provide the testnet base url\nconst umFuturesClient = new UMFutures(apiKey, apiSecret, {\n  baseURL: \"https://testnet.binancefuture.com\",\n});\n```\n\n### Base URL\n\nIf `baseURL` is not provided, it defaults to `fapi.binance.com`.\n\nIt's recommended to pass in the `baseURL` parameter to the constructor, so that it can easily be replaced with the testnet baseURL for testing/debugging.\n\n````javascript\n\n```javascript\n\n### Optional Parameters\n\nOptional parameters are encapsulated to a single object as the last function parameter.\n\n```javascript\nconst { UMFutures } = require('@binance/futures-connector')\n\nconst apiKey = ''\nconst apiSecret = ''\nconst client = new Spot(apiKey, apiSecret)\n\numFuturesClient.getAccountInformation({ recvWindow: 2000 }).then(response =\u003e umFuturesClient.logger.log(response.data))\n\n````\n\n### Timeout\n\nIt's easy to set timeout in milliseconds in request. If the request take longer than timeout, the request will be aborted. If it's not set, there will be no timeout.\n\n```javascript\nconst { UMFutures } = require(\"@binance/futures-connector\");\n\nconst apiKey = \"\";\nconst apiSecret = \"\";\nconst umFuturesClient = new UMFutures(apiKey, apiSecret, { timeout: 1000 });\n\nclient\n  .getAccountInformation()\n  .then((response) =\u003e umFuturesClient.logger.log(response.data))\n  .catch((error) =\u003e umFuturesClient.logger.error(error.message));\n```\n\n### Proxy\n\nThe `axios` package is used as the http client in this library. A proxy settings is passed into `axios` directly, the details can be found at [here](https://github.com/axios/axios#request-config):\n\n```javascript\nconst { UMFutures } = require(\"@binance/futures-connector\");\n\nconst apiKey = \"\";\nconst apiSecret = \"\";\nconst umFuturesClient = new UMFutures(apiKey, apiSecret, {\n  proxy: {\n    protocol: \"https\",\n    host: \"127.0.0.1\",\n    port: 9000,\n    auth: {\n      username: \"proxy_user\",\n      password: \"password\",\n    },\n  },\n});\n```\n\nYou may have a HTTP proxy, that can bring the problem that you need to make a HTTPS connection through the HTTP proxy. You can do that by build a HTTPS-over-HTTP tunnel by npm package [tunnel](https://www.npmjs.com/package/tunnel), and then pass the turnnel agent to `httpsAgent` in `axios`.\n\n```javascript\nconst tunnel = require(\"tunnel\");\n\nconst agent = tunnel.httpsOverHttp({\n  proxy: {\n    host: \"127.0.0.1\",\n    port: 3128,\n  },\n});\n\nconst umFuturesClient = new UMFutures(null, null, {\n  baseURL: \"https://fapi.binance.com\",\n  httpsAgent: agent,\n});\n\numFuturesClient\n  .getAccountInformation()\n  .then((response) =\u003e umFuturesClient.logger.log(response.data))\n  .catch((error) =\u003e umFuturesClient.logger.error(error));\n```\n\n[This comment](https://github.com/axios/axios/issues/925#issuecomment-359982190) provides more details.\n\n### Custom Logger Integration\n\n```javascript\nconst { UMFutures } = require(\"@binance/futures-connector\");\nconst fs = require(\"fs\");\nconst { Console } = require(\"console\");\n\n// make sure the logs/ folder is created beforehand\nconst output = fs.createWriteStream(\"./logs/stdout.log\");\nconst errorOutput = fs.createWriteStream(\"./logs/stderr.log\");\n\nconst logger = new Console({ stdout: output, stderr: errorOutput });\nconst umFuturesClient = new UMFutures(\"\", \"\", { logger: logger });\n\numFuturesClient\n  .getExchangeInfo()\n  .then((response) =\u003e umFuturesClient.logger.log(response.data));\n// check the output file\n```\n\nThe default logger defined in the package is [Node.js Console class](https://nodejs.org/api/console.html). Its output is sent to `process.stdout` and `process.stderr`, same as the global console.\n\n### Error\n\nThere are 2 types of error that may be returned from the API server and the user has to handle it properly:\n\n- `Client error`\n\n  - This is thrown when server returns `4XX`, it's an issue from client side.\n  - The following properties may be helpful to resolve the issue:\n    - Response header - Please refer to `Response Metadata` section for more details.\n    - HTTP status code\n    - Error code - Server's error code, e.g. `-1102`\n    - Error message - Server's error message, e.g. `Unknown order sent.`\n    - Request config - Configuration send to the server, which can include URL, request method and headers.\n\n  ```\n  // client initialization is skipped\n  client.exchangeInfo({ symbol: 'invalidSymbol' })\n    .then(response =\u003e client.logger.log(response.data))\n    .catch(err =\u003e {\n      client.logger.error(err.response.headers) // full response header\n      client.logger.error(err.response.status) // HTTP status code 400\n      client.logger.error(err.response.data) // includes both error code and message\n      client.logger.error(err.response.config) // includes request's config\n    })\n\n  ```\n\n- `Server error`\n  - This is thrown when server returns `5XX`, it's an issue from server side.\n\n## Websocket\n\nThe WebSocket URLs for the available futures environments are as follows:\n\n- Testnet CM: wss://dstream.binancefuture.com\n- Testnet UM: wss://stream.binancefuture.com\n- Main CM: wss://dstream.binance.com\n- Main UM: wss://fstream.binance.com\n\n### Websocket Streams\n\nYou can connect to the WebSocket stream using the UMStream Module (for USD-M Futures). Here is an example:\n\n```javascript\nconst { UMStream } = require(\"@binance/futures-connector\");\nconst logger = new Console({ stdout: process.stdout, stderr: process.stderr });\n\n// Define callbacks for different events\nconst callbacks = {\n  open: () =\u003e logger.debug(\"Connected with Websocket server\"),\n  close: () =\u003e logger.debug(\"Disconnected with Websocket server\"),\n  message: (data) =\u003e logger.info(data),\n};\n\n// Create a new WebSocket client with the wsURL (Websocket URL) defined\nconst umWebsocketStreamClient = new UMStream({\n  logger,\n  callbacks,\n  wsURL: \"wss://fstream.binance.com\",\n});\n\n// Subscribe to the allMarketMiniTickersStream stream\numWebsocketStreamClient.allMarketMiniTickersStream(\"bnbusdt_perp\");\n\n// Close the WebSocket stream after 6 seconds\nsetTimeout(() =\u003e umWebsocketStreamClient.disconnect(), 6000);\n```\n\n### Unsubscribe Websocket Stream\n\nYou can unsubscribe from a WebSocket stream as follows:\n\n```javascript\numWebsocketStreamClient.unsubscribe(\"bnbusdt_perp@kline_1m\");\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinance%2Fbinance-futures-connector-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinance%2Fbinance-futures-connector-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinance%2Fbinance-futures-connector-node/lists"}