{"id":24290171,"url":"https://github.com/dutu/poloniex-api-node","last_synced_at":"2025-04-05T07:06:08.979Z","repository":{"id":11561113,"uuid":"69505919","full_name":"dutu/poloniex-api-node","owner":"dutu","description":"Poloniex API client for REST and WebSocket API","archived":false,"fork":false,"pushed_at":"2023-09-27T23:00:37.000Z","size":17712,"stargazers_count":141,"open_issues_count":2,"forks_count":59,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-29T06:07:17.054Z","etag":null,"topics":["api","callback","node-wrapper","poloniex","poloniex-api","promise","rest","rest-api","websocket","websocket-api","websocket-client"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/poloniex-api-node","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/dutu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2016-09-28T21:38:50.000Z","updated_at":"2024-11-06T18:50:16.000Z","dependencies_parsed_at":"2024-06-18T15:23:21.308Z","dependency_job_id":"459f3d0f-d741-4f43-9298-de4a745aa889","html_url":"https://github.com/dutu/poloniex-api-node","commit_stats":{"total_commits":114,"total_committers":15,"mean_commits":7.6,"dds":0.4736842105263158,"last_synced_commit":"203848c0c26257a0ed5c10fb5f8ac66db051a29b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutu%2Fpoloniex-api-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutu%2Fpoloniex-api-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutu%2Fpoloniex-api-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutu%2Fpoloniex-api-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dutu","download_url":"https://codeload.github.com/dutu/poloniex-api-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"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":["api","callback","node-wrapper","poloniex","poloniex-api","promise","rest","rest-api","websocket","websocket-api","websocket-client"],"created_at":"2025-01-16T11:16:34.052Z","updated_at":"2025-04-05T07:06:08.954Z","avatar_url":"https://github.com/dutu.png","language":"JavaScript","readme":"poloniex-api-node\n=======\n[![Tests](https://github.com/dutu/poloniex-api-node/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/dutu/poloniex-api-node/actions/workflows/nodejs-ci.yml) \n\n\n**poloniex-api-node** is a simple node.js wrapper for Poloniex REST and WebSocket API.\n\n### Contents\n* [Changelog](#changelog)\n* [Install](#install)\n* [Usage](#usage)\n\t* [Constructor](#constructor)\n\t* [REST API](#rest-api)\n\t* [WebSocket API](#websocket-api)\n* [Contributors](#contributors)\n* [License](#license)\n\n# Changelog\n\nSee detailed [GitHub Releases](https://github.com/dutu/poloniex-api-node/releases)\n\n## Breaking changes introduced in version 3.0.0\n\nLegacy Poloniex API is no longer supported.\nPoloniex has announced that **the legacy API is slated to be decommissioned on Jan 31st, 2023**.\nModule supporting the legacy API has been moved to [branch legacy_API](https://github.com/dutu/poloniex-api-node/tree/legacy_API), and it is not longer maintained. \n\n# Install\n\n    npm install --save poloniex-api-node\n\n# Usage\n\n## Constructor\n\n* `new Poloniex({ apiKey, apiSecret })`\n\nTo access the private Poloniex API methods you must supply your API key id and key secret. If you are only accessing the public API endpoints, you can leave the parameter out.\n\nExamples:\n\n```js\nconst poloniex = new Poloniex({ apiKey: 'myKey', apiSecret: 'mySecret' })\n```\n\n## REST API\n\n### Properties\n* `apiCallRateLimits` - API call rate limits for endpoints sets (resource-intensive and non-resource-intensive private and public endpoints)\n\n\tExample output:\n\t```javascript\n  {\n    riPub: 10,\n    nriPub: 200,\n    nriPriv: 50,\n    riPriv: 10\n  }\n  ```\n\n* `apiCallRates` - Current call rate for resource-intensive and non-resource-intensive private and public API calls\n\n\tExample output:\n\t```javascript\n  {\n    riPub: 8,\n    nriPub: 100,\n    nriPriv: 5,\n    riPriv: 7\n  }\n  ```\nSee https://docs.poloniex.com/#rate-limits.\n\n### Methods\n\nAll methods accept one object parameter, which is used to pass all request parameters for the API call.\n\n[Official Poloniex API documentation](https://docs.poloniex.com/) lists all valid **Request Parameters** for API calls. \nWhen a **Request Parameter** needs to be included, a property with the exact same name needs to be added to the object parameter.\n\n\nAll methods return a promise.\n\nExample:\n\n```js\nimport Poloniex from 'poloniex-api-node'\nlet poloniex = new Poloniex({ apiKey: 'myKey', apiSecret: 'mySecret' })\n\nconst tradesHistory = poloniex.getTradesHistory({ limit: 1000, symbols: 'BTC_USDT' })\n  .then((result) =\u003e console.log(result))\n  .catch((err) =\u003e console.log(err))\n```\n\nAn optional property `getApiCallRateInfo` can be specified. When set to `true` the corresponding API call is not sent to the exchange, instead the current API call rate is returned. See [rate limits](https://docs.poloniex.com/#rate-limits).\n\nExample:\n\n```js\nconst callRateInfo = poloniex.getTradesHistory({ limit: 1000, symbols: 'BTC_USDT', getApiCallRateInfo: true })\n```\nExample output: \n```javascript\n[\n 'riPriv', // id of the API endpoind set (can be 'riPub', 'nriPub', 'riPriv' or 'nriPriv')  \n 2,        // current API call rate\n 10        // API call rate limit\n]\n```\n\n### Public API Methods\n\n#### Reference Data\n* [`getSymbols`](https://docs.poloniex.com/#public-endpoints-reference-data-symbol-information) - get symbols and their trade info\n* [`getCurrencies`](https://docs.poloniex.com/#public-endpoints-reference-data-currency-information) - get supported currencies\n* [`getTimestamp`](https://docs.poloniex.com/#public-endpoints-reference-data-system-timestamp) - get current server time\n\n#### Market Data\n * [`getPrices`](https://docs.poloniex.com/#public-endpoints-market-data-prices) - get the latest trade price for symbols\n * [`getMarkPrice`](https://docs.poloniex.com/#public-endpoints-market-data-mark-price) - get the latest mark price for cross margin symbols\n * [`getMarkPriceComponents`](https://docs.poloniex.com/#public-endpoints-market-data-mark-price-components) - get components of the mark price for a given symbol\n * [`getOrderBook`](https://docs.poloniex.com/#public-endpoints-market-data-order-book) - get the order book for a given symbol\n * [`getCandles`](https://docs.poloniex.com/#public-endpoints-market-data-candles) - returns OHLC for a symbol at given timeframe (interval)\n * [`getTrades`](https://docs.poloniex.com/#public-endpoints-market-data-trades) - returns a list of recent trades\n * [`getTicker`](https://docs.poloniex.com/#public-endpoints-market-data-ticker) - returns ticker in last 24 hours for all symbols\n\n#### Margin\n * [`getCollateralInfo`](https://docs.poloniex.com/#public-endpoints-margin-collateral-info) - get collateral information for currencies\n * [`getBorrowRatesInfo`](https://docs.poloniex.com/#public-endpoints-margin-borrow-rates-info) - get borrow rates information for all tiers and currencies\n\n\n### Authenticated API Methods\n#### Accounts\n * [`getAccountsInfo`](https://docs.poloniex.com/#authenticated-endpoints-accounts-account-information) - get a list of all accounts of a use\n * [`getAccountsBalances`](https://docs.poloniex.com/#authenticated-endpoints-accounts-all-account-balances) - get a list of accounts of a user with each account’s id, type and balances\n * [`getAccountsActivity`](https://docs.poloniex.com/#authenticated-endpoints-accounts-account-activity) - get a list of activities such as airdrop, rebates, staking, credit/debit adjustments, and other (historical adjustments)\n * [`accountsTransfer`](https://docs.poloniex.com/#authenticated-endpoints-accounts-accounts-transfer) - transfer amount of currency from an account to another account for a user\n * [`getAccountsTransferRecords`](https://docs.poloniex.com/#authenticated-endpoints-accounts-accounts-transfer-records) - get a list of transfer records of a user\n * [`getFeeInfo`](https://docs.poloniex.com/#authenticated-endpoints-accounts-fee-info) - get fee rate\n\n#### Subaccounts\n * [`getSubaccountsInfo`](https://docs.poloniex.com/#authenticated-endpoints-subaccounts-subaccount-information) - get a list of all the accounts within an Account Group for a user\n * [`getSubaccountsBalances`](https://docs.poloniex.com/#authenticated-endpoints-subaccounts-subaccount-balances) - get balances information by currency and account type\n * [`subaccountsTransfer`](https://docs.poloniex.com/#authenticated-endpoints-subaccounts-subaccount-transfer) - transfer amount of currency from an account and account type to another account and account type among the accounts in the account group\n * [`getSubaccountsTransferRecords`](https://docs.poloniex.com/#authenticated-endpoints-subaccounts-subaccount-transfer-records) - get a list of transfer records of a user\n\n#### Wallets\n * [`getDepositAddresses`](https://docs.poloniex.com/#authenticated-endpoints-wallets-deposit-addresses) - get deposit addresses for a user\n * [`getWalletsActivityRecords`](https://docs.poloniex.com/#authenticated-endpoints-wallets-wallets-activity-records) - get deposit and withdrawal activity history\n * [`createNewCurrencyAddress`](https://docs.poloniex.com/#authenticated-endpoints-wallets-new-currency-address) - Create a new address for a currency\n * [`withdrawCurrency`](https://docs.poloniex.com/#authenticated-endpoints-wallets-withdraw-currency) - immediately places a withdrawal for a given currency\n\n#### Margin\n * [`getMarginAccountInfo`](https://docs.poloniex.com/#authenticated-endpoints-margin-account-margin) - get account margin information\n * [`getMarginBorrowStatus`](https://docs.poloniex.com/#authenticated-endpoints-margin-borrow-status) - get borrow status of currencies\n * [`getMarginMaxSize`](https://docs.poloniex.com/#authenticated-endpoints-margin-maximum-buy-sell-amount) - get maximum and available buy/sell amount for a given symbol\n\n#### Orders\n * [`createOrder`](https://docs.poloniex.com/#authenticated-endpoints-orders-create-order) - create an order for an account\n * [`createBatchOrders`](https://docs.poloniex.com/#authenticated-endpoints-orders-create-multiple-orders) - create multiple orders via a single request\n * [`replaceOrder`](https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-replace-order) - cancel an existing active order, new or partially filled, and place a new order\n * [`getOpenOrders`](https://docs.poloniex.com/#authenticated-endpoints-orders-open-orders) - get a list of active orders for an account\n * [`getOrderDetails`](https://docs.poloniex.com/#authenticated-endpoints-orders-order-details) - get an order’s status\n * [`cancelOrder`](https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-order-by-id) - cancel an active order\n * [`cancelBatchOrders`](https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-multiple-orders-by-ids) - batch cancel one or many active orders in an account by IDs\n * [`cancelAllOrders`](https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-all-orders) - cancel all orders in an account\n * [`setKillSwitch`](https://docs.poloniex.com/#authenticated-endpoints-orders-kill-switch) - set a timer that cancels all regular and smartorders after the timeout has expired\n * [`getKillSwitchStatus`](https://docs.poloniex.com/#authenticated-endpoints-orders-kill-switch-status) - get status of kill switch\n\n#### Smart Orders\n * [`createSmartOrder`](https://docs.poloniex.com/#authenticated-endpoints-smart-orders-create-order) - create a smart order for an account\n * [`replaceSmartOrder`](https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-replace-order) - cancel an existing untriggered smart order and place a new smart order\n * [`getSmartOpenOrders`](https://docs.poloniex.com/#authenticated-endpoints-smart-orders-open-orders) - get a list of (pending) smart orders for an account\n * [`getSmartOrderDetails`](https://docs.poloniex.com/#authenticated-endpoints-smart-orders-order-details) - get a smart order’s status\n * [`cancelSmartOrder`](https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-order-by-id) - cancel a smart order\n * [`cancelBatchSmartOrders`](https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-multiple-orders-by-id) - batch cancel one or many smart orders in an account by IDs\n * [`cancelAllSmartOrders`](https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-all-orders) - batch cancel all smart orders in an account\n\n#### Order History\n * [`getOrdersHistory`](https://docs.poloniex.com/#authenticated-endpoints-order-history-orders-history) - get a list of historical orders in an account\n * [`getSmartOrdersHistory`](https://docs.poloniex.com/#authenticated-endpoints-order-history-smart-orders-history) - get a list of historical smart orders in an account\n\n#### Trades\n * [`getTradesHistory`](https://docs.poloniex.com/#authenticated-endpoints-trades-trade-history) - get a list of all trades for an account\n * [`getOrderTrades`](https://docs.poloniex.com/#authenticated-endpoints-trades-trades-by-order-id) - get a list of all trades for an order specified by its orderId\n\n\n## Websocket API\n\nThe module uses [forever-websocket](https://github.com/dutu/forever-websocket) to connect to Poloniex websocket server.  \n`ForeverWebSocket` extends [`WebSocket`](https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocket), and in additions supports:\n* automatic reconnection\n* configurable reconnecting timers\n* configurable timeouts and reconnects when no message received\n* automatic pings to keep connection alive\n\n### Connection\n\n* `newPublicWebSocket(options)` - establishes a WebSocket connection for public channels  \n* `newAuthenticatedWebSocket(options)` - establishes a WebSocket connection for authenticated channels\n\n`options` parameter properties (check [`ForeverWebSocket`](https://github.com/dutu/forever-websocket) for additional explanations):\n\nProperty name | Type            | Attributes | Default                                                                     | Description\n--------------|-----------------|------------|-----------------------------------------------------------------------------|--------------\n`reconnect` | object or `null` | optional | `{ factor: 1.5, initialDelay: 50, maxDelay: 10000, randomizeDelay: false }` | Reconnecting parameters. Defaults to exponential backoff strategy \n`timeout` | number          | optional | no timeout\t                                                                 | Timeout in milliseconds after which the websockets reconnects when no messages are received\n\n`newPublicWebSocket()` and `newAuthenticatedWebSocket()` return a `ForeverWebSocket` instance.\n\n#### Ping\nPing function is activated by default, ping requests are issued every 30 seconds to keep the connection alive.\n```javascript\n{\n\"event\": \"ping\"\n}\n```\n\n### Public channels\nSee https://docs.poloniex.com/#public-channels\n\nExample:\n```javascript\nimport Poloniex from 'poloniex-api-node'\nconst poloniex = new Poloniex()\n\n// Create a new WebSocket connected to public endpoint. The WebSocket should not reconnect if disconnected. \nconst ws = poloniex.newPublicWebSocket({ reconnect: null })\n\n// Specify event handlers\nws.on('open', () =\u003e console.log('Websocket connection open'))\nws.on('message', (data) =\u003e console.log('Websocket data received'))\nws.on('error', () =\u003e console.log('Websocket error'))\nws.on('close', () =\u003e console.log('Websocket connection closed'))\n```\n\n\n### Authenticated channels\nSee https://docs.poloniex.com/#authenticated-channels\n\nWhen `newAuthenticatedWebSocket()` is used to open a WebSocket connection to access private channels, the authentication `auth` message is automatically sent to Poloniex immediately after the WebSocket connection is open.\nSubscriptions for authentication channels can be sent after poloniex server responds with successful authentication confirmation:\n```javascript\n{\n  \"data\":  {\n    \"success\": true,\n    \"ts\": 1645597033915\n  },\n  \"channel\": \"auth\"\n}\n```\n\nExample: \n\n```js\nimport Poloniex from 'poloniex-api-node'\nconst poloniex = new Poloniex({ apiKey: 'myKey', apiSecret: 'mySecret' })\n\n// Create a new WebSocket connected to private endpoint. \nconst ws = poloniex.newAuthenticatedWebSocket()\n\n// Specify event handlers\nws.on('open', () =\u003e console.log('Websocket connection open'))\nws.on('message', (data) =\u003e {\n  // if 'auth` message is received and authentication is sucessfull, send subscribe message \n  if (data.channel === 'auth' \u0026\u0026 data.data.success) {\n    ws.send({\n      event: 'subscribe',\n      channel: ['orders'],\n      symbols: ['all']\n    })\n  }  \n})\n```\n\n# Contributors\n\nThis project exists thanks to all the people who contribute.\n\n* [dutu](https://github.com/dutu)\n* [julesGoullee](https://github.com/julesGoullee)\n* [zymnytskiy](https://github.com/zymnytskiy)\n* [Wallison Santos](https://github.com/wallybh)\n* [Denis Bezrukov](https://github.com/anthrax63)\n* [BarnumD](https://github.com/BarnumD)\n* [zunderbolt](https://github.com/zunderbolt)\n* [aloysius-pgast](https://github.com/aloysius-pgast)\n* [SeanRobb](https://github.com/SeanRobb)\n* [Robert Valmassoi](https://github.com/valmassoi)\n* [epdev](https://github.com/epdev)\n* [standup75](https://github.com/standup75)\n* [kevflynn](https://github.com/kevflynn)\n* [Alexey Marunin](https://github.com/alexeymarunin)\n\n# License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutu%2Fpoloniex-api-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdutu%2Fpoloniex-api-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutu%2Fpoloniex-api-node/lists"}