Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/colkito/blockchain-rates
Blockchain Exchange Rates API wrapper for Node.js - A tiny and easy to use library
https://github.com/colkito/blockchain-rates
bitcoin blockchain currency dollar nodejs rates ticker
Last synced: 9 days ago
JSON representation
Blockchain Exchange Rates API wrapper for Node.js - A tiny and easy to use library
- Host: GitHub
- URL: https://github.com/colkito/blockchain-rates
- Owner: colkito
- Created: 2019-12-16T02:46:55.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-18T21:45:25.000Z (over 1 year ago)
- Last Synced: 2024-09-16T18:22:50.392Z (2 months ago)
- Topics: bitcoin, blockchain, currency, dollar, nodejs, rates, ticker
- Language: TypeScript
- Homepage: https://npmjs.com/blockchain-rates
- Size: 731 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# blockchain-rates
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/colkito/blockchain-rates/npm-publish.yml?style=flat-square)
[![BundlePhobia](https://img.shields.io/bundlephobia/min/blockchain-rates.svg?style=flat-square)](https://bundlephobia.com/result?p=blockchain-rates)
[![BundlePhobia](https://img.shields.io/bundlephobia/minzip/blockchain-rates.svg?style=flat-square)](https://bundlephobia.com/result?p=blockchain-rates)A lightweight Node.js wrapper for [Blockchain's](https://blockchain.info/ticker) 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`:
```js
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
```json
{
"15m": 33997.0,
"last": 33997.0,
"buy": 33997.0,
"sell": 33997.0,
"symbol": "R$"
}
```Getting `all` the rates:
```js
import blockchainRates from 'blockchain-rates';// Using callback
blockchainRates.get((err, res) => {
console.error('Callback Error:', err);
console.log('Callback Rates:', res);
});
```Successful response
```json
{
"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](example/rates-example.js).
## Available Codes (updated: 2023-01-25)
[Follow this link](CODES.md) to see the complete list of codes.
## Related Packages
- [BitPay Rates API](https://npmjs.com/bitpay-rates)