I'm working on something like this now. I do not have a complete implementation built yet, so please bear with me for any errors or troubles that might arise. However, this might help get you on your feet...
I started by installing bitcoind
and setting it up as a client which Node.js can interact with the Blockchain through. I did this by setting up bitcoin.conf
with my Blockchain information and starting bitcoind
in a screen. Take a look at this page for information on connecting bitcoind with your Blockchain account: https://blockchain.info/api/json_rpc_api
You'll also need middleware for Nodejs to interact with Blockchain through bitcoind. Here's the one Blockchain links to: https://github.com/jb55/node-bitcoin can be simply installed with:
npm install bitcoin
The readme file on this Git provides information and code snippits you can use to connect Nodejs with Blockchain. Node connects to your local bitcoin server:
var bitcoin = require('bitcoin');
var client = new bitcoin.Client('localhost', 8332, 'username', 'password');
Node gets the balance of all your addresses, with at least 6 confirmations:
client.getBalance('*', 6, function(err, balance) {
if (err) return console.log(err);
console.log('Balance:', balance);
});
Here's a list of all the possible Blockchain API requests: en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list
You can use these functions to create and destroy wallet addresses, check their balances, as well as send funds from your script if you so desire.
Speaking briefly about security, double encryption is recommended and can be enabled in the Blockchain My Wallet 'Account Details' page. This means each address has it's own access password, on top of the master wallet password. Simple operations such as fetching a balance do not require both passwords to be sent, but sending funds would require Node to send both the master and wallet passwords. If you're using a server with a static IP, you can also use the 'IP Lock' setting in Blockchain to restrict access to outsiders. Gotcha: two-factor authorization must be disabled on your Blockchain wallet to allow access from your script.