<p>Check to see how many outputs total for the tx using .length and then do a for loop and run through every output for each transaction. Use an if statement to check if that particular output has your desired address in the 'addr' field. If it does match then print that value to the screen. </p>

<p>I made a fiddle that I think should work, I didn't test it though... <a href="http://jsfiddle.net/nmgus1fa/" rel="nofollow">http://jsfiddle.net/nmgus1fa/</a></p>

<pre><code>var btcs = new WebSocket('wss://ws.blockchain.info/inv');

btcs.onopen = function()
{
btcs.send( JSON.stringify( {"op":"addr_sub", "addr":"15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi"} ) );
};

btcs.onmessage = function(onmsg)
{
  var response = JSON.parse(onmsg.data);
  var getOuts = response.x.out;
  var countOuts = getOuts.length; 
  for(i = 0; i &lt; countOuts; i++)
  {
    //check every output to see if it matches specified address
    var outAdd = response.x.out[i].addr;
    var specAdd = "15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi";
       if (outAdd == specAdd )
       {
       var amount = response.x.out[i].value;
       var calAmount = amount / 100000000;
       $('#messages').prepend("&lt;p&gt;" + calAmount + "&lt;/p&gt;");
       }
  } 
}
</code></pre>

CC BY-SA 3.0
2015-10-02T21:25:43.913Z
2015-10-02T21:25:43.913Z
m1xolyd1an
<p>I'm looking at the blockchain.info API and I'm having a difficult time finding the value of incoming transactions. That and the number of incoming transactions are the only things I'm interested in. </p>

<p>As an example here: <a href="https://blockchain.info/rawaddr/15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi" rel="noreferrer">https://blockchain.info/rawaddr/15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi</a></p>

<p>or here: <a href="https://blockexplorer.com/api/txs/?address=15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi" rel="noreferrer">https://blockexplorer.com/api/txs/?address=15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi</a></p>

<p>It lists both incoming and ougoing transactions, and with transactions with several inputs, they are all listed individually. So I can't just have a script search for "value" which was my first idea. Is there a better way to do it?</p>

CC BY-SA 3.0
2015-10-01T05:22:28.307Z
Can you clarify what you mean? So your example looks for all Txs for = 15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi... Are you looking for the value of inputs which are 15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi (ie  is paying to other addresses), or are you after the address/value pair of all Txs funding 15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi?
Wizard Of Ozzie
CC BY-SA 3.0
2015-10-01T20:29:47.617Z
I want to list my incoming payments, so just the individual values of transactions that have been made for a certain address. Outgoing transactions are irrelevant. I'm surprised if there isn't an easier way to do it since you'd think it's one of the most common things people look for!
biwepepi
<api><blockchain.info><blockexplorer>
How to get value of incoming transactions from Blockchain.info API
biwepepi
# How to get value of incoming transactions from Blockchain.info API

(Asked by: username_0 on 2015-10-01)

I'm looking at the blockchain.info API and I'm having a difficult time finding the value of incoming transactions. That and the number of incoming transactions are the only things I'm interested in.

As an example here: <https://blockchain.info/rawaddr/15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi>

or here: <https://blockexplorer.com/api/txs/?address=15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi>

It lists both incoming and ougoing transactions, and with transactions with several inputs, they are all listed individually. So I can't just have a script search for "value" which was my first idea. Is there a better way to do it?

**Tags:** api, blockchain.info, blockexplorer

> **Comments:**
> **username_1**: Can you clarify what you mean? So your example looks for all Txs for = 15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi... Are you looking for the value of inputs which are 15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi (ie  is paying to other addresses), or are you after the address/value pair of all Txs funding 15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi?  
> **username_0**: I want to list my incoming payments, so just the individual values of transactions that have been made for a certain address. Outgoing transactions are irrelevant. I'm surprised if there isn't an easier way to do it since you'd think it's one of the most common things people look for!  

---

## 1 answers

### Answer by username_2 on 2015-10-02. Score: 2

Check to see how many outputs total for the tx using .length and then do a for loop and run through every output for each transaction. Use an if statement to check if that particular output has your desired address in the 'addr' field. If it does match then print that value to the screen.

I made a fiddle that I think should work, I didn't test it though... <http://jsfiddle.net/nmgus1fa/>

```
var btcs = new WebSocket('wss://ws.blockchain.info/inv');

btcs.onopen = function()
{
btcs.send( JSON.stringify( {"op":"addr_sub", "addr":"15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi"} ) );
};

btcs.onmessage = function(onmsg)
{
  var response = JSON.parse(onmsg.data);
  var getOuts = response.x.out;
  var countOuts = getOuts.length; 
  for(i = 0; i < countOuts; i++)
  {
    //check every output to see if it matches specified address
    var outAdd = response.x.out[i].addr;
    var specAdd = "15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi";
       if (outAdd == specAdd )
       {
       var amount = response.x.out[i].value;
       var calAmount = amount / 100000000;
       $('#messages').prepend("<p>" + calAmount + "</p>");
       }
  } 
}

```


---

