<p>Solution script:</p>
<pre><code>#!/usr/bin/env python3

import requests

addr=input('Enter address to check: ')

if addr=='':
    exit()

r=requests.get('https://blockchain.info/q/addressbalance/'+addr)

if not r.status_code==200:
    print('Error',r.status_code)
    exit()

b=int(r.text)

print(addr,'\t',r.text,'sat\t',b/100000,'mBTC\t',b/100000000,'BTC')
</code></pre>

CC BY-SA 4.0
2023-06-12T00:51:30.387Z
2023-06-12T00:51:30.387Z
pbies
<p>You <em>can</em> access an API and be limited by their ToS but you don't have to.</p>
<p>All transactions (<code>TX</code>) and BTC addresses (<code>pubKey</code>) are public on the blockchain with the distinction that all TX are recorded, but <code>pubKeys</code> show up only once mentioned in a <code>TX</code>.</p>
<p>Assuming you're talking about bitcoin and not something else you should run <code>bitcoind</code> on your machine and query it locally without limitations.</p>
<p><code>bitcoin-cli getbalance</code></p>

CC BY-SA 4.0
2022-11-06T05:02:12.557Z
`getbalance` is about wallet, not transactions in the blockchain...
pbies
CC BY-SA 4.0
2022-11-06T02:59:21.400Z
2022-11-06T02:59:21.400Z
CSᵠ
<p>You can use services like <a href="https://www.blockchain.com/explorer/" rel="nofollow noreferrer">blockchain.com</a>, <a href="https://blockchair.com/" rel="nofollow noreferrer">blockchair.com</a> or <a href="https://tokenview.io/" rel="nofollow noreferrer">tokenview.io</a> to explore crypto addresses. It will show you balance, a list of transactions, date and time and some additional info.
As for your script, you can use <code>requests</code> library to send requests to API and receive JSON data or scrape the web-sites directly using <code>requests</code> and <code>beautifulsoup</code>.</p>

CC BY-SA 4.0
2023-06-01T11:47:35.287Z
2023-06-01T11:47:35.287Z
MagentaPink
<p>I am willing to write Python script to check for some public addresses balances. I understand that I need to access API of known exchanges (Coinbase, Binance). I also know that there will be limit of requests sent in time.</p>
<p>As far as I can see there is possibility to check for wallet balances. But what about checking some public BTC addresses?</p>

<address><api>
Check public address balance
pbies
# Check public address balance

(Asked by: username_0 on 2022-11-06)

I am willing to write Python script to check for some public addresses balances. I understand that I need to access API of known exchanges (Coinbase, Binance). I also know that there will be limit of requests sent in time.

As far as I can see there is possibility to check for wallet balances. But what about checking some public BTC addresses?

**Tags:** address, api


---

## 3 answers

### Answer by username_0 on 2023-06-12. Score: 1 | Accepted answer

Solution script:
#!/usr/bin/env python3

import requests

addr=input('Enter address to check: ')

if addr=='':
    exit()

r=requests.get('https://blockchain.info/q/addressbalance/'+addr)

if not r.status_code==200:
    print('Error',r.status_code)
    exit()

b=int(r.text)

print(addr,'\t',r.text,'sat\t',b/100000,'mBTC\t',b/100000000,'BTC')


---

### Answer by username_1 on 2022-11-06. Score: 1

You *can* access an API and be limited by their ToS but you don't have to.

All transactions (`TX`) and BTC addresses (`pubKey`) are public on the blockchain with the distinction that all TX are recorded, but `pubKeys` show up only once mentioned in a `TX`.

Assuming you're talking about bitcoin and not something else you should run `bitcoind` on your machine and query it locally without limitations.

`bitcoin-cli getbalance`

> **Comments:**
> **username_0**: `getbalance` is about wallet, not transactions in the blockchain...  

---

### Answer by username_2 on 2023-06-01. Score: 1

You can use services like [blockchain.com](https://www.blockchain.com/explorer/), [blockchair.com](https://blockchair.com/) or [tokenview.io](https://tokenview.io/) to explore crypto addresses. It will show you balance, a list of transactions, date and time and some additional info.
As for your script, you can use `requests` library to send requests to API and receive JSON data or scrape the web-sites directly using `requests` and `beautifulsoup`.


---

