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.

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

  • Good answer! Does the Blocktrail API sort the transactions by date? The API docs are sorta unclear about this. – Nick ODell Jan 6 '15 at 16:26
  • Ah, thanks for pointing that out. Yes they are sorted by time, with 'desc' giving you the most recent transactions first. – OACDesigns Jan 6 '15 at 20:36
  • @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 Mar 17 '17 at 19:09
  • @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 twitter – OACDesigns Mar 20 '17 at 16:52
  • Ah ok, I really appreciate the tip! – Jonathan van Clute Mar 20 '17 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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