0.0.3 • Published 4 years ago

coinbase-library v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Coinbase-Library

Installation

$ npm install Coinbase-Library

Usage

Initialize CoinbaseAPI

const CoinbaseLibrary = require('coinbase-library');
const Coinbase = new CoinbaseLibrary('ApiKeyHere', 'ApiSecretHere');

Get exchange rate

await Coinbase.getRate('ETH', 'EUR');
await Coinbase.getRate('BTC', 'USD');

Get wallet balance

// Returns wallet's crypto and normal currency as object -> { crypto: '0.01234567', normal: '12.34' }
const balance = await Coinbase.getBalance('walletid', 'both');
// Returns wallet's normal currency -> 12.34
const balance = await Coinbase.getBalance('walletid', 'normal');
// Returns wallet's crypto currency -> 0.01234567
const balance = await Coinbase.getBalance('walletid', 'crypto');

Example

const CoinbaseLibrary = require('coinbase-library');
const Coinbase = new CoinbaseLibrary('apikey', 'apisecret');

async function main() {
  try {
    const balance = await Coinbase.getBalance('walletid', 'both');
    const rate = await Coinbase.getRate('ETH', 'EUR');
    console.log(balance);
    console.log(rate);
  }
  catch (error) {
    console.log(error);
  }
}

main();
0.0.3

4 years ago

0.0.2

4 years ago

1.0.0

4 years ago