How to get the list of transactions that has gone into an address with the amount and date?

1

How to get the list of transactions that has deposited funds in an address, including information about the amount that has been deposited (sent towards my address not sent away from it), and the date when the transaction occurred.

For example here is address A (my address) :

TX 1)  from address B , 2   bitcoins , 2014 1 january 12:12 pm 
TX 2)  from address C , 1   bitcoins , 2014 2 january 7:51 am 
TX 3)  from address D , 4   bitcoins , 2014 5 january 3:22 am 
TX 4)  from address E , 0.5 bitcoins , 2014 6 january 1:42 pm

Also, I want it to use an API that is online, so that I don't need to download the whole block chain.

Preferably blockchain.info API or blockexporer.com API would be nice.

A link to a tutorial would also be helpful. I have an specific application in mind that needs this info for an address.

Mr. Curious

Posted 2015-01-06T03:13:28.493

Reputation: 11

Answers

1

You could achieve this by getting the transactions an address has been involved in and filtering on the outputs with that address hash.

We've just released our own free API called Blocktrail and provide SDKs for PHP, Python and NodeJS which make getting blockchain data trivial.

Assuming PHP you could do the following:

Initialise the Blocktrail SDK

use \Blocktrail\SDK\BlocktrailSDK;
$client = new BlocktrailSDK("MY_APIKEY", "MY_APISECRET", "BTC", false);

Get the address' transactions

$address = "1A4NfSJDzxzKgRrgfjxSAQ8hCPJJWKcmzX";
$page = 1;
$limit = 500;
$sortDir = "desc";
$transactions = $client->addressTransactions($address, $page, $limit, $sortDir);

For each transaction get the amount sent to this address from the outputs

$deposits = array();
foreach($transactions as $tx) {
    foreach($tx['outputs'] as $txout) {
      if($txout['address'] == $address) {
        $deposits[] = $txout['value'];
      }
    }
}

Tutorials and Examples

We'll be creating in-depth tutorials really soon, but for now you can check the API documentation for code examples and descriptions of the data returned.

There is also an example project on github: A Simple Block Explorer

OACDesigns

Posted 2015-01-06T03:13:28.493

Reputation: 121

Good answer! Does the Blocktrail API sort the transactions by date? The API docs are sorta unclear about this.Nick ODell 2015-01-06T16:26:38.477

Ah, thanks for pointing that out. Yes they are sorted by time, with 'desc' giving you the most recent transactions first.OACDesigns 2015-01-06T20:36:06.930

@OACDesigns I just want a simple CSV that I can import into Google Sheets, so I'm trying to use your "CSV_EXPORT" option, like so: https://api.blocktrail.com/v1/BTC/address/16LzffMx6TqbMX4za7LEUkrLrWifhLfu9w/transactions.csv?limit=200&api_key=CSV_EXPORT

Unfortunately if the limit is set to anything more than about 100, it times out. Is there a way to get the whole transaction history of an address reliably? – Jonathan van Clute 2017-03-17T19:09:15.647

@JonathanvanClute Hi Jonathan, unfortunately I am no longer involved in the project so I can't really help with this. I would suggest reaching out to the Blocktrail devs by email or on twitterOACDesigns 2017-03-20T16:52:11.603

Ah ok, I really appreciate the tip!Jonathan van Clute 2017-03-20T16:53:11.627

no problem, I hope you find a solution!OACDesigns 2017-03-22T15:21:18.703