When does `vin` contain multiple addresses I need to find out all the bitcoins transferred from a particular address to a particular address. 

For this I am using the blockexplorer API, for this I use their "Transactions for multiple addresses" API since only this provides a paginated response. Others only give 10 results by default. 

So I iterate through transactions, look fromAddress in vin, similarly search for toAddress in vout. If all satisfied I take that value. 

for transaction in txs:
  valueIn = transaction['valueIn']
  valueOut = transaction['valueOut']
  confirmations = transaction['confirmations']
  if confirmations &gt;= 12:
    vin = transaction['vin']
  for row in vin:
      if row['addr'] == fromAddress:
        vout = transaction['vout']
        for j in vout:
          addresses = j['scriptPubKey']['addresses']
          if toAddress in set(addresses):
            output.append(j['value'])


But in some case I saw multiple addresses in vin, when is that? 
Would my logic would still be right, if my address is part of that?
So a transaction will have multiple vins, if it takes multiple UTXOs to send the value.

So let's say you in the past have received 10BTC from X, and 5BTC from Y.

You now need to send 11BTC to Kate.

What it will do is, 

it will send out the 10BTC from X, as this is an Unspent Transaction Output, it will then send out the 5BTC from Y and send you back 4BTC.

In this case, you may see 2 inputs on the input side.

Your logic may not work because the "fromAddress" for the 10BTC might be the fromAddress that you hold, but the fromAddress for the BTC, you may not have.

In order to find out all transactions from personA to personB, you must know all of their public addresses in their wallet.

You also cannot assume that all inputs, are from personA because with BTC you can pool transactions, so each input can be from another person.

If you had all of the addresses, your code would look something like this:

if fromAddresses.contains(row['addr']):


Hope that helps.