Extended from the original deprecated package by @litvintech to provide API services and re-formatted results.
Crypto balances
Easily check address balances of various crypto tokens. Script automaticaly recognizes a protocol by address and returns balances of tokens associated with it.
Supported Protocols
- Using https://blockcypher.com: Bitcoin, Litecoin, Dash, Dogecoin
- Using https://blockchain.info: Bitcoin Xpub
- Using https://ethplorer.io: Ethereum, ERC20 Tokens
- Using https://chainz.cryptoid.info: LTC Segwit, Stratis, DigiByte
- Using https://neoscan.io: NEO, NEP5 Tokens
As a dependency
Require the package and use it as any other promise:
~ » npm install --save crypto-balances-2
const balance = require('crypto-balances-2');
balance("0xfc30a6c6d1d61f0027556ed25a670345ab39d0cb")
.then(result => console.log(result))
.catch(error => console.log(`OH NO! ${error}`));
// logs: { "address_type": "ETH", balances: {"ETH": 0.29, "OMG": 124.448} }
// balance takes an optional second coin type parameter.
// eg. balance("0xfc30a6c6d1d61f0027556ed25a670345ab39d0cb", "BTC")
As an API
~ » git clone https://github.com/danielheyman/crypto-balances
~ » cd crypto-balances
~ » npm install
~ » npm start
An API call can be made to port 8888 with a given address to http://127.0.0.1:8888/address_to_check.
It will return a json response such as { "address_type": "ETH", balances: {"ETH": 0.29, "OMG": 124.448} }
.
If an error occurs, it will return a json response such as { "error": "ethplorer: Invalid API key" }
.
For a specific coin, a call can be made to http://127.0.0.1:8888/coin/address_to_check. eg. http://127.0.0.1:8888/eth/0xfc30a6c6d1d61f0027556ed25a670345ab39d0cb
As an API using Docker
Useful when running on a machine with multiple node applications, each requiring different specifications.
Run docker-compose up
to get the container up.
An API call can be made on port 8888 with a given address to http://0.0.0.0:8888/address_to_check.
Tests
~ » npm run test
License
Under MIT License
Contributing
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request