1.1.4 • Published 1 year ago

blockchain-rates v1.1.4

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

blockchain-rates

GitHub Workflow Status BundlePhobia BundlePhobia

A lightweight Node.js wrapper for Blockchain's Exchange Rates API (ticker), now in TypeScript.

Zero-dependency, promise and callback support for easy integration into your project. ✨

Requirements

  • nodejs >= 12.x

Examples

Getting a rate by code:

import blockchainRates from 'blockchain-rates';

const code = 'BRL'; // see list of codes bellow

// Using promise
blockchainRates
  .get(code)
  .then((rate) => console.log('Promise Rate:', rate))
  .catch((err) => console.error('Promise Error:', err));

Successful response

{
  "15m": 33997.0,
  "last": 33997.0,
  "buy": 33997.0,
  "sell": 33997.0,
  "symbol": "R$"
}

Getting all the rates:

import blockchainRates from 'blockchain-rates';

// Using callback
blockchainRates.get((err, res) => {
  console.error('Callback Error:', err);
  console.log('Callback Rates:', res);
});

Successful response

{
  "BRL": {
    "15m": 33997.0,
    "last": 33997.0,
    "buy": 33997.0,
    "sell": 33997.0,
    "symbol": "R$"
  },
  "USD": {
    "15m": 7046.5,
    "last": 7046.5,
    "buy": 7046.5,
    "sell": 7046.5,
    "symbol": "$"
  },
  {...}
}

More examples here.

Available Codes (updated: 2023-01-25)

Follow this link to see the complete list of codes.

Related Packages

1.1.4

1 year ago

1.1.3

1 year ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.2

4 years ago

1.0.9

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago