<p>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...</p>

<p>I started by installing <code>bitcoind</code> and setting it up as a client which Node.js can interact with the Blockchain through. I did this by setting up <code>bitcoin.conf</code> with my Blockchain information and starting <code>bitcoind</code> in a screen. Take a look at this page for information on connecting bitcoind with your Blockchain account: <a href="https://blockchain.info/api/json_rpc_api" rel="nofollow">https://blockchain.info/api/json_rpc_api</a></p>

<p>You'll also need middleware for Nodejs to interact with Blockchain through bitcoind. Here's the one Blockchain links to: <a href="https://github.com/jb55/node-bitcoin" rel="nofollow">https://github.com/jb55/node-bitcoin</a> can be simply installed with:</p>

<p><code>npm install bitcoin</code> </p>

<p>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:</p>

<p><code>var bitcoin = require('bitcoin');
var client = new bitcoin.Client('localhost', 8332, 'username', 'password');</code></p>

<p>Node gets the balance of all your addresses, with at least 6 confirmations:</p>

<p><code>client.getBalance('*', 6, function(err, balance) {
  if (err) return console.log(err);
  console.log('Balance:', balance);
});</code></p>

<p>Here's a list of all the possible Blockchain API requests: en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list</p>

<p>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.</p>

<p>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.</p>

CC BY-SA 3.0
2014-03-12T19:15:34.523Z
Hey! Thanks this was actually really helpful! One question though! If I wanted to deploy my application to heroku how would this work? From my understanding this would only do everything locally right? Do I need to purchase a server to run the btcoind separately online then connect or?
gbachik
CC BY-SA 3.0
2014-03-12T17:35:06.440Z
2014-03-14T12:32:24.670Z
2014-03-14T12:32:24.670Z
user14351
<p>I also found this node package that works very well for dealing with one Blockchain wallet at a time.</p>

<p><a href="https://www.npmjs.org/package/blockchain-wallet" rel="nofollow">https://www.npmjs.org/package/blockchain-wallet</a></p>

<p><code>npm install blockchain-wallet</code></p>

<pre><code>var BlockchainWallet = require('blockchain-wallet'),
blockchainWallet = new BlockchainWallet("YourGuid", "YourPassword"),
// Certain API methods require a second password if the wallet is second password protected, while others don't at all.
transactionBlockchainWallet = new BlockchainWallet("YourGuid", "YourPassword", "YourSecondPassword");

blockchainWallet.list(function(err, data) {
  if(err) {
   throw err;
  }
  console.log(data);
});
</code></pre>

CC BY-SA 3.0
2014-03-14T17:14:29.283Z
2014-03-14T17:14:29.283Z
user14351
<p>Blockchain has great documentation for PHP, but nothing really for node!</p>

<p>Does anyone here have any projects,where they used the blockchain.info Receive Payments API, in their node apps, to receive money / check for confirmations?</p>

<p>I learn a lot better by viewing / recreating example code so any you have would help me out tons!</p>

<development><api><blockchain.info><javascript>
How do I use Blockchain.info's Receive Payments API with node JS / Express?
gbachik
# How do I use Blockchain.info's Receive Payments API with node JS / Express?

(Asked by: username_0 on 2014-03-12)

Blockchain has great documentation for PHP, but nothing really for node!

Does anyone here have any projects,where they used the blockchain.info Receive Payments API, in their node apps, to receive money / check for confirmations?

I learn a lot better by viewing / recreating example code so any you have would help me out tons!

**Tags:** development, api, blockchain.info, javascript


---

## 2 answers

### Answer by username_1 on 2014-03-12. Score: 1

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.

> **Comments:**
> **username_0**: Hey! Thanks this was actually really helpful! One question though! If I wanted to deploy my application to heroku how would this work? From my understanding this would only do everything locally right? Do I need to purchase a server to run the btcoind separately online then connect or?  

---

### Answer by username_1 on 2014-03-14. Score: 0

I also found this node package that works very well for dealing with one Blockchain wallet at a time.

<https://www.npmjs.org/package/blockchain-wallet>

`npm install blockchain-wallet`

```
var BlockchainWallet = require('blockchain-wallet'),
blockchainWallet = new BlockchainWallet("YourGuid", "YourPassword"),
// Certain API methods require a second password if the wallet is second password protected, while others don't at all.
transactionBlockchainWallet = new BlockchainWallet("YourGuid", "YourPassword", "YourSecondPassword");

blockchainWallet.list(function(err, data) {
  if(err) {
   throw err;
  }
  console.log(data);
});

```


---

