Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

I'm running a Bitcoin blog and I'd love to display a ticket of the total amount of Bitcoins in existence. Unfortunately, I'm not sure where I can find a JSON feed for this (now that MTGOX is gone). Is there something like this I can utilize?

share|improve this question
add comment

2 Answers 2

Take a look at this, its the blockchain.info api. it gives a json feed for many things.

share|improve this answer
add comment

The number of bitcoins in existence at any given time is predictable in advance. To get an approximate number, you just need to look it up in a table based on today's date. The Bitcoin wiki has one at Controlled supply.

To get the precise number of mined bitcoins at any given moment, you would take the current block height (available from any of a number of different places) and apply a fixed formula to get the current total number of rewards claimed so far. This number would be exact because there is no possibility of varying from the predetermined reward schedule (and there is no other way of conjuring bitcoins into existence other than mining).

The following is a simple Python function which calculates the total bitcoins in existence at any time given the block height. It should be straightforward to translate to PHP.

def total_bitcoins(height):
    total = 0
    reward = 50
    while height >= 210000:
        total += reward * 210000
        height -= 210000
        reward /= 2
    total += reward * height
    return total

https://gist.github.com/ghewgill/9821866

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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