Installations
npm install coinbase-pro-node
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
>= 18
Node Version
20.10.0
NPM Version
10.2.3
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.95%)
Shell (0.05%)
Developer
Download Statistics
Total Downloads
990,810
Last Day
58
Last Week
1,307
Last Month
10,069
Last Year
174,733
GitHub Statistics
254 Stars
1,246 Commits
62 Forks
8 Watching
4 Branches
15 Contributors
Package Meta Information
Latest Version
9.1.0
Package Id
coinbase-pro-node@9.1.0
Unpacked Size
361.53 kB
Size
70.95 kB
File Count
156
NPM Version
10.2.3
Node Version
20.10.0
Publised On
03 Jul 2024
Total Downloads
Cumulative downloads
Total Downloads
990,810
Last day
-87.6%
58
Compared to previous day
Last week
-45.2%
1,307
Compared to previous week
Last month
13.5%
10,069
Compared to previous month
Last year
-36.5%
174,733
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
22
[!IMPORTANT]
On 2022-06-22 Coinbase announced that it will discontinue the Pro API in favor of its Advanced Trade API.With this news the coinbase-pro-node package, which has been serving users effectively since 2019-04-11, will become non functional.
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 to assist in this process.
Coinbase API
🌟 Better than the original Coinbase API. See why. 🌟
Community-maintained Coinbase API for Node.js & Deno, written in TypeScript and covered by tests.
Motivation
The purpose of this coinbase-pro-node package is to maintain a recent Coinbase API for Node.js with type safety through TypeScript.
Features
- ✅ Typed. Source code is 100% TypeScript. No need to install external typings.
- ✅ Tested. Code coverage is 100%. No surprises when using "coinbase-pro-node".
- ✅ Convenient. Request throttling is built-in. Don't worry about rate limiting.
- ✅ Comfortable. More than an API client. You will get extras like candle watching.
- ✅ Maintained. Automated security updates. No threats from outdated dependencies.
- ✅ Documented. Get started with demo scripts and generated documentation.
- ✅ Modern. HTTP client with Promise API. Don't lose yourself in callback hell.
- ✅ Robust. WebSocket reconnection is built-in. No problems if your Wi-Fi is gone.
- ✅ Reliable. Following semantic versioning. Get notified about breaking changes.
Installation
npm
1npm install coinbase-pro-node
Yarn
1yarn add coinbase-pro-node
Setup
JavaScript
1const {CoinbasePro} = require('coinbase-pro-node'); 2const client = new CoinbasePro();
TypeScript
1import {CoinbasePro} from 'coinbase-pro-node'; 2const client = new CoinbasePro();
Usage
The demo section provides many examples on how to use "coinbase-pro-node". There is also an automatically generated API documentation. For a quick start, here is a simple example for a REST request:
REST Example
1import {CoinbasePro} from 'coinbase-pro-node'; 2 3// API Keys can be generated here: 4// https://pro.coinbase.com/profile/api 5// https://public.sandbox.pro.coinbase.com/profile/api 6const auth = { 7 apiKey: '', 8 apiSecret: '', 9 passphrase: '', 10 // The Sandbox is for testing only and offers a subset of the products/assets: 11 // https://docs.cloud.coinbase.com/exchange/docs#sandbox 12 useSandbox: true, 13}; 14 15const client = new CoinbasePro(auth); 16 17client.rest.account.listAccounts().then(accounts => { 18 const message = `You can trade "${accounts.length}" different pairs.`; 19 console.log(message); 20});
WebSocket Example
If you want to listen to WebSocket messages, have a look at these demo scripts:
Demos
All demo scripts 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 used in init-client.ts.
1npx ts-node ./src/demo/dump-candles.ts
Tip: There is a .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!
Web Frontend Applications
The "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 of modern web browser, you will have to use a proxy server.
A proxy server can be setup with webpack's DevServer proxy configuration or http-proxy-middleware.
Here is an example:
Backend
1import {createProxyMiddleware} from 'http-proxy-middleware'; 2import express from 'express'; 3 4const app = express(); 5 6app.use( 7 '/api-coinbase-pro', 8 createProxyMiddleware({ 9 target: 'https://api.exchange.coinbase.com', 10 changeOrigin: true, 11 pathRewrite: { 12 [`^/api-coinbase-pro`]: '', 13 }, 14 }) 15);
Later on, you can use the proxy URL (/api-coinbase-pro
from above) in your web application to initialize "coinbase-pro-node" with it:
Frontend
1const client = new CoinbasePro({ 2 httpUrl: '/api-coinbase-pro', 3 apiKey: '', 4 apiSecret: '', 5 passphrase: '', 6 useSandbox: false, 7});
Real-world Examples
Checkout GitHub's dependency graph to see who uses "coinbase-pro-node" in production. There are also npm packages depending on "coinbase-pro-node".
Maintainers
Stargazers
Contributing
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
The following commits will help you getting started quickly with the code base:
All resources can be found in the Coinbase Exchange API reference. For the latest updates, check Coinbase's API Changelog.
License
This project is MIT licensed.
⭐️ Show your support ⭐️
Please leave a star if you find this project useful.
If you like this project, you might also like these related projects:
- trading-signals, Technical indicators, written in TypeScript, with arbitrary-precision arithmetic.
- ig-trading-api, REST API, written in TypeScript, for CFD trading with IG.
- binance-api-node, Heavily tested and Promise-based Binance API with TypeScript definitions.
Problems with official Coinbase APIs
There are official Coinbase APIs for Node.js, but they all come with some disadvantages leading to decreased developer experience (DX):
- Coinbase's first Node.js API has no type safety and got deprecated on July, 19th 2016
- Coinbase's second Node.js API has no type safety and got deprecated on January, 16 2020
- Coinbase's current Node.js API (OAS spec) still lacks type safety and does not incorporate best practices like automatic reconnections and request throttling
Official Coinbase API
Coinbase is versioning its API through ReadMe.com, so you can generate an API client from their OpenAPI Specification. ReadMe provides a Node.js package named "api" which allows you to retrieve an automatically generated Node.js client:
Installation
1npm install api@^4.5.1
Usage
1import api from 'api'; 2 3const sdk = api('@coinbase-exchange/v1.0#qgumw1pl3iz4yut'); 4 5sdk['ExchangeRESTAPI_GetProductTrades']({ 6 product_id: 'BTC-USD', 7}).then(response => { 8 console.log(`Found "${response.length}" trades.`); 9});
Drawbacks
The current Coinbase Node.js SDK (provided by the api package) does not support typings for response payloads:
No vulnerabilities found.
Reason
18 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: no topLevel permission defined: .github/workflows/continuous-integration.yml:1
- Warn: no topLevel permission defined: .github/workflows/create-release.yml:1
- Warn: topLevel 'contents' permission set to 'write': .github/workflows/merge-dependencies.yml:8
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/bennycode/coinbase-pro-node/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/bennycode/coinbase-pro-node/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/bennycode/coinbase-pro-node/codeql-analysis.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/continuous-integration.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/bennycode/coinbase-pro-node/continuous-integration.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/continuous-integration.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/bennycode/coinbase-pro-node/continuous-integration.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/continuous-integration.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/bennycode/coinbase-pro-node/continuous-integration.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/create-release.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/bennycode/coinbase-pro-node/create-release.yml/main?enable=pin
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Score
5.9
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More