2

How to get balances and transactions of a Bitcoin address? I'm looking into bitcoin development and relatively new to the space. - Tien

1
  • Using which wallet software?
    – Mercedes
    Commented Jun 14, 2023 at 18:51

1 Answer 1

2

You can get this data by hosting Blockbook and using REST query:

GET /api/v2/address/<address>[?page=<page>&pageSize=<size>&from=<block height>&to=<block height>&details=<basic|tokens|tokenBalances|txids|txs>&contract=<contract address>&secondary=usd]

Or you can simply use the Blockbook RPC Add-on of QuickNode Marketplace.

Once you have the Add-on enabled on your QuickNode Bitcoin RPC. The method to be used is bb_getaddress and the code should look something like this:

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "method": "bb_getaddress",
  "params": [
    "ADDRESS_TO_GET_TXs_AND_BALANCES",
    {
      "page": 1,
      "size": 1000,
      "fromHeight": 0,
      "details": "txids"
    }
  ]
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("QUICKNODE_BTC_RPC_URL_HERE", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

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.