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?

  • 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? Oct 1, 2015 at 5:22
  • 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
    Oct 1, 2015 at 20:29

1 Answer 1


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>");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.