Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get amount of Bitcoins at an address with PHP

I'm using Coinbase, but they don't have an API call to get the amount of Bitcoins per address, but only per account, which is a collection of addresses.

Does anyone have an API call for this? I'd prefer to not to reinvent the wheel by setting up my own Bitcoin server/daemon as suggested in this other SO thread:

How to check Bitcoin address balance from my application?

like image 695
tim peterson Avatar asked Dec 20 '22 16:12

tim peterson


1 Answers

Hmm, would this work for you:

<?php
function getBalance($address) {
    return file_get_contents('https://blockchain.info/q/addressbalance/'. $address);
}

echo 'Address Balance: ' . getBalance('1EzwoHtiXB4iFwedPr49iywjZn2nnekhoj');

Using the https://blockchain.info/q API.

like image 170
Jens A. Koch Avatar answered Dec 22 '22 05:12

Jens A. Koch