Gathering detailed insights and metrics for coinbase
Gathering detailed insights and metrics for coinbase
Gathering detailed insights and metrics for coinbase
Gathering detailed insights and metrics for coinbase
DEPRECATED — The official Node.js library for the Coinbase API.
npm install coinbase
Typescript
Module System
Node Version
NPM Version
75.5
Supply Chain
93.4
Quality
72.6
Maintenance
25
Vulnerability
96.8
License
JavaScript (100%)
Total Downloads
699,092
Last Day
27
Last Week
2,382
Last Month
9,628
Last Year
127,686
Apache-2.0 License
367 Stars
83 Commits
152 Forks
28 Watchers
4 Branches
22 Contributors
Updated on Apr 19, 2025
Minified
Minified + Gzipped
Latest Version
2.0.8
Package Id
coinbase@2.0.8
Unpacked Size
148.42 kB
Size
36.03 kB
File Count
45
NPM Version
3.9.3
Node Version
8.10.0
Cumulative downloads
Total Downloads
Last Day
-10%
27
Compared to previous day
Last Week
-3.3%
2,382
Compared to previous week
Last Month
-17%
9,628
Compared to previous month
Last Year
36.2%
127,686
Compared to previous year
4
The official Node.js library for the Coinbase API.
npm install coinbase
Version | GitHub repository |
---|---|
2.0.x | This repository |
0.1.x | mateodelnorte/coinbase |
Npm coinbase
package name used to refer to the unofficial coinbase library maintained by Matt Walters. Matt graciously allowed us to use the name for this package instead. You can still find that package on Github. Thanks, Matt.
The first thing you'll need to do is sign up for coinbase.
If you're writing code for your own Coinbase account, enable an API key. Next, create a Client
object for interacting with the API:
1var Client = require('coinbase').Client; 2var client = new Client({'apiKey': mykey, 'apiSecret': mysecret});
If you're writing code that will act on behalf of another user, start by creating a new OAuth 2 application. You will need to do some work to obtain OAuth credentials for your users; while outside the scope of this document, please refer to our OAuth 2 tutorial and documentation. Once you have these credentials, create a client:
1var Client = require('coinbase').Client; 2var client = new Client({'accessToken': accessToken, 'refreshToken': refreshToken});
With a client instance
, you can now make API calls. We've included some examples below, but in general the library has Javascript prototypes for each of the objects described in our REST API documentation. These classes each have methods for making the relevant API calls; for instance, coinbase.model.Transaction.complete
maps to the complete bitcoin request API endpoint. The comments of each method in the code references the endpoint it implements. Each API method returns an object
representing the JSON response from the API.
Listing available accounts
1var coinbase = require('coinbase'); 2var client = new coinbase.Client({'apiKey': mykey, 'apiSecret': mysecret}); 3 4client.getAccounts({}, function(err, accounts) { 5 accounts.forEach(function(acct) { 6 console.log('my bal: ' + acct.balance.amount + ' for ' + acct.name); 7 }); 8});
Get Balance from an Account Id
1var coinbase = require('coinbase'); 2var client = new coinbase.Client({'apiKey': mykey, 'apiSecret': mysecret}); 3 4client.getAccount('<ACCOUNT ID>', function(err, account) { 5 console.log('bal: ' + account.balance.amount + ' currency: ' + account.balance.currency); 6});
Selling bitcoin
1var args = { 2 "amount": "12", 3 "currency": "BTC" 4}; 5account.sell(args, function(err, xfer) { 6 console.log('my xfer id is: ' + xfer.id); 7});
Sending bitcoin
1var args = { 2 "to": "user1@example.com", 3 "amount": "1.234", 4 "currency": "BTC", 5 "description": "Sample transaction for you" 6}; 7account.sendMoney(args, function(err, txn) { 8 console.log('my txn id is: ' + txn.id); 9});
Requesting bitcoin
1var args = { 2 "to": "user1@example.com", 3 "amount": "1.234", 4 "currency": "BTC", 5 "description": "Sample transaction for you" 6}; 7account.requestMoney(args, function(err, txn) { 8 console.log('my txn id is: ' + txn.id); 9});
Listing current transactions
1account.getTransactions(null, function(err, txns) { 2 txns.forEach(function(txn) { 3 console.log('my txn status: ' + txn.status); 4 }); 5});
Using pagination
1account.getTransactions(null, function(err, txns, pagination) { 2 txns.forEach(function(txn) { 3 console.log('my txn: ' + txn.id); 4 }); 5 console.log(pagination.next_uri); 6 account.getTransactions(pagination, function(err, txns) { 7 txns.forEach(function(txn) { 8 console.log('my txn: ' + txn.id); 9 }); 10 }); 11});
Checking bitcoin prices
1client.getBuyPrice({'currencyPair': 'BTC-USD'}, function(err, obj) { 2 console.log('total amount: ' + obj.data.amount); 3});
Verifying merchant callback authenticity
1if (client.verifyCallback(req.raw_body, req.headers['CB-SIGNATURE'])) { 2 // Process callback 3}
Errors are thrown for invalid arguments but are otherwise returned as the first argument to callback functions using http-errors module.
Errors contain name
, status
, and message
fields for error handling. You can find
more information about error types here
Any and all contributions are welcome! The process is simple:
Tests are run via mocha and nock. To run the tests, clone the repository and then:
npm install
npm test
Please also scan the packages for known vulnerabilities.
1npm install -g nsp 2nsp check --output summary
You can also run the tests against various node environments using the Dockerfile.example file.
cp Dockerfile.example Dockerfile
[sudo] docker build -t coinbase-node .
[sudo] docker run -it coinbase-node
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
Found 7/22 approved changesets -- score normalized to 3
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
39 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
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