Node.js SDK for the BlockCypher Web services. See http://www.blockcypher.com
JavaScript
Switch branches/tags
Nothing to show
Clone or download
matthieu Merge pull request #16 from EJMason/ejmason/feat-assign
Replace xtend with Object.assign
Latest commit 33ef22a Jul 20, 2017

README.md

node-client

Node.js SDK for the BlockCypher Web services. See http://dev.blockcypher.com for detailed documentation.

To install, just use npm:

npm install blockcypher

Examples

bcypher = require('blockcypher');

var bcapi = new bcypher('btc','main','YOURTOKEN');

function printResponse(err, data) {
  if (err !== null) {
    console.log(err);
  } else {
    console.log(data);
  }
}

//get chain info
bcapi.getChain(printResponse);
//get block height without any optional URL params
bcapi.getBlock(300000, printResponse);
//get block height with an optional "txstart" param, as outlined in docs here: http://dev.blockcypher.com/
bcapi.getBlock(300000, {txstart:2}, printResponse);

//let's try a post request, like making a new webhook
var webhook = {
	event: "unconfirmed-tx",
	address: "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh",
	url: "https://my.domain.com/callbacks/new-tx"
};
bcapi.createHook(webhook, printResponse);

//Now let's list all of our webhooks
bcapi.listHooks(printResponse);