Post
Topic
Board Project Development
Re: [Question] Fast way to check bulk address bitcoin balance
by
DanielHoffman
on 15/11/2023, 19:36:57 UTC
Using requests.get is indeed very slow.

To check the balance of Bitcoin addresses in bulk, you would want an API that supports batch requests.
This would speed up the whole process since you can query multiple addresses within a single API call. The Blockchain.com API supports batch requests for address balances.

Code:
import requests

def fetch_balances(addresses):
    address_list = '|'.join(addresses)

    api_endpoint = f'https://blockchain.info/balance?active={address_list}'

    response = requests.get(api_endpoint)
    data = response.json()

    for address, info in data.items():
        balance = info['final_balance']
        print(f"Address: {address}, Balance: {balance} ")

addresses = ['address1', 'address2', 'address3', ...]

fetch_balances(addresses)

A simple python script that would help you to fetch the balances of multiple addresses. The output would be in satoshis due to API of Blockchain.com

Thanks but already do check balance in same 50 seconds  Embarrassed, honestly i want to do this very fast but it's okay