{"id":17028409,"url":"https://github.com/bennycode/coinbase-pro-node","last_synced_at":"2025-04-14T04:09:18.095Z","repository":{"id":38839277,"uuid":"233376394","full_name":"bennycode/coinbase-pro-node","owner":"bennycode","description":"Coinbase API written in TypeScript and covered by tests.","archived":false,"fork":false,"pushed_at":"2025-04-01T01:10:36.000Z","size":5403,"stargazers_count":254,"open_issues_count":5,"forks_count":62,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-14T04:09:12.140Z","etag":null,"topics":["api","api-client","bitcoin","code-coverage","coinbase","cryptocurrency","ethereum","exchange","fintech","hacktoberfest","trading","trading-api","typescript"],"latest_commit_sha":null,"homepage":"https://bennycode.com/coinbase-pro-node","language":"TypeScript","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/bennycode.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":"2020-01-12T10:44:06.000Z","updated_at":"2025-04-01T01:04:04.000Z","dependencies_parsed_at":"2023-02-04T02:04:42.657Z","dependency_job_id":"332b6f07-c5b0-41fe-a824-709940ec29d6","html_url":"https://github.com/bennycode/coinbase-pro-node","commit_stats":{"total_commits":1246,"total_committers":17,"mean_commits":73.29411764705883,"dds":0.5224719101123596,"last_synced_commit":"5d5e3825d6c68fb7af587de1a4f3c3bace2e1f02"},"previous_names":[],"tags_count":85,"template":false,"template_full_name":"bennycode/ts-node-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennycode%2Fcoinbase-pro-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennycode%2Fcoinbase-pro-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennycode%2Fcoinbase-pro-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennycode%2Fcoinbase-pro-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bennycode","download_url":"https://codeload.github.com/bennycode/coinbase-pro-node/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248819405,"owners_count":21166477,"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","api-client","bitcoin","code-coverage","coinbase","cryptocurrency","ethereum","exchange","fintech","hacktoberfest","trading","trading-api","typescript"],"created_at":"2024-10-14T07:54:08.321Z","updated_at":"2025-04-14T04:09:18.069Z","avatar_url":"https://github.com/bennycode.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003e [!IMPORTANT]  \n\u003e On [2022-06-22](https://www.coinbase.com/blog/hello-advanced-trade-goodbye-coinbase-pro) Coinbase announced that it will discontinue the [Pro API](https://docs.cloud.coinbase.com/exchange/reference) in favor of its [Advanced Trade API](https://docs.cloud.coinbase.com/advanced-trade-api/reference).\n\u003e\n\u003e With this news the **coinbase-pro-node** package, which has been serving users effectively since 2019-04-11, will become non functional.\n\u003e\n\u003e Luckily, the code of this library is open-source, allowing you to fork it and tailor it to the new Advanced Trade API. Coinbase offers a [Pro to Advanced Trade API Mapping guide](https://docs.cloud.coinbase.com/advanced-trade-api/docs/rest-api-pro-mapping) to assist in this process.\n\n# Coinbase API\n\n![Language Details](https://img.shields.io/github/languages/top/bennycode/coinbase-pro-node) ![Code Coverage](https://img.shields.io/codecov/c/github/bennycode/coinbase-pro-node/main) ![License](https://img.shields.io/npm/l/coinbase-pro-node.svg) ![Package Version](https://img.shields.io/npm/v/coinbase-pro-node.svg)\n\n---\n\n🌟 _Better than the original Coinbase API. [See why](#problems-with-official-coinbase-apis)._ 🌟\n\nCommunity-maintained [Coinbase API][1] for Node.js \u0026 Deno, written in TypeScript and covered by tests.\n\n## Motivation\n\nThe purpose of this [coinbase-pro-node][5] package is to maintain a recent Coinbase API for Node.js with type safety through TypeScript.\n\n## Features\n\n- ✅ **Typed.** Source code is 100% TypeScript. No need to install external typings.\n- ✅ **Tested.** Code coverage is 100%. No surprises when using \"coinbase-pro-node\".\n- ✅ **Convenient.** Request throttling is built-in. Don't worry about rate limiting.\n- ✅ **Comfortable.** More than an API client. You will get extras like [candle watching](https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/rest-watch-candles.ts).\n- ✅ **Maintained.** Automated security updates. No threats from outdated dependencies.\n- ✅ **Documented.** Get started with [demo scripts][3] and [generated documentation][4].\n- ✅ **Modern.** HTTP client with Promise API. Don't lose yourself in callback hell.\n- ✅ **Robust.** WebSocket reconnection is built-in. No problems if your Wi-Fi is gone.\n- ✅ **Reliable.** Following [semantic versioning][8]. Get notified about breaking changes.\n\n## Installation\n\n**npm**\n\n```bash\nnpm install coinbase-pro-node\n```\n\n**Yarn**\n\n```bash\nyarn add coinbase-pro-node\n```\n\n## Setup\n\n**JavaScript**\n\n```javascript\nconst {CoinbasePro} = require('coinbase-pro-node');\nconst client = new CoinbasePro();\n```\n\n**TypeScript**\n\n```typescript\nimport {CoinbasePro} from 'coinbase-pro-node';\nconst client = new CoinbasePro();\n```\n\n## Usage\n\nThe [demo section][3] provides many examples on how to use \"coinbase-pro-node\". There is also an automatically generated [API documentation][4]. For a quick start, here is a simple example for a REST request:\n\n### REST Example\n\n```typescript\nimport {CoinbasePro} from 'coinbase-pro-node';\n\n// API Keys can be generated here:\n// https://pro.coinbase.com/profile/api\n// https://public.sandbox.pro.coinbase.com/profile/api\nconst auth = {\n  apiKey: '',\n  apiSecret: '',\n  passphrase: '',\n  // The Sandbox is for testing only and offers a subset of the products/assets:\n  // https://docs.cloud.coinbase.com/exchange/docs#sandbox\n  useSandbox: true,\n};\n\nconst client = new CoinbasePro(auth);\n\nclient.rest.account.listAccounts().then(accounts =\u003e {\n  const message = `You can trade \"${accounts.length}\" different pairs.`;\n  console.log(message);\n});\n```\n\n### WebSocket Example\n\nIf you want to listen to WebSocket messages, have a look at these demo scripts:\n\n- [Subscribe to \"ticker\" channel (real-time price updates)](https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/websocket-ticker.ts)\n- [Subscribe to authenticated \"user\" channel](https://github.com/bennycode/coinbase-pro-node/blob/main/src/demo/websocket-user.ts)\n\n### Demos\n\nAll [demo scripts][3] are executable from the root directory. If you want to use specific credentials with a demo script, simply add a `.env` file to the root of this package to [modify environment variables](https://github.com/motdotla/dotenv/tree/v8.2.0#usage) used in [init-client.ts](https://github.com/bennyn/coinbase-pro-node/blob/main/src/demo/init-client.ts).\n\n```bash\nnpx ts-node ./src/demo/dump-candles.ts\n```\n\n**Tip:** There is a [.env.defaults](https://github.com/bennycode/coinbase-pro-node/blob/main/.env.defaults) file which serves as a template. Just remove its `.defaults` extension and enter your credentials to get started. Do not commit this file (or your credentials) to any repository!\n\n### Web Frontend Applications\n\nThe \"coinbase-pro-node\" library was built to be used in Node.js environments BUT you can also make use of it in web frontend applications (using React, Vue.js, etc.). However, due to the [CORS restrictions](https://developer.mozilla.org/docs/Web/HTTP/CORS) of modern web browser, you will have to use a proxy server.\n\nA proxy server can be setup with webpack's [DevServer proxy configuration](https://webpack.js.org/configuration/dev-server/#devserverproxy) or [http-proxy-middleware](https://www.npmjs.com/package/http-proxy-middleware).\n\nHere is an example:\n\n**Backend**\n\n```typescript\nimport {createProxyMiddleware} from 'http-proxy-middleware';\nimport express from 'express';\n\nconst app = express();\n\napp.use(\n  '/api-coinbase-pro',\n  createProxyMiddleware({\n    target: 'https://api.exchange.coinbase.com',\n    changeOrigin: true,\n    pathRewrite: {\n      [`^/api-coinbase-pro`]: '',\n    },\n  })\n);\n```\n\nLater on, you can use the proxy URL (`/api-coinbase-pro` from above) in your web application to initialize \"coinbase-pro-node\" with it:\n\n**Frontend**\n\n```typescript\nconst client = new CoinbasePro({\n  httpUrl: '/api-coinbase-pro',\n  apiKey: '',\n  apiSecret: '',\n  passphrase: '',\n  useSandbox: false,\n});\n```\n\n### Real-world Examples\n\nCheckout [GitHub's dependency graph][6] to see who uses \"coinbase-pro-node\" in production. There are also [npm packages][7] depending on \"coinbase-pro-node\".\n\n## Maintainers\n\n[![Benny Neugebauer on Stack Exchange][stack_exchange_bennyn_badge]][stack_exchange_bennyn_url]\n\n## Stargazers\n\n[![Stargazers](https://reporoster.com/stars/bennycode/coinbase-pro-node)](https://github.com/bennycode/coinbase-pro-node/stargazers)\n\n## Contributing\n\nContributions, issues and feature requests are welcome!\n\nFeel free to check the [issues page](https://github.com/bennycode/coinbase-pro-node/issues).\n\nThe following commits will help you getting started quickly with the code base:\n\n- [Add REST API endpoint](https://github.com/bennycode/coinbase-pro-node/commit/9920c2f4343985c349b68e2a47d7fe2c42e23e34)\n- [Add REST API endpoint (with fixtures)](https://github.com/bennycode/coinbase-pro-node/commit/8a150fecb7d32b7b7cd39a8109985f665aaee26e)\n\nAll resources can be found in the [Coinbase Exchange API reference][2]. For the latest updates, check [Coinbase's API Changelog][9].\n\n## License\n\nThis project is [MIT](./LICENSE) licensed.\n\n## ⭐️ Show your support ⭐️\n\n[Please leave a star](https://github.com/bennycode/coinbase-pro-node/stargazers) if you find this project useful.\n\nIf you like this project, you might also like these related projects:\n\n- [**trading-signals**](https://github.com/bennycode/trading-signals), Technical indicators, written in TypeScript, with arbitrary-precision arithmetic.\n- [**ig-trading-api**](https://github.com/bennycode/ig-trading-api), REST API, written in TypeScript, for CFD trading with IG.\n- [**binance-api-node**](https://github.com/Ashlar/binance-api-node), Heavily tested and Promise-based Binance API with TypeScript definitions.\n\n---\n\n## Problems with official Coinbase APIs\n\nThere are official Coinbase APIs for Node.js, but they all come with some disadvantages leading to decreased developer experience (DX):\n\n1. [Coinbase's first Node.js API](https://github.com/coinbase/coinbase-exchange-node) has no type safety and got deprecated on [July, 19th 2016](https://github.com/coinbase/coinbase-exchange-node/commit/b8347efdb4e2589367c1395b646d283c9c391681)\n2. [Coinbase's second Node.js API](https://github.com/coinbase/coinbase-pro-node) has no type safety and got deprecated on [January, 16 2020](https://github.com/coinbase/coinbase-pro-node/issues/393#issuecomment-574993096)\n3. [Coinbase's current Node.js API](https://docs.cloud.coinbase.com/exchange/reference) ([OAS spec](https://dash.readme.com/api/v1/api-registry/qgumw1pl3iz4yut)) still lacks type safety and does not incorporate best practices like automatic reconnections and request throttling\n\n## Official Coinbase API\n\nCoinbase is versioning its API through [ReadMe.com](https://readme.com/), so you can generate an API client from their [OpenAPI Specification](https://dash.readme.com/api/v1/api-registry/qgumw1pl3iz4yut). ReadMe provides a Node.js package named \"[api](https://www.npmjs.com/package/api)\" which allows you to retrieve an automatically generated Node.js client:\n\n### Installation\n\n```bash\nnpm install api@^4.5.1\n```\n\n### Usage\n\n```ts\nimport api from 'api';\n\nconst sdk = api('@coinbase-exchange/v1.0#qgumw1pl3iz4yut');\n\nsdk['ExchangeRESTAPI_GetProductTrades']({\n  product_id: 'BTC-USD',\n}).then(response =\u003e {\n  console.log(`Found \"${response.length}\" trades.`);\n});\n```\n\n### Drawbacks\n\nThe current Coinbase Node.js SDK (provided by the [api package](https://www.npmjs.com/package/api)) does not support typings for response payloads:\n\n![Official Coinbase API](./coinbase-api-screenshot.png 'Type safety problems in official Coinbase API')\n\n[1]: https://pro.coinbase.com/\n[2]: https://docs.cloud.coinbase.com/exchange\n[3]: https://github.com/bennycode/coinbase-pro-node/tree/main/src/demo\n[4]: https://bennycode.com/coinbase-pro-node\n[5]: https://www.npmjs.com/package/coinbase-pro-node\n[6]: https://github.com/bennycode/coinbase-pro-node/network/dependents\n[7]: https://www.npmjs.com/browse/depended/coinbase-pro-node\n[8]: https://docs.npmjs.com/about-semantic-versioning\n[9]: https://docs.cloud.coinbase.com/exchange/docs/changelog\n[stack_exchange_bennyn_badge]: https://stackexchange.com/users/flair/203782.png?theme=default\n[stack_exchange_bennyn_url]: https://stackexchange.com/users/203782/benny-neugebauer?tab=accounts\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennycode%2Fcoinbase-pro-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbennycode%2Fcoinbase-pro-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennycode%2Fcoinbase-pro-node/lists"}